Thrust is a powerful library of parallel algorithms and data structures. Thrust provides a flexible, high-level interface for GPU programming that greatly enhances developer productivity. Using Thrust, C++ developers can write just a few lines of code to perform GPU-accelerated sort, scan, transform, and reduction operations orders of magnitude faster than the latest multi-core CPUs. For example, the thrust::sort algorithm delivers 5x to 100x faster sorting performance than STL and TBB.
"Having access to GPU computing through the standard template interface greatly increases productivity for a wide range of tasks, from simple cashflow generation to complex computations with Libor market models, variable annuities or CVA adjustments. The Thrust C++ library has lowered the barrier of entry significantly by taking care of low-level functionality like memory access and allocation, allowing the financial engineer to focus on algorithm development in a GPU-enhanced environment."
-- Peter Decrem, Director of Rates Products, Quantifi
Thrust provides STL-like templated interfaces to several algorithms and data structures designed for high performance heterogeneous parallel computing:
Thrust also supports OpenMP and TBB back ends enabling developers to use Thrust to build applications that deliver great performance on GPUs *and* multi-core CPUs. Find out more details of Thrust features in the Thrust Quick Start Guide.
The easiest way to learn Thrust is by looking at a few examples.
The example below generates random numbers on the host and transfers them to the device where they are sorted.
This second code sample computes the sum of 100 random numbers on the GPU.