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
46 lines
1.0 KiB
Plaintext
46 lines
1.0 KiB
Plaintext
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of CUDASTF 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/**
|
|
* @file
|
|
*
|
|
* @brief Test reduce access mode
|
|
*
|
|
*/
|
|
|
|
#include <cuda/experimental/stf.cuh>
|
|
|
|
using namespace cuda::experimental::stf;
|
|
|
|
template <typename context_t>
|
|
void run()
|
|
{
|
|
context_t ctx;
|
|
auto lsum = ctx.logical_data(shape_of<scalar_view<size_t>>());
|
|
|
|
size_t N = 100000;
|
|
|
|
ctx.parallel_for(box(N), lsum.reduce(reducer::sum<size_t>{}))->*[] __device__(size_t i, auto& sum) {
|
|
sum++;
|
|
};
|
|
|
|
size_t res_sum = ctx.wait(lsum);
|
|
|
|
ctx.finalize();
|
|
|
|
_CCCL_ASSERT(res_sum == N, "Invalid result");
|
|
}
|
|
|
|
int main()
|
|
{
|
|
run<stream_ctx>();
|
|
run<graph_ctx>();
|
|
}
|