[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:
@@ -0,0 +1,57 @@
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include <cub/device/device_scan.cuh>
|
||||
|
||||
#include <cuda/__execution/determinism.h>
|
||||
#include <cuda/__execution/require.h>
|
||||
#include <cuda/std/__functional/invoke.h>
|
||||
|
||||
#include <nvbench_helper.cuh>
|
||||
|
||||
template <typename T, typename OffsetT>
|
||||
static void exclusive_scan(nvbench::state& state, nvbench::type_list<T, OffsetT>)
|
||||
try
|
||||
{
|
||||
using init_value_t = T;
|
||||
using offset_t = OffsetT;
|
||||
using scan_op_t = ::cuda::std::plus<T>;
|
||||
|
||||
const auto elements = static_cast<std::size_t>(state.get_int64("Elements{io}"));
|
||||
|
||||
thrust::device_vector<T> input = generate(elements);
|
||||
thrust::device_vector<T> output(elements, thrust::no_init);
|
||||
|
||||
const T* d_input = thrust::raw_pointer_cast(input.data());
|
||||
T* d_output = thrust::raw_pointer_cast(output.data());
|
||||
|
||||
state.add_element_count(elements);
|
||||
state.add_global_memory_reads<T>(elements, "Size");
|
||||
state.add_global_memory_writes<T>(elements);
|
||||
|
||||
caching_allocator_t alloc;
|
||||
state.exec(nvbench::exec_tag::gpu | nvbench::exec_tag::no_batch, [&](nvbench::launch& launch) {
|
||||
auto env = cub_bench_env(alloc, launch, cuda::execution::require(cuda::execution::determinism::run_to_run));
|
||||
_CCCL_TRY_CUDA_API(
|
||||
cub::DeviceScan::ExclusiveScan,
|
||||
"ExclusiveScan failed",
|
||||
d_input,
|
||||
d_output,
|
||||
scan_op_t{},
|
||||
init_value_t{},
|
||||
static_cast<offset_t>(elements),
|
||||
env);
|
||||
});
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
state.skip("Skipping: out of memory.");
|
||||
}
|
||||
|
||||
using types = nvbench::type_list<float, double>;
|
||||
using offsets = nvbench::type_list<int64_t>;
|
||||
|
||||
NVBENCH_BENCH_TYPES(exclusive_scan, NVBENCH_TYPE_AXES(types, offsets))
|
||||
.set_name("base")
|
||||
.set_type_axes_names({"T{ct}", "OffsetT{ct}"})
|
||||
.add_int64_power_of_two_axis("Elements{io}", nvbench::range(16, 28, 4));
|
||||
Reference in New Issue
Block a user