//seqCuda.cu
#include
using namespace std;
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
int main()
{
const int N=50000;
// task 1: create the array
thrust::device_vector a(N);
// task 2: fill the array
thrust::sequence(a.begin(), a.end(), 0);
// task 3: calculate the sum of the array
int sumA= thrust::reduce(a.begin(),a.end(), 0);
// task 4: calculate the sum of 0 … N-1
int sumCheck=0;
for(int i=0; i < N; i++) sumCheck += i;
// task 5: check the results agree
if(sumA == sumCheck) cout << “Test Succeeded!” << endl;
else { cerr << “Test FAILED!” << endl; return(1);}
return(0);
}
程序就是上面这段,书上面的。我是VS2010+cuda5.5,在debug模式下运行到 thrust::device_vector a(N);,总是出错
[attach]3394[/attach]
我试过把 thrust::device_vector a(N),改成C++的语言,没问题,求解!谢谢了!难道是 thrust::device_vector 这句使用有什么限制?还是我环境配置有问题,大神求解!