cuda - 推力:如何从主机阵列创建 device_vector?

标签 cuda thrust

这个问题在这里已经有了答案:





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/

相关文章:

open-source - 用于蛋白质折叠的开源 GPGPU 项目

c++ - 将 OpenMP 与 C++ 结合使用的算法库

c++ - CUDA 推力返回类型

c++ - 从 C++ 访问 device_vector 的最佳方式

cuda - 无法为 thrust::cuda min_element() 函数构建比较谓词

c - 了解 CUDA 内核执行

c++ - CUDA C++类被误认为是模板

c++ - 谁可以从mark的文档中给我这个代码的主程序?

c++ - CUFFT 输出与 FFTW 输出不对齐

cuda - 无法创建推力设备向量