Thrust for CUDA
Monday, 11 October 2010

If you are interested in using the GPU for general purpose computation, i.e. GGPU, then Thrust is a library that can save you a huge amount of effort.

Banner

 

Thrust  is an open-source template library for CUDA applications and the latest version 1.3 has just been  released.

thrust

Modeled after the C++ Standard Template Library (STL), Thrust brings a familiar abstraction layer to GPU computing.

Version 1.3 adds several new features, including:

  • a state-of-the-art sorting implementation,
  • performance improvements to stream compaction and reduction
  • robust error reporting and failure detection
  • support for CUDA 3.2 and gf104-based GPUs
  • search algorithm

To give you some idea of how easy Thrust is to use consider the following short program that generates random numbers and then sorts them using the GPU: (Note: "host" means CPU and "device" means GPU)

int main(void)
{
// generate 32M 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
// (846M keys per second on
//               GeForce GTX 480)
 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;
}

Notice the way that Thrust methods can be used on both the host and the device and how the whole messy business of parallelising algorithms is hidden from the programmer.

To get started first download Thrust v1.3 and then follow the online quick-start guide. Refer to the online documentation for a complete list of features. Many examples and a set of introductory slides are also available.

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

Other relevant articles:

GPU Gems Volume 1

Graphics Accelerators

Bitmap Effects

GPGPU optimisation

Banner


Pico 2W Announced But There Is A Surprise!
25/11/2024

Raspberry Pi released the Pico 2 a few months ago and we have been waiting for the Pico 2W since then. But Pimoroni beat them to the draw with the Pico Plus 2W based on the RM2 radio module and hinted [ ... ]



Eclipse IoT Developer Survey 2024
04/12/2024

The Eclipse Foundation’s IoT Working Group has released the results of its 2024 IoT Developer Survey. Industrial automation and automotive are now the leading industry sectors and connectivity is th [ ... ]


More News

<ASIN:0321228324>

<ASIN:0321335597>

<ASIN:0321515269>

Last Updated ( Monday, 11 October 2010 )