我正在尝试运行http://docs.thrust.googlecode.com/hg/group__modifying.html中描述的每个示例,但在编译和运行时遇到错误.
我使用以下文件:fe.cu:
#include <thrust/for_each.h>
#include <thrust/device_vector.h>
#include <stdio.h>
struct printf_functor{
__host__ __device__
void operator()(int x){
printf("%d\n");
}
};
int main(){
thrust::device_vector<int> d_vec(3);
d_vec[0] = 0; d_vec[1] = 1; d_vec[2] = 2;
thrust::for_each(d_vec.begin(), d_vec.end(), printf_functor());
}
Run Code Online (Sandbox Code Playgroud)
我编译nvcc -arch=sm_20 fe.cu.
当我使用./a.out运行时,我得到以下输出:
terminate called after throwing an instance of 'thrust::system::system_error'
what(): unspecified launch failure
Aborted
Run Code Online (Sandbox Code Playgroud)
以下是用于运行代码的GPU上的一些信息:
--- General Information for device 0 ---
Name: Tesla C2075
Compute capability: 2.0
Clock rate: 1147000
Device copy overlap: Enabled
Kernel execution timeout …Run Code Online (Sandbox Code Playgroud)