[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:
33
cccl_upstream/thrust/examples/fill_copy_sequence.cu
Normal file
33
cccl_upstream/thrust/examples/fill_copy_sequence.cu
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <thrust/copy.h>
|
||||
#include <thrust/device_vector.h>
|
||||
#include <thrust/fill.h>
|
||||
#include <thrust/host_vector.h>
|
||||
#include <thrust/sequence.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
// initialize all ten integers of a device_vector to 1
|
||||
thrust::device_vector<int> D(10, 1);
|
||||
|
||||
// set the first seven elements of a vector to 9
|
||||
thrust::fill(D.begin(), D.begin() + 7, 9);
|
||||
|
||||
// initialize a host_vector with the first five elements of D
|
||||
thrust::host_vector<int> H(D.begin(), D.begin() + 5);
|
||||
|
||||
// set the elements of H to 0, 1, 2, 3, ...
|
||||
thrust::sequence(H.begin(), H.end());
|
||||
|
||||
// copy all of H back to the beginning of D
|
||||
thrust::copy(H.begin(), H.end(), D.begin());
|
||||
|
||||
// print D
|
||||
for (size_t i = 0; i < D.size(); i++)
|
||||
{
|
||||
std::cout << "D[" << i << "] = " << D[i] << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user