这个问题在这里已经有了答案:
is there a better and a faster way to copy from CPU memory to GPU using thrust?
(1 个回答)
8 个月前关闭。
我从主机上的库中获取一些数据作为指向数组的指针。如何创建在设备上保存此数据的 device_vector?
int* data;
int num;
get_data_from_library( &data, &num );
thrust::device_vector< int > iVec; // How to construct this from data?
最佳答案
根据 this answer , 所有你需要的是:
int* data;
int num;
get_data_from_library( &data, &num );
thrust::device_vector< int > iVec(data, data+num);
关于cuda - 推力:如何从主机阵列创建 device_vector?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9495599/