/ Published in: C++

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#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; }
Comments
