使用thrust,在运行时总是出错
ctech 2014-02-06 05:08:17 编译正常,运行时总是出现这个错误:Unhandled exception at 0x7735c41f in ThrustAPI.exe: Microsoft C++ exception: thrust::system::system_error at memory location 0x002af4d8.. ,怎么解决呢?谢谢!
#include <iostream>
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 = 5;
thrust::device_vector<int> a(N);
thrust::sequence(a.begin(), a.end(), 0);
int sumA = thrust::reduce(a.begin(), a.end(), 0);
int sumCheck = 0;
for(int i = 0; i < N; i++) sumCheck += i;
if(sumA == sumCheck)
{
cout << "Test Succeeded!" << endl;
}
else
{
cerr << "Test FAILED!" << endl;
return 1;
}
return 0;
}