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
39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
// Wrap thrust and cub in different enclosing namespaces
|
|
// (In practice, you probably want these to be the same, in which case just
|
|
// set THRUST_CUB_WRAPPED_NAMESPACE to set both).
|
|
#define THRUST_WRAPPED_NAMESPACE wrap_thrust
|
|
#define CUB_WRAPPED_NAMESPACE wrap_cub
|
|
#define CCCL_IGNORE_DEPRECATED_API
|
|
|
|
#include <thrust/device_vector.h>
|
|
#include <thrust/host_vector.h>
|
|
#include <thrust/transform.h>
|
|
|
|
#include <cuda/iterator>
|
|
|
|
#include <unittest/unittest.h>
|
|
|
|
// Test that we can use a few common utilities and algorithms from a wrapped
|
|
// namespace at runtime. More extensive testing is performed by the header
|
|
// tests and the check_namespace.cmake test.
|
|
void TestWrappedNamespace()
|
|
{
|
|
const std::size_t n = 2048;
|
|
|
|
const auto in_1_begin = ::cuda::make_constant_iterator<int>(12);
|
|
const auto in_2_begin = ::cuda::make_counting_iterator<int>(1024);
|
|
|
|
// Check that the qualifier resolves properly:
|
|
THRUST_NS_QUALIFIER::device_vector<int> d_out(n);
|
|
|
|
::wrap_thrust::thrust::transform(in_1_begin, in_1_begin + n, in_2_begin, d_out.begin(), ::cuda::std::plus<>{});
|
|
|
|
::wrap_thrust::thrust::host_vector<int> h_out(d_out);
|
|
|
|
for (std::size_t i = 0; i < n; ++i)
|
|
{
|
|
ASSERT_EQUAL(h_out[i], static_cast<int>(i) + 1024 + 12);
|
|
}
|
|
}
|
|
DECLARE_UNITTEST(TestWrappedNamespace);
|