// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include #include #include template static void exclusive_scan(nvbench::state& state, nvbench::type_list) try { using init_value_t = T; using offset_t = OffsetT; using scan_op_t = ::cuda::std::plus; const auto elements = static_cast(state.get_int64("Elements{io}")); thrust::device_vector input = generate(elements); thrust::device_vector 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(elements, "Size"); state.add_global_memory_writes(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(elements), env); }); } catch (const std::bad_alloc&) { state.skip("Skipping: out of memory."); } using types = nvbench::type_list; using offsets = nvbench::type_list; 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));