神奇的thrust::device_vector与nvcc编译选项

在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编译就可以了……

具体原因有时间再分析

你可能感兴趣的:(vector)