在C++的GPU库thrust中,有两种vector

thrust::device_vector<int> D; //GPU使用的内存中的向量
thrust::host_vector<int> H;  //CPU使用的内存中的向量

按照官网上给出的例子(https://code.google.com/p/thrust/wiki/QuickStartGuide),这两都可以通过构造函数初始化:

比如:

thrust::host_vector<int> H(10,1); //长度为10,每个元素都是1

但是device_vector这么做用nvcc编译都不能通过……

不过如果把代码文件名以.cu结尾命名,再用nvcc编译就可以了……

具体原因有时间再分析

相关文章:

  • 2021-08-20
  • 2021-05-10
  • 2021-07-28
  • 2021-12-12
  • 2022-01-13
  • 2022-12-23
  • 2022-02-12
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案