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
27 lines
594 B
Plaintext
27 lines
594 B
Plaintext
#define CCCL_IGNORE_DEPRECATED_API
|
|
|
|
#include <thrust/copy.h>
|
|
#include <thrust/device_vector.h>
|
|
#include <thrust/functional.h>
|
|
#include <thrust/transform.h>
|
|
|
|
#include <cuda/iterator>
|
|
|
|
#include <iostream>
|
|
#include <iterator>
|
|
|
|
int main()
|
|
{
|
|
thrust::device_vector<int> data{3, 7, 2, 5};
|
|
|
|
// add 10 to all values in data
|
|
thrust::transform(data.begin(), data.end(), cuda::constant_iterator<int>(10), data.begin(), cuda::std::plus<int>());
|
|
|
|
// data is now [13, 17, 12, 15]
|
|
|
|
// print result
|
|
thrust::copy(data.begin(), data.end(), std::ostream_iterator<int>(std::cout, "\n"));
|
|
|
|
return 0;
|
|
}
|