Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thrust: How to create device_vector from host array? [duplicate]

Tags:

cuda

thrust

I get some data from a library on the host as a pointer to an array. How do I create a device_vector that holds this data on the device?

int* data;
int num;
get_data_from_library( &data, &num );

thrust::device_vector< int > iVec; // How to construct this from data?
like image 489
Ashwin Nanjappa Avatar asked Feb 29 '12 08:02

Ashwin Nanjappa


1 Answers

As per this answer, all you need is:

int* data;
int num;
get_data_from_library( &data, &num );

thrust::device_vector< int > iVec(data, data+num);
like image 105
talonmies Avatar answered Sep 23 '22 18:09

talonmies