Files
project_6/cccl_upstream/examples/thrust_flexible_device_system
EngineX CI 56fd68e7dd [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
2026-07-30 09:35:51 +00:00
..

Thrust Flexible Device System Example

This example illustrates best practices for writing generic CMake that supports user-configuration of the Thrust device system via the CCCL_THRUST_DEVICE_SYSTEM CMake option.

Valid values for this option are:

  • CUDA
  • OMP (OpenMP)
  • TBB (Intel Thread Building Blocks)
  • CPP (Serial C++ backend)

The CMakeLists.txt file for this example is annotated to show how to achieve a generic build system that supports any of device system.

How To Use This Example

Configure and build this example as follows:

# Checkout example and prepare build directory:
git clone https://github.com/NVIDIA/cccl.git
cd cccl/thrust_flexible_device_system
mkdir build
cd build

# Configure:
cmake .. -DCCCL_THRUST_DEVICE_SYSTEM=CUDA # or TBB, OMP, CPP

# Build:
cmake --build .

# Run:
ctest -V

Advanced Thrust Usecases

For more control over the Thrust configuration, see the Thrust CMake package's README.md. This details how to use the thrust_create_target function to generate Thrust interface targets in CMake.

If using thrust_create_target directly, you may also want to set the CMake option CCCL_ENABLE_DEFAULT_THRUST_TARGET=OFF to prevent the default CCCL::Thrust target from being initialized. This will avoid checking for any dependencies required for the default target that may be unnecessary for your project.

Further Reading About CCCL + CMake

The basic example's README.md has additional information that you may find useful for using CCCL with CPM and CMake.