-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
The C++ Programmer's Mindset
By :
Thrust is NVIDIA’s C++ library for parallel and device-aware containers and algorithms. It (mostly) replicates the standard library interface but allows for the data to be stored on a device (GPU) and for algorithms to be implemented by kernels. Thrust is distributed as part of the CUDA toolkit, so it is generally very easy to use as part of CUDA projects. (AMD ROCm also provides a similar library.)
The backbone containers provided by Thrust are the various vector classes. A Thrust host_vector operates very much like std::vector, with data stored in linear memory that grows geometrically when it runs out of space. On the other hand, a device_vector is entirely contained in GPU memory, with data allocated by cudaMalloc (or equivalent). A third universal_vector is a vector based on unified memory spaces, whereby the transfer of data from host memory to device memory is handled transparently at runtime based on where the data is...