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:


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.


Review the latest CUDA 6.5 performance report to learn how much you could accelerate your code.


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

Additional Resources