Fork me on GitHub

Thrust v1.2.0 release

We are pleased to announce the release of Thrust v1.2, an open-source template library for developing CUDA applications. Modeled after the C++ Standard Template Library (STL), Thrust brings a familiar abstraction layer to the realm of GPU computing.

Version 1.2 adds several new features, including:

As the following code example shows, Thrust programs are concise and readable.

#include <thrust/device_vector.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/reduce.h>
#include <string>

// This example computes a run-length code for an array
// of characters using a key-value (or segmented) reduction

int main(void)
  // input data on the host
  std::string data = "aaabbbbbcddeeeeeeeeeff";

  size_t N = data.size();

  // copy input data to the device
  thrust::device_vector<char> input(data.begin(), data.end());

  // allocate storage for output data and run lengths
  thrust::device_vector<char> output(N);
  thrust::device_vector<int>  lengths(N);

  // compute run lengths
  size_t num_runs =
    thrust::reduce_by_key(input.begin(), input.end(),        // input key sequence
                          thrust::constant_iterator<int>(1), // input value sequence
                          output.begin(),                    // output key sequence
                          lengths.begin()                    // output value sequence
                          ).first - output.begin();          // compute the output size
  // output is now  [a,b,c,d,e,f]
  // lengths is now [3,5,1,2,9,2]
  return 0;

Get started with Thrust today! First download Thrust v1.2 and then follow the online quick-start guide. Refer to the online documentation for a complete list of features. Many concrete examples and a set of introductory slides are also available.

Thrust is open-source software distributed under the OSI-approved Apache License v2.0.