CCCL (CUDA C++ Core Libraries) provides: - CUB: device/block/warp-level GPU primitives (reduce, scan, sort, topk) - Thrust: high-level parallel algorithms (transform_reduce, sort, scan) - libcudacxx: CUDA C++ standard library (atomics, barriers, memory) - cudax: experimental features (memory resources, allocators) - Tuning policies: per-SM hardware-specific algorithm parameters Competition optimization vectors mapped to CCCL: - Output TPS (83% weight): warp_reduce, block_reduce, device_topk - Input TPS (14% weight): device_scan, block_load, prefetch - Cache TPS (3% weight): prefix caching strategy patterns - Memory (0.9 util): pooled/cached/buddy allocators Source: https://github.com/NVIDIA/cccl (shallow clone, HEAD only) License: Apache-2.0
141 lines
4.5 KiB
C
141 lines
4.5 KiB
C
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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
|
|
// NOLINTBEGIN(modernize-use-using)
|
|
|
|
#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 <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include <cccl/c/extern_c.h>
|
|
#include <cccl/c/types.h>
|
|
|
|
CCCL_C_EXTERN_C_BEGIN
|
|
|
|
typedef struct cccl_device_histogram_build_result_t
|
|
{
|
|
int cc;
|
|
void* payload;
|
|
size_t payload_size;
|
|
cccl_payload_kind_t payload_kind;
|
|
CUlibrary library;
|
|
cccl_type_info counter_type;
|
|
cccl_type_info level_type;
|
|
cccl_type_info sample_type;
|
|
int num_active_channels;
|
|
bool may_overflow;
|
|
CUkernel init_kernel;
|
|
CUkernel sweep_kernel;
|
|
void* runtime_policy;
|
|
size_t runtime_policy_size;
|
|
char* init_kernel_lowered_name;
|
|
char* sweep_kernel_lowered_name;
|
|
} 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_type_info level_type,
|
|
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);
|
|
|
|
// Extended version with build configuration
|
|
CCCL_C_API CUresult cccl_device_histogram_build_ex(
|
|
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_type_info level_type,
|
|
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_build_config* config);
|
|
|
|
CCCL_C_API CUresult cccl_device_histogram_compile(
|
|
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_type_info level_type,
|
|
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_build_config* config);
|
|
|
|
CCCL_C_API CUresult cccl_device_histogram_load(cccl_device_histogram_build_result_t* build);
|
|
|
|
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_link_ltoir(
|
|
cccl_device_histogram_build_result_t* build, const void** input_blobs, const size_t* input_sizes, size_t num_inputs);
|
|
|
|
// Serializes a populated build_result into a self-describing byte buffer.
|
|
// On success *out_buf points to a heap allocation that the caller must free
|
|
// with cccl_serialization_buffer_free, and *out_size holds its length. The build_result
|
|
// itself is not modified. CUlibrary/CUkernel handles are not serialized.
|
|
CCCL_C_API CUresult
|
|
cccl_device_histogram_serialize(const cccl_device_histogram_build_result_t* build, void** out_buf, size_t* out_size);
|
|
|
|
// Reconstructs a build_result from a buffer produced by cccl_device_histogram_serialize.
|
|
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
|
// remain null until cccl_device_histogram_load is called. On failure build is
|
|
// left unchanged and a non-success CUresult is returned.
|
|
CCCL_C_API CUresult
|
|
cccl_device_histogram_deserialize(cccl_device_histogram_build_result_t* build, const void* buf, size_t size);
|
|
|
|
CCCL_C_API CUresult cccl_device_histogram_cleanup(cccl_device_histogram_build_result_t* bld_ptr);
|
|
|
|
CCCL_C_EXTERN_C_END
|
|
// NOLINTEND(modernize-use-using)
|