[INFRA] Import NVIDIA/CCCL upstream as optimization reference library
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
This commit is contained in:
121
cccl_upstream/c/parallel/include/cccl/c/binary_search.h
Normal file
121
cccl_upstream/c/parallel/include/cccl/c/binary_search.h
Normal file
@@ -0,0 +1,121 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDA Experimental in CUDA C++ Core 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) 2024 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/transform.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_binary_search_build_result_t
|
||||
{
|
||||
cccl_device_transform_build_result_t transform;
|
||||
size_t op_state_size;
|
||||
size_t op_state_alignment;
|
||||
} cccl_device_binary_search_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_binary_search_build(
|
||||
cccl_device_binary_search_build_result_t* build,
|
||||
cccl_binary_search_mode_t mode,
|
||||
cccl_iterator_t d_data,
|
||||
cccl_iterator_t d_values,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_binary_search_build_ex(
|
||||
cccl_device_binary_search_build_result_t* build,
|
||||
cccl_binary_search_mode_t mode,
|
||||
cccl_iterator_t d_data,
|
||||
cccl_iterator_t d_values,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_binary_search_compile(
|
||||
cccl_device_binary_search_build_result_t* build,
|
||||
cccl_binary_search_mode_t mode,
|
||||
cccl_iterator_t d_data,
|
||||
cccl_iterator_t d_values,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_binary_search_load(cccl_device_binary_search_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_binary_search(
|
||||
cccl_device_binary_search_build_result_t build,
|
||||
cccl_iterator_t d_data,
|
||||
uint64_t num_items,
|
||||
cccl_iterator_t d_values,
|
||||
uint64_t num_values,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_binary_search_link_ltoir(
|
||||
cccl_device_binary_search_build_result_t* build,
|
||||
const void** input_blobs,
|
||||
const size_t* input_sizes,
|
||||
size_t num_inputs,
|
||||
const char* kernel_lowered_name,
|
||||
size_t values_value_size,
|
||||
size_t output_value_size,
|
||||
size_t op_state_size,
|
||||
size_t op_state_alignment,
|
||||
int cc_major,
|
||||
int cc_minor);
|
||||
|
||||
// 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_binary_search_serialize(
|
||||
const cccl_device_binary_search_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_binary_search_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_binary_search_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_binary_search_deserialize(cccl_device_binary_search_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_binary_search_cleanup(cccl_device_binary_search_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
23
cccl_upstream/c/parallel/include/cccl/c/extern_c.h
Normal file
23
cccl_upstream/c/parallel/include/cccl/c/extern_c.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
# define CCCL_C_EXTERN_C_BEGIN extern "C" {
|
||||
# define CCCL_C_EXTERN_C_END }
|
||||
|
||||
#else
|
||||
|
||||
# define CCCL_C_EXTERN_C_BEGIN
|
||||
# define CCCL_C_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
99
cccl_upstream/c/parallel/include/cccl/c/for.h
Normal file
99
cccl_upstream/c/parallel/include/cccl/c/for.h
Normal file
@@ -0,0 +1,99 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDA Experimental in CUDA C++ Core 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) 2024 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_for_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
CUkernel static_kernel;
|
||||
char* static_kernel_lowered_name;
|
||||
} cccl_device_for_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_for_build(
|
||||
cccl_device_for_build_result_t* build,
|
||||
cccl_iterator_t d_data,
|
||||
cccl_op_t op,
|
||||
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_for_build_ex(
|
||||
cccl_device_for_build_result_t* build,
|
||||
cccl_iterator_t d_data,
|
||||
cccl_op_t op,
|
||||
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_for_compile(
|
||||
cccl_device_for_build_result_t* build,
|
||||
cccl_iterator_t d_data,
|
||||
cccl_op_t op,
|
||||
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_for_load(cccl_device_for_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_for_link_ltoir(
|
||||
cccl_device_for_build_result_t* build, const void** input_blobs, const size_t* input_sizes, size_t num_inputs);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_for(
|
||||
cccl_device_for_build_result_t build, cccl_iterator_t d_data, uint64_t num_items, cccl_op_t op, CUstream stream);
|
||||
|
||||
// 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_for_serialize(const cccl_device_for_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_for_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_for_load is called. If the deserialized payload
|
||||
// kind is CCCL_PAYLOAD_LTOIR, cccl_device_for_link_ltoir must be called before
|
||||
// cccl_device_for_load. On failure build is left unchanged and a non-success
|
||||
// CUresult is returned.
|
||||
CCCL_C_API CUresult cccl_device_for_deserialize(cccl_device_for_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_for_cleanup(cccl_device_for_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
140
cccl_upstream/c/parallel/include/cccl/c/histogram.h
Normal file
140
cccl_upstream/c/parallel/include/cccl/c/histogram.h
Normal file
@@ -0,0 +1,140 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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)
|
||||
124
cccl_upstream/c/parallel/include/cccl/c/merge_sort.h
Normal file
124
cccl_upstream/c/parallel/include/cccl/c/merge_sort.h
Normal file
@@ -0,0 +1,124 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_merge_sort_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
cccl_type_info key_type;
|
||||
cccl_type_info item_type;
|
||||
CUkernel block_sort_kernel;
|
||||
CUkernel partition_kernel;
|
||||
CUkernel merge_kernel;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* block_sort_kernel_lowered_name;
|
||||
char* partition_kernel_lowered_name;
|
||||
char* merge_kernel_lowered_name;
|
||||
} cccl_device_merge_sort_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_merge_sort_build(
|
||||
cccl_device_merge_sort_build_result_t* build,
|
||||
cccl_iterator_t d_in_keys,
|
||||
cccl_iterator_t d_in_items,
|
||||
cccl_iterator_t d_out_keys,
|
||||
cccl_iterator_t d_out_items,
|
||||
cccl_op_t op,
|
||||
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_merge_sort_build_ex(
|
||||
cccl_device_merge_sort_build_result_t* build,
|
||||
cccl_iterator_t d_in_keys,
|
||||
cccl_iterator_t d_in_items,
|
||||
cccl_iterator_t d_out_keys,
|
||||
cccl_iterator_t d_out_items,
|
||||
cccl_op_t op,
|
||||
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_merge_sort_compile(
|
||||
cccl_device_merge_sort_build_result_t* build,
|
||||
cccl_iterator_t d_in_keys,
|
||||
cccl_iterator_t d_in_items,
|
||||
cccl_iterator_t d_out_keys,
|
||||
cccl_iterator_t d_out_items,
|
||||
cccl_op_t op,
|
||||
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_merge_sort_load(cccl_device_merge_sort_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_merge_sort(
|
||||
cccl_device_merge_sort_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in_keys,
|
||||
cccl_iterator_t d_in_items,
|
||||
cccl_iterator_t d_out_keys,
|
||||
cccl_iterator_t d_out_items,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_merge_sort_link_ltoir(
|
||||
cccl_device_merge_sort_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_merge_sort_serialize(const cccl_device_merge_sort_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_merge_sort_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_merge_sort_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_merge_sort_deserialize(cccl_device_merge_sort_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_merge_sort_cleanup(cccl_device_merge_sort_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
146
cccl_upstream/c/parallel/include/cccl/c/radix_sort.h
Normal file
146
cccl_upstream/c/parallel/include/cccl/c/radix_sort.h
Normal file
@@ -0,0 +1,146 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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_radix_sort_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
cccl_type_info key_type;
|
||||
cccl_type_info value_type;
|
||||
CUkernel single_tile_kernel;
|
||||
CUkernel upsweep_kernel;
|
||||
CUkernel alt_upsweep_kernel;
|
||||
CUkernel scan_bins_kernel;
|
||||
CUkernel downsweep_kernel;
|
||||
CUkernel alt_downsweep_kernel;
|
||||
CUkernel histogram_kernel;
|
||||
CUkernel exclusive_sum_kernel;
|
||||
CUkernel init_bins_and_counters_kernel;
|
||||
CUkernel init_lookback_kernel;
|
||||
CUkernel onesweep_kernel;
|
||||
cccl_sort_order_t order;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* single_tile_kernel_lowered_name;
|
||||
char* upsweep_kernel_lowered_name;
|
||||
char* alt_upsweep_kernel_lowered_name;
|
||||
char* scan_bins_kernel_lowered_name;
|
||||
char* downsweep_kernel_lowered_name;
|
||||
char* alt_downsweep_kernel_lowered_name;
|
||||
char* histogram_kernel_lowered_name;
|
||||
char* exclusive_sum_kernel_lowered_name;
|
||||
char* init_bins_and_counters_kernel_lowered_name;
|
||||
char* init_lookback_kernel_lowered_name;
|
||||
char* onesweep_kernel_lowered_name;
|
||||
} cccl_device_radix_sort_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_radix_sort_build(
|
||||
cccl_device_radix_sort_build_result_t* build,
|
||||
cccl_sort_order_t sort_order,
|
||||
cccl_iterator_t input_keys_it,
|
||||
cccl_iterator_t input_values_it,
|
||||
cccl_op_t decomposer,
|
||||
const char* decomposer_return_type,
|
||||
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_radix_sort_build_ex(
|
||||
cccl_device_radix_sort_build_result_t* build,
|
||||
cccl_sort_order_t sort_order,
|
||||
cccl_iterator_t input_keys_it,
|
||||
cccl_iterator_t input_values_it,
|
||||
cccl_op_t decomposer,
|
||||
const char* decomposer_return_type,
|
||||
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_radix_sort_compile(
|
||||
cccl_device_radix_sort_build_result_t* build,
|
||||
cccl_sort_order_t sort_order,
|
||||
cccl_iterator_t input_keys_it,
|
||||
cccl_iterator_t input_values_it,
|
||||
cccl_op_t decomposer,
|
||||
const char* decomposer_return_type,
|
||||
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_radix_sort_load(cccl_device_radix_sort_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_radix_sort(
|
||||
cccl_device_radix_sort_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_keys_out,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t d_values_out,
|
||||
cccl_op_t decomposer,
|
||||
uint64_t num_items,
|
||||
int begin_bit,
|
||||
int end_bit,
|
||||
bool is_overwrite_okay,
|
||||
int* selector,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_radix_sort_link_ltoir(
|
||||
cccl_device_radix_sort_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_radix_sort_serialize(const cccl_device_radix_sort_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_radix_sort_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_radix_sort_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_radix_sort_deserialize(cccl_device_radix_sort_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_radix_sort_cleanup(cccl_device_radix_sort_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
135
cccl_upstream/c/parallel/include/cccl/c/reduce.h
Normal file
135
cccl_upstream/c/parallel/include/cccl/c/reduce.h
Normal file
@@ -0,0 +1,135 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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) 2024 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_reduce_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
uint64_t accumulator_size;
|
||||
CUkernel single_tile_kernel;
|
||||
CUkernel single_tile_second_kernel;
|
||||
CUkernel reduction_kernel;
|
||||
cccl_determinism_t determinism;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* single_tile_kernel_lowered_name;
|
||||
char* single_tile_second_kernel_lowered_name;
|
||||
char* reduction_kernel_lowered_name;
|
||||
} cccl_device_reduce_build_result_t;
|
||||
|
||||
// TODO return a union of nvtx/cuda/nvrtc errors or a string?
|
||||
CCCL_C_API CUresult cccl_device_reduce_build(
|
||||
cccl_device_reduce_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
cccl_determinism_t determinism,
|
||||
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_reduce_build_ex(
|
||||
cccl_device_reduce_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
cccl_determinism_t determinism,
|
||||
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_reduce_compile(
|
||||
cccl_device_reduce_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
cccl_determinism_t determinism,
|
||||
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_reduce_load(cccl_device_reduce_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_reduce(
|
||||
cccl_device_reduce_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_reduce_nondeterministic(
|
||||
cccl_device_reduce_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_reduce_link_ltoir(
|
||||
cccl_device_reduce_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_reduce_serialize(const cccl_device_reduce_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_reduce_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_reduce_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_reduce_deserialize(cccl_device_reduce_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_reduce_cleanup(cccl_device_reduce_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
169
cccl_upstream/c/parallel/include/cccl/c/scan.h
Normal file
169
cccl_upstream/c/parallel/include/cccl/c/scan.h
Normal file
@@ -0,0 +1,169 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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_scan_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
cccl_type_info input_type;
|
||||
cccl_type_info output_type;
|
||||
cccl_type_info accumulator_type;
|
||||
CUkernel init_kernel;
|
||||
CUkernel scan_kernel;
|
||||
bool force_inclusive;
|
||||
cccl_init_kind_t init_kind;
|
||||
size_t description_bytes_per_tile;
|
||||
size_t payload_bytes_per_tile;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* init_kernel_lowered_name;
|
||||
char* scan_kernel_lowered_name;
|
||||
} cccl_device_scan_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_scan_build(
|
||||
cccl_device_scan_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
cccl_type_info init,
|
||||
bool force_inclusive,
|
||||
cccl_init_kind_t init_kind,
|
||||
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_scan_build_ex(
|
||||
cccl_device_scan_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
cccl_type_info init,
|
||||
bool force_inclusive,
|
||||
cccl_init_kind_t init_kind,
|
||||
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_scan_compile(
|
||||
cccl_device_scan_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
cccl_type_info init,
|
||||
bool force_inclusive,
|
||||
cccl_init_kind_t init_kind,
|
||||
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_scan_load(cccl_device_scan_build_result_t* build_ptr);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_exclusive_scan(
|
||||
cccl_device_scan_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_inclusive_scan(
|
||||
cccl_device_scan_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_exclusive_scan_future_value(
|
||||
cccl_device_scan_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
cccl_iterator_t init,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_inclusive_scan_future_value(
|
||||
cccl_device_scan_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
cccl_iterator_t init,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_inclusive_scan_no_init(
|
||||
cccl_device_scan_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_scan_link_ltoir(
|
||||
cccl_device_scan_build_result_t* build, const void** input_blobs, const size_t* input_sizes, size_t num_inputs);
|
||||
|
||||
// Serialize a populated build_result. See cccl/c/serialization.h::cccl_serialization_buffer_free.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_scan_serialize(const cccl_device_scan_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_scan_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_scan_load is called. On failure build is left
|
||||
// unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult cccl_device_scan_deserialize(cccl_device_scan_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_scan_cleanup(cccl_device_scan_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
128
cccl_upstream/c/parallel/include/cccl/c/segmented_reduce.h
Normal file
128
cccl_upstream/c/parallel/include/cccl/c/segmented_reduce.h
Normal file
@@ -0,0 +1,128 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_segmented_reduce_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
uint64_t accumulator_size;
|
||||
CUkernel segmented_reduce_kernel;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* segmented_reduce_kernel_lowered_name;
|
||||
} cccl_device_segmented_reduce_build_result_t;
|
||||
|
||||
// TODO return a union of nvtx/cuda/nvrtc errors or a string?
|
||||
CCCL_C_API CUresult cccl_device_segmented_reduce_build(
|
||||
cccl_device_segmented_reduce_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_iterator_t begin_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
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_segmented_reduce_build_ex(
|
||||
cccl_device_segmented_reduce_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_iterator_t begin_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
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_segmented_reduce_compile(
|
||||
cccl_device_segmented_reduce_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_iterator_t begin_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
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_segmented_reduce_load(cccl_device_segmented_reduce_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_segmented_reduce(
|
||||
cccl_device_segmented_reduce_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_segments,
|
||||
cccl_iterator_t start_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
cccl_op_t op,
|
||||
cccl_value_t init,
|
||||
size_t max_segment_size,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_segmented_reduce_link_ltoir(
|
||||
cccl_device_segmented_reduce_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_segmented_reduce_serialize(
|
||||
const cccl_device_segmented_reduce_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_segmented_reduce_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_segmented_reduce_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult cccl_device_segmented_reduce_deserialize(
|
||||
cccl_device_segmented_reduce_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_segmented_reduce_cleanup(cccl_device_segmented_reduce_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
142
cccl_upstream/c/parallel/include/cccl/c/segmented_sort.h
Normal file
142
cccl_upstream/c/parallel/include/cccl/c/segmented_sort.h
Normal file
@@ -0,0 +1,142 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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_segmented_sort_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
cccl_type_info key_type;
|
||||
cccl_type_info offset_type;
|
||||
cccl_op_t large_segments_selector_op;
|
||||
cccl_op_t small_segments_selector_op;
|
||||
CUkernel segmented_sort_fallback_kernel;
|
||||
CUkernel segmented_sort_kernel_small;
|
||||
CUkernel segmented_sort_kernel_large;
|
||||
CUkernel three_way_partition_init_kernel;
|
||||
CUkernel three_way_partition_kernel;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
void* partition_runtime_policy;
|
||||
size_t partition_runtime_policy_size;
|
||||
cccl_sort_order_t order;
|
||||
char* segmented_sort_fallback_kernel_lowered_name;
|
||||
char* segmented_sort_kernel_small_lowered_name;
|
||||
char* segmented_sort_kernel_large_lowered_name;
|
||||
char* three_way_partition_init_kernel_lowered_name;
|
||||
char* three_way_partition_kernel_lowered_name;
|
||||
} cccl_device_segmented_sort_build_result_t;
|
||||
|
||||
// TODO return a union of nvtx/cuda/nvrtc errors or a string?
|
||||
CCCL_C_API CUresult cccl_device_segmented_sort_build(
|
||||
cccl_device_segmented_sort_build_result_t* build,
|
||||
cccl_sort_order_t sort_order,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t begin_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
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 (mirrors radix_sort build_ex)
|
||||
CCCL_C_API CUresult cccl_device_segmented_sort_build_ex(
|
||||
cccl_device_segmented_sort_build_result_t* build,
|
||||
cccl_sort_order_t sort_order,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t begin_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
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_segmented_sort_compile(
|
||||
cccl_device_segmented_sort_build_result_t* build,
|
||||
cccl_sort_order_t sort_order,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t begin_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
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_segmented_sort_load(cccl_device_segmented_sort_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_segmented_sort(
|
||||
cccl_device_segmented_sort_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_keys_out,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t d_values_out,
|
||||
uint64_t num_items,
|
||||
uint64_t num_segments,
|
||||
cccl_iterator_t start_offset_in,
|
||||
cccl_iterator_t end_offset_in,
|
||||
bool is_overwrite_okay,
|
||||
int* selector,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_segmented_sort_link_ltoir(
|
||||
cccl_device_segmented_sort_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_segmented_sort_serialize(
|
||||
const cccl_device_segmented_sort_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_segmented_sort_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_segmented_sort_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_segmented_sort_deserialize(cccl_device_segmented_sort_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_segmented_sort_cleanup(cccl_device_segmented_sort_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
50
cccl_upstream/c/parallel/include/cccl/c/serialization.h
Normal file
50
cccl_upstream/c/parallel/include/cccl/c/serialization.h
Normal file
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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) 2026 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 <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
// Algorithm tag stored in the blob header. Used to detect cross-algorithm
|
||||
// deserialization attempts (e.g. loading a reduce blob with scan_deserialize).
|
||||
typedef enum cccl_serialization_algo_t
|
||||
{
|
||||
CCCL_SERIALIZATION_ALGO_REDUCE = 1,
|
||||
CCCL_SERIALIZATION_ALGO_SCAN = 2,
|
||||
CCCL_SERIALIZATION_ALGO_SEGMENTED_REDUCE = 3,
|
||||
CCCL_SERIALIZATION_ALGO_TRANSFORM = 4,
|
||||
CCCL_SERIALIZATION_ALGO_BINARY_SEARCH = 5,
|
||||
CCCL_SERIALIZATION_ALGO_MERGE_SORT = 6,
|
||||
CCCL_SERIALIZATION_ALGO_RADIX_SORT = 7,
|
||||
CCCL_SERIALIZATION_ALGO_SEGMENTED_SORT = 8,
|
||||
CCCL_SERIALIZATION_ALGO_THREE_WAY_PARTITION = 9,
|
||||
CCCL_SERIALIZATION_ALGO_UNIQUE_BY_KEY = 10,
|
||||
CCCL_SERIALIZATION_ALGO_HISTOGRAM = 11,
|
||||
CCCL_SERIALIZATION_ALGO_FOR = 12,
|
||||
} cccl_serialization_algo_t;
|
||||
|
||||
// Frees a buffer returned by any cccl_device_<algo>_serialize call.
|
||||
// Required because allocations cross the cccl.c.parallel shared-library
|
||||
// boundary; callers must not free returned buffers themselves.
|
||||
CCCL_C_API void cccl_serialization_buffer_free(void* buf);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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) 2026 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 <stddef.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
// Diagnostics for the deserialize path. Declared in a standalone header
|
||||
// (rather than serialization.h, which is pulled in transitively by every algorithm
|
||||
// translation unit) so adding it does not trigger a rebuild of the whole C
|
||||
// parallel library.
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
// Returns a human-readable description of the most recent serialization failure on the
|
||||
// calling thread, or "" if none. The returned pointer is owned by the library
|
||||
// and is valid until the next serialization call on the same thread. Callers can surface
|
||||
// this so a deserialize failure carries an actionable message instead of only an
|
||||
// opaque CUDA error code.
|
||||
CCCL_C_API const char* cccl_serialization_last_error(void);
|
||||
|
||||
// Validates that a serialization blob (a build_result blob, i.e. what is passed to
|
||||
// cccl_device_<algo>_deserialize) can be loaded on the current device, *before*
|
||||
// the opaque cuLibraryLoadData failure. Checks the blob magic and, for CUBIN
|
||||
// payloads, that the target compute-capability major matches the current device.
|
||||
//
|
||||
// Returns CUDA_SUCCESS if the blob looks loadable, or an error code with a
|
||||
// message retrievable via cccl_serialization_last_error(). This never executes device
|
||||
// code; it only inspects the header.
|
||||
CCCL_C_API CUresult cccl_serialization_validate_blob(const void* buf, size_t size);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
132
cccl_upstream/c/parallel/include/cccl/c/three_way_partition.h
Normal file
132
cccl_upstream/c/parallel/include/cccl/c/three_way_partition.h
Normal file
@@ -0,0 +1,132 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_three_way_partition_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
CUkernel three_way_partition_init_kernel;
|
||||
CUkernel three_way_partition_kernel;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* three_way_partition_init_kernel_lowered_name;
|
||||
char* three_way_partition_kernel_lowered_name;
|
||||
} cccl_device_three_way_partition_build_result_t;
|
||||
|
||||
// TODO return a union of nvtx/cuda/nvrtc errors or a string?
|
||||
CCCL_C_API CUresult cccl_device_three_way_partition_build(
|
||||
cccl_device_three_way_partition_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_first_part_out,
|
||||
cccl_iterator_t d_second_part_out,
|
||||
cccl_iterator_t d_unselected_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t select_first_part_op,
|
||||
cccl_op_t select_second_part_op,
|
||||
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_three_way_partition_build_ex(
|
||||
cccl_device_three_way_partition_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_first_part_out,
|
||||
cccl_iterator_t d_second_part_out,
|
||||
cccl_iterator_t d_unselected_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t select_first_part_op,
|
||||
cccl_op_t select_second_part_op,
|
||||
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_three_way_partition_compile(
|
||||
cccl_device_three_way_partition_build_result_t* build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_first_part_out,
|
||||
cccl_iterator_t d_second_part_out,
|
||||
cccl_iterator_t d_unselected_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t select_first_part_op,
|
||||
cccl_op_t select_second_part_op,
|
||||
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_three_way_partition_load(cccl_device_three_way_partition_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_three_way_partition(
|
||||
cccl_device_three_way_partition_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_first_part_out,
|
||||
cccl_iterator_t d_second_part_out,
|
||||
cccl_iterator_t d_unselected_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t select_first_part_op,
|
||||
cccl_op_t select_second_part_op,
|
||||
uint64_t num_items,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_three_way_partition_link_ltoir(
|
||||
cccl_device_three_way_partition_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_three_way_partition_serialize(
|
||||
const cccl_device_three_way_partition_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_three_way_partition_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_three_way_partition_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult cccl_device_three_way_partition_deserialize(
|
||||
cccl_device_three_way_partition_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_three_way_partition_cleanup(cccl_device_three_way_partition_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
160
cccl_upstream/c/parallel/include/cccl/c/transform.h
Normal file
160
cccl_upstream/c/parallel/include/cccl/c/transform.h
Normal file
@@ -0,0 +1,160 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_transform_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
CUkernel transform_kernel;
|
||||
int loaded_bytes_per_iteration;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
void* cache;
|
||||
char* transform_kernel_lowered_name;
|
||||
} cccl_device_transform_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_unary_transform_build(
|
||||
cccl_device_transform_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_unary_transform_build_ex(
|
||||
cccl_device_transform_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_unary_transform_compile(
|
||||
cccl_device_transform_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_transform_load(cccl_device_transform_build_result_t* build_ptr);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_unary_transform(
|
||||
cccl_device_transform_build_result_t build,
|
||||
cccl_iterator_t d_in,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_binary_transform_build(
|
||||
cccl_device_transform_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in1,
|
||||
cccl_iterator_t d_in2,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_binary_transform_build_ex(
|
||||
cccl_device_transform_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in1,
|
||||
cccl_iterator_t d_in2,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_binary_transform_compile(
|
||||
cccl_device_transform_build_result_t* build_ptr,
|
||||
cccl_iterator_t d_in1,
|
||||
cccl_iterator_t d_in2,
|
||||
cccl_iterator_t d_out,
|
||||
cccl_op_t op,
|
||||
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_binary_transform(
|
||||
cccl_device_transform_build_result_t build,
|
||||
cccl_iterator_t d_in1,
|
||||
cccl_iterator_t d_in2,
|
||||
cccl_iterator_t d_out,
|
||||
uint64_t num_items,
|
||||
cccl_op_t op,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_transform_link_ltoir(
|
||||
cccl_device_transform_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_transform_serialize(const cccl_device_transform_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_transform_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_transform_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_transform_deserialize(cccl_device_transform_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_transform_cleanup(cccl_device_transform_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
186
cccl_upstream/c/parallel/include/cccl/c/types.h
Normal file
186
cccl_upstream/c/parallel/include/cccl/c/types.h
Normal file
@@ -0,0 +1,186 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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) 2024 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
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define CCCL_C_API __declspec(dllexport)
|
||||
#else // ^^^ _WIN32 ^^^ / vvv !_WIN32 vvv
|
||||
# define CCCL_C_API __attribute__((__visibility__("default")))
|
||||
#endif // !_WIN32
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef enum cccl_type_enum
|
||||
{
|
||||
CCCL_INT8 = 0,
|
||||
CCCL_INT16 = 1,
|
||||
CCCL_INT32 = 2,
|
||||
CCCL_INT64 = 3,
|
||||
CCCL_UINT8 = 4,
|
||||
CCCL_UINT16 = 5,
|
||||
CCCL_UINT32 = 6,
|
||||
CCCL_UINT64 = 7,
|
||||
CCCL_FLOAT16 = 8, // This may be unsupported if _CCCL_HAS_NVFP16() is false but we can't include the header to check
|
||||
// that here
|
||||
CCCL_FLOAT32 = 9,
|
||||
CCCL_FLOAT64 = 10,
|
||||
CCCL_STORAGE = 11,
|
||||
CCCL_BOOLEAN = 12,
|
||||
} cccl_type_enum;
|
||||
|
||||
typedef struct cccl_type_info
|
||||
{
|
||||
size_t size;
|
||||
size_t alignment;
|
||||
cccl_type_enum type;
|
||||
} cccl_type_info;
|
||||
|
||||
typedef enum cccl_op_kind_t
|
||||
{
|
||||
// Arbitrary semantics, without state.
|
||||
CCCL_STATELESS = 0,
|
||||
// Arbitrary semantics, with state.
|
||||
CCCL_STATEFUL = 1,
|
||||
// Well-known semantics, required to be stateless.
|
||||
// Equivalent to corresponding function objects in C++'s <functional>.
|
||||
// If the types involved are primitive, only the kind field is necessary.
|
||||
// Otherwise, the cccl_op_t object must also contain the rest of the fields,
|
||||
// as appropriate.
|
||||
CCCL_PLUS = 2,
|
||||
CCCL_MINUS = 3,
|
||||
CCCL_MULTIPLIES = 4,
|
||||
CCCL_DIVIDES = 5,
|
||||
CCCL_MODULUS = 6,
|
||||
CCCL_EQUAL_TO = 7,
|
||||
CCCL_NOT_EQUAL_TO = 8,
|
||||
CCCL_GREATER = 9,
|
||||
CCCL_LESS = 10,
|
||||
CCCL_GREATER_EQUAL = 11,
|
||||
CCCL_LESS_EQUAL = 12,
|
||||
CCCL_LOGICAL_AND = 13,
|
||||
CCCL_LOGICAL_OR = 14,
|
||||
CCCL_LOGICAL_NOT = 15,
|
||||
CCCL_BIT_AND = 16,
|
||||
CCCL_BIT_OR = 17,
|
||||
CCCL_BIT_XOR = 18,
|
||||
CCCL_BIT_NOT = 19,
|
||||
CCCL_IDENTITY = 20,
|
||||
CCCL_NEGATE = 21,
|
||||
CCCL_MINIMUM = 22,
|
||||
CCCL_MAXIMUM = 23,
|
||||
} cccl_op_kind_t;
|
||||
|
||||
typedef enum cccl_op_code_type
|
||||
{
|
||||
CCCL_OP_LTOIR = 0, // Pre-compiled LTO-IR (default for backward compatibility)
|
||||
CCCL_OP_CPP_SOURCE = 1 // C++ source code
|
||||
} cccl_op_code_type;
|
||||
|
||||
typedef struct cccl_op_t
|
||||
{
|
||||
cccl_op_kind_t type;
|
||||
const char* name;
|
||||
const char* code;
|
||||
size_t code_size;
|
||||
cccl_op_code_type code_type;
|
||||
size_t size;
|
||||
size_t alignment;
|
||||
void* state;
|
||||
const char** extra_ltoirs;
|
||||
size_t* extra_ltoir_sizes;
|
||||
size_t num_extra_ltoirs;
|
||||
cccl_op_code_type* extra_code_types;
|
||||
} cccl_op_t;
|
||||
|
||||
typedef struct cccl_build_config
|
||||
{
|
||||
const char** extra_compile_flags; // e.g., {"-DENABLE_FAST_MATH", "-O3"}
|
||||
size_t num_extra_compile_flags;
|
||||
const char** extra_include_dirs; // e.g., {"/path/to/my/headers"}
|
||||
size_t num_extra_include_dirs;
|
||||
} cccl_build_config;
|
||||
|
||||
typedef enum cccl_iterator_kind_t
|
||||
{
|
||||
CCCL_POINTER = 0,
|
||||
CCCL_ITERATOR = 1,
|
||||
} cccl_iterator_kind_t;
|
||||
|
||||
typedef struct cccl_value_t
|
||||
{
|
||||
cccl_type_info type;
|
||||
void* state;
|
||||
} cccl_value_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
int64_t signed_offset;
|
||||
uint64_t unsigned_offset;
|
||||
} cccl_increment_t;
|
||||
|
||||
typedef void (*cccl_host_op_fn_ptr_t)(void*, cccl_increment_t);
|
||||
|
||||
typedef struct cccl_iterator_t
|
||||
{
|
||||
size_t size;
|
||||
size_t alignment;
|
||||
cccl_iterator_kind_t type;
|
||||
cccl_op_t advance;
|
||||
cccl_op_t dereference;
|
||||
cccl_type_info value_type;
|
||||
void* state;
|
||||
cccl_host_op_fn_ptr_t host_advance;
|
||||
} cccl_iterator_t;
|
||||
|
||||
typedef enum cccl_sort_order_t
|
||||
{
|
||||
CCCL_ASCENDING = 0,
|
||||
CCCL_DESCENDING = 1,
|
||||
} cccl_sort_order_t;
|
||||
|
||||
typedef enum cccl_init_kind_t
|
||||
{
|
||||
CCCL_VALUE_INIT = 0,
|
||||
CCCL_FUTURE_VALUE_INIT = 1,
|
||||
CCCL_NO_INIT = 2,
|
||||
} cccl_init_kind_t;
|
||||
|
||||
typedef enum cccl_determinism_t
|
||||
{
|
||||
CCCL_NOT_GUARANTEED = 0,
|
||||
CCCL_RUN_TO_RUN = 1,
|
||||
CCCL_GPU_TO_GPU = 2,
|
||||
} cccl_determinism_t;
|
||||
|
||||
typedef enum cccl_binary_search_mode_t
|
||||
{
|
||||
CCCL_BINARY_SEARCH_LOWER_BOUND = 0,
|
||||
CCCL_BINARY_SEARCH_UPPER_BOUND = 1,
|
||||
} cccl_binary_search_mode_t;
|
||||
|
||||
typedef enum cccl_payload_kind_t
|
||||
{
|
||||
CCCL_PAYLOAD_LTOIR = 0,
|
||||
CCCL_PAYLOAD_CUBIN = 1,
|
||||
} cccl_payload_kind_t;
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
129
cccl_upstream/c/parallel/include/cccl/c/unique_by_key.h
Normal file
129
cccl_upstream/c/parallel/include/cccl/c/unique_by_key.h
Normal file
@@ -0,0 +1,129 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 <stdint.h>
|
||||
|
||||
#include <cccl/c/extern_c.h>
|
||||
#include <cccl/c/types.h>
|
||||
|
||||
CCCL_C_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct cccl_device_unique_by_key_build_result_t
|
||||
{
|
||||
int cc;
|
||||
void* payload;
|
||||
size_t payload_size;
|
||||
cccl_payload_kind_t payload_kind;
|
||||
CUlibrary library;
|
||||
CUkernel compact_init_kernel;
|
||||
CUkernel sweep_kernel;
|
||||
size_t description_bytes_per_tile;
|
||||
size_t payload_bytes_per_tile;
|
||||
void* runtime_policy;
|
||||
size_t runtime_policy_size;
|
||||
char* compact_init_kernel_lowered_name;
|
||||
char* sweep_kernel_lowered_name;
|
||||
} cccl_device_unique_by_key_build_result_t;
|
||||
|
||||
CCCL_C_API CUresult cccl_device_unique_by_key_build(
|
||||
cccl_device_unique_by_key_build_result_t* build,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t d_keys_out,
|
||||
cccl_iterator_t d_values_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t op,
|
||||
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_unique_by_key_build_ex(
|
||||
cccl_device_unique_by_key_build_result_t* build,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t d_keys_out,
|
||||
cccl_iterator_t d_values_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t op,
|
||||
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_unique_by_key_compile(
|
||||
cccl_device_unique_by_key_build_result_t* build,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t d_keys_out,
|
||||
cccl_iterator_t d_values_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t op,
|
||||
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_unique_by_key_load(cccl_device_unique_by_key_build_result_t* build);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_unique_by_key(
|
||||
cccl_device_unique_by_key_build_result_t build,
|
||||
void* d_temp_storage,
|
||||
size_t* temp_storage_bytes,
|
||||
cccl_iterator_t d_keys_in,
|
||||
cccl_iterator_t d_values_in,
|
||||
cccl_iterator_t d_keys_out,
|
||||
cccl_iterator_t d_values_out,
|
||||
cccl_iterator_t d_num_selected_out,
|
||||
cccl_op_t op,
|
||||
uint64_t num_items,
|
||||
CUstream stream);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_unique_by_key_link_ltoir(
|
||||
cccl_device_unique_by_key_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_unique_by_key_serialize(
|
||||
const cccl_device_unique_by_key_build_result_t* build, void** out_buf, size_t* out_size);
|
||||
|
||||
// Reconstructs a build_result from a buffer produced by cccl_device_unique_by_key_serialize.
|
||||
// On success build is populated as if by compile(); CUlibrary/CUkernel handles
|
||||
// remain null until cccl_device_unique_by_key_load is called. On failure build is
|
||||
// left unchanged and a non-success CUresult is returned.
|
||||
CCCL_C_API CUresult
|
||||
cccl_device_unique_by_key_deserialize(cccl_device_unique_by_key_build_result_t* build, const void* buf, size_t size);
|
||||
|
||||
CCCL_C_API CUresult cccl_device_unique_by_key_cleanup(cccl_device_unique_by_key_build_result_t* bld_ptr);
|
||||
|
||||
CCCL_C_EXTERN_C_END
|
||||
// NOLINTEND(modernize-use-using)
|
||||
Reference in New Issue
Block a user