You are here

Thrust

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  

   

 

Key Features
Thrust provides STL-like templated interfaces to several algorithms and data structures designed for high performance heterogeneous parallel computing:

Thrust also supports an OpenMP back-end that developers can select at compile-time, so you can 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

Examples
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.

Performance

Availability 
In addition to the Thrust open source project hosted on Google Code, a production-tested version of Thrust is now included in the CUDA Toolkit 

Additional Resources