My favorites | Sign in
Logo
                
People details
Project owners:
  wnbell, jaredhoberock

What is Thrust?

Thrust is a CUDA library of parallel algorithms with an interface resembling the C++ Standard Template Library (STL). Thrust provides a flexible high-level interface for GPU programming that greatly enhances developer productivity. Develop high-performance applications rapidly with Thrust!



News

Examples

Thrust is best explained through examples. The following source code generates random numbers on the host and transfers them to the device where they are sorted.

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <cstdlib>

int main(void)
{
    // generate 16M random numbers on the host
    thrust::host_vector<int> h_vec(1 << 24);
    thrust::generate(h_vec.begin(), h_vec.end(), rand);

    // transfer data to the device
    thrust::device_vector<int> d_vec = h_vec;

    // sort data on the device (145M keys per second on a GTX 280)
    thrust::sort(d_vec.begin(), d_vec.end());

    // transfer data back to host
    thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());

    return 0;
}

This code sample computes the sum of 100 random numbers on the GPU.

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <cstdlib>

int main(void)
{
  // generate random data on the host
  thrust::host_vector<int> h_vec(100);
  thrust::generate(h_vec.begin(), h_vec.end(), rand);

  // transfer to device and compute sum
  thrust::device_vector<int> d_vec = h_vec;
  int x = thrust::reduce(d_vec.begin(), d_vec.end(), thrust::plus<int>());
  return 0;
}

Refer to the Tutorial page for further information and examples.

Contributors

The primary developers of Thrust are:

We wish to thank the following people, who have made important intellectual and/or software contributions to the project:
  • Mark Harris
  • Michael Garland
  • Nadathur Satish
  • Shubho Sengupta
We also thank the compiler group at NVIDIA for their continued improvements to nvcc. In particular, we appreciate the work Bastiaan Aarts has done to enhance nvcc's C++ support.









Hosted by Google Code