Skip to content

Add Histogram implementation for c.parallel #4689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bf6b404
Move histogram kernels to nvrtc compilable header
NaderAlAwar May 1, 2025
c9f6cdb
Implement dynamic dispatch for histogram. I moved the transforms to a…
NaderAlAwar May 5, 2025
4dec1b0
Merge branch 'main' into histogram-dynamic-cub-dispatch
NaderAlAwar May 5, 2025
5502a47
Use different strategy to pass kernels
NaderAlAwar May 5, 2025
ac3d31c
Add initial c.parallel histogram implementation
NaderAlAwar May 6, 2025
c9ab949
Continue implementing histogram
NaderAlAwar May 7, 2025
0e6806c
Make SampleT template parameter
NaderAlAwar May 8, 2025
ec2633c
Merge branch 'histogram-dynamic-cub-dispatch' into histogram-c-parallel
NaderAlAwar May 8, 2025
7a6c329
weird conflict in unique_by_key
NaderAlAwar May 8, 2025
afe411a
Use new SampleT template parameter
NaderAlAwar May 8, 2025
e9ac6e4
Merge branch 'histogram-dynamic-cub-dispatch' into histogram-c-parallel
NaderAlAwar May 8, 2025
a7bc270
Fix issue with macro
NaderAlAwar May 9, 2025
57a091c
Merge branch 'histogram-dynamic-cub-dispatch' into histogram-c-parallel
NaderAlAwar May 9, 2025
f1d9628
Revert "weird conflict in unique_by_key"
NaderAlAwar May 9, 2025
86b86da
Make TransformsT a template parameter
NaderAlAwar May 9, 2025
b500558
Merge branch 'histogram-dynamic-cub-dispatch' into histogram-c-parallel
NaderAlAwar May 9, 2025
b42d8e6
Further fixes to fix compilation errors
NaderAlAwar May 9, 2025
a1eef4f
Set build elements and start with minimal test
NaderAlAwar May 11, 2025
55af8b1
Get working version of histogram
NaderAlAwar May 12, 2025
af6bacd
Make type usage uniform
NaderAlAwar May 12, 2025
c2921eb
Add comment on our fixed choice of LevelT
NaderAlAwar May 12, 2025
3afd42e
Clean up code
NaderAlAwar May 12, 2025
7e6a08a
Make counter type generic
NaderAlAwar May 12, 2025
99f658a
FUrther fixes to histogram
NaderAlAwar May 13, 2025
d343d87
Fix histogram test not working
NaderAlAwar May 13, 2025
ce2760b
Make API test more clear
NaderAlAwar May 13, 2025
c4d06e8
Expand test case
NaderAlAwar May 13, 2025
b1bcc35
Begin implementing histogram range
NaderAlAwar May 13, 2025
9ba61f3
Get counter and level types from inputs
NaderAlAwar May 15, 2025
4bae19f
Make level arrays cccl_value_t instead of cccl_iterator_t
NaderAlAwar May 15, 2025
e079de9
Make levels arrays cccl_value_t
NaderAlAwar May 15, 2025
b8fbcec
Merge branch 'main' into histogram-dynamic-cub-dispatch
NaderAlAwar May 16, 2025
f826842
Merge branch 'main' into histogram-dynamic-cub-dispatch
bernhardmgruber May 19, 2025
7174bfe
Address comments to improve readability
NaderAlAwar May 20, 2025
25cc856
Merge branch 'histogram-dynamic-cub-dispatch' into histogram-c-parallel
NaderAlAwar May 20, 2025
9b432fa
Remove unused variable
NaderAlAwar May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions c/parallel/include/cccl/c/histogram.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// Part of CUDA Experimental in CUDA Core Compute Libraries,
// under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//

#pragma once

#ifndef CCCL_C_EXPERIMENTAL
# error "C exposure is experimental and subject to change. Define CCCL_C_EXPERIMENTAL to acknowledge this notice."
#endif // !CCCL_C_EXPERIMENTAL

#include <cuda.h>

#include <cccl/c/extern_c.h>
#include <cccl/c/types.h>
#include <stdbool.h>
#include <stdint.h>

CCCL_C_EXTERN_C_BEGIN

typedef struct cccl_device_histogram_build_result_t
{
int cc;
void* cubin;
size_t cubin_size;
CUlibrary library;
cccl_type_info counter_type;
int num_active_channels;
CUkernel init_kernel;
CUkernel sweep_kernel;
} cccl_device_histogram_build_result_t;

CCCL_C_API CUresult cccl_device_histogram_build(
cccl_device_histogram_build_result_t* build,
int num_channels,
int num_active_channels,
cccl_iterator_t d_samples,
int num_output_levels_val,
cccl_iterator_t d_output_histograms,
cccl_value_t d_levels,
int64_t num_rows,
int64_t row_stride_samples,
bool is_evenly_segmented,
int cc_major,
int cc_minor,
const char* cub_path,
const char* thrust_path,
const char* libcudacxx_path,
const char* ctk_path);

CCCL_C_API CUresult cccl_device_histogram_range(
cccl_device_histogram_build_result_t build,
void* d_temp_storage,
size_t* temp_storage_bytes,
cccl_iterator_t d_samples,
cccl_iterator_t d_output_histograms,
cccl_value_t num_output_levels,
cccl_value_t d_levels,
int64_t num_row_pixels,
int64_t num_rows,
int64_t row_stride_samples,
CUstream stream);

CCCL_C_API CUresult cccl_device_histogram_even(
cccl_device_histogram_build_result_t build,
void* d_temp_storage,
size_t* temp_storage_bytes,
cccl_iterator_t d_samples,
cccl_iterator_t d_output_histograms,
cccl_value_t num_output_levels,
cccl_value_t lower_level,
cccl_value_t upper_level,
int64_t num_row_pixels,
int64_t num_rows,
int64_t row_stride_samples,
CUstream stream);

CCCL_C_API CUresult cccl_device_histogram_cleanup(cccl_device_histogram_build_result_t* bld_ptr);

CCCL_C_EXTERN_C_END
Loading