【问题标题】:CUDA thrust thrust::system::system_error in exclusive_scanExclusive_scan 中的 CUDA 推力推力::system::system_error
【发布时间】:2014-07-01 22:07:24
【问题描述】:

以下代码来自Converting thrust::iterators to and from raw pointers的回答

编译正常,但是在CUDA 6.0下运行时,exclusive_scan后报thrust::system::system_error(trace stack中满是exclusive_scan相关信息)

#include <cuda_runtime.h>
#include <thrust/device_ptr.h>
#include <thrust/device_vector.h>
#include <thrust/scan.h>
#include <thrust/fill.h>
#include <thrust/copy.h>
#include <cstdio>
#pragma comment(lib,"cudart.lib")

int main()                                                        
{                                                                 
    const int N = 16;
    int * a;
    cudaMalloc((void**)&a, N*sizeof(int));   
    thrust::device_ptr<int> d = thrust::device_pointer_cast(a);  
    thrust::fill(d, d+N, 2);
    thrust::device_vector<int> v(N);                    
    thrust::exclusive_scan(d, d+N, v.begin());

    int v_[N];
    thrust::copy(v.begin(), v.end(), v_);
    for(int i=0; i<N; i++)
        printf("%d %d\n", i, v_[i]);     

    return 0;                                                  
}

该代码有什么问题?(该代码是 2 年前发布的,回答它的人说它运行正常。我认为他使用的是 CUDA 4.0 或更低版本。但代码在 CUDA 5.0 之后无法运行)我' m 使用 VS 2012 和 CUDA 6.0 (compute_13,sm_13)

【问题讨论】:

    标签: cuda thrust


    【解决方案1】:

    您正在编译添加-G 开关的调试项目。这可以是problematic with Thrust。切换到发布项目,这将删除-G 开关。

    我尝试了以下组合:

    -G -arch=sm_20
    -arch=sm_20
    -arch=sm_13
    

    以及所有运行正常的生成代码。

    当我这样做时:

     -G -arch=sm_13
    

    我能够重现您看到的错误。 (CUDA 6 上的所有测试)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-14
      • 1970-01-01
      • 2016-07-11
      • 2013-01-04
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多