Cuda 如何复制推力::主机向量<;char>;一个字符*

Cuda 如何复制推力::主机向量<;char>;一个字符*,cuda,nvidia,thrust,Cuda,Nvidia,Thrust,我正在试着用我的手来推动CUDA。 但是我工作的环境需要我将最后的数据复制到char*中,而不是asch::host\u vector 我现在的代码如下所示 thrust::device_vector<unsigned int> sortindexDev(filesize); thrust::host_vector<char>BWThost(filesize); thrust::device_vector<char>BWTdev(filesize); thru

我正在试着用我的手来推动CUDA。 但是我工作的环境需要我将最后的数据复制到
char*
中,而不是
asch::host\u vector
我现在的代码如下所示

thrust::device_vector<unsigned int> sortindexDev(filesize);
thrust::host_vector<char>BWThost(filesize);
thrust::device_vector<char>BWTdev(filesize);
thrust::device_vector<char>inputDataDev(filesize);
  .
  .
  some code using thrust:: sort, thrust::transform, etc
  .
  .
  .
  .
BWThost = BWTdev;
只需使用,例如:

thrust::device_vector<char>BWTdev(filesize);
char *chardata = malloc(filesize);

thrust::copy(BWTdev.begin(), BWTdev.end(), &chardata[0]);
推力::设备向量bwtdev(文件大小);
char*chardata=malloc(文件大小);
推力::复制(BWTdev.begin()、BWTdev.end()、和chardata[0]);
[免责声明:使用浏览器编写,未经编译或测试,使用风险自负]

这是直接从
设备_向量
复制到主机阵列,无需任何中间
主机_向量
或显式主机端循环

thrust::device_vector<char>BWTdev(filesize);
char *chardata = malloc(filesize);

thrust::copy(BWTdev.begin(), BWTdev.end(), &chardata[0]);