Return to Snippet

Revision: 36251
at November 19, 2010 23:43 by initiationone


Initial Code
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <cstdlib.h>
int main(void)
{
   // generate 32M random numbers on the host
   thrust::host_vector<int> h_vec(32 << 20);
   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 sec on GeForceGTX 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;
}

Initial URL


Initial Description


Initial Title
thrust usage example

Initial Tags


Initial Language
C++