-1

テストベクターで並列合計スキャンを実行しようとしています。この目的のために、Thrust と CUB ライブラリの両方を使用しています

struct CustomSum
{
    template <typename T>
    CUB_RUNTIME_FUNCTION __forceinline__
        T operator()(const T &a, const T &b) const {
            return a + b;
        }
};
    // 2d array stored in row-major order [(0,0), (0,1), (0,2), ... ]
    thrust::host_vector<int> hVec_I1(SIZE_IMG, 1);
    thrust::host_vector<int> hVec_I2(SIZE_IMG, 1);
    thrust::host_vector<int> h_out(SIZE_IMG, 1);

    CustomSum sum_op;
    // Innitialize vector with synthetic image:
    initialize(N, N, hVec_I1, hVec_I2);

    // Compute Integral Image M1 and M2
    thrust::device_vector<int> dVec_M1 = hVec_I1;
    thrust::device_vector<int> dVec_M2 = hVec_I2;
    thrust::device_vector<int> d_o = h_out;

    //thrust::device_ptr<double> d_in = dVec_M1.data();
    //thrust::device_ptr<double> d_out1 = d_out.data();
    int* d_in = thrust::raw_pointer_cast(&dVec_M1[0]);
    int *d_out = thrust::raw_pointer_cast(&d_o[0]);
    //d_in = thrust::raw_pointer_cast(dVec_M2.data());

    //thrust::device_vector<int> d_out;
    //int *d_out = thrust::raw_pointer_cast(dVec_M1.data());
    void *d_temp_storage = NULL;
    size_t temp_storage_bytes = 0;

    // Run inclusive prefix sum-scan
    cub::DeviceScan::InclusiveScan(d_temp_storage, temp_storage_bytes, d_in, d_out, sum_op, SIZE_IMG);
    // Allocate temporary storage for inclusive prefix scan
    cudaMalloc(&d_temp_storage, temp_storage_bytes);
    // Run inclusive prefix sum-scan
    cub::DeviceScan::InclusiveScan(d_temp_storage, temp_storage_bytes, d_in, d_out, sum_op, SIZE_IMG);

私が得ているエラーは

Error   43  error : calling a __host__ function("CustomSum::operator ()<int> ") from a __device__ function("cub::TilePrefixCallbackOp<int, CustomSum, cub::ScanTileState<int, (bool)1> > ::operator ()") is not allowed c:\users\asu_cuda_laptop\documents\visual studio 2013\projects\stats_kernel\cub\agent\single_pass_scan_operators.cuh    747 1   stats_kernel

エラーを正しく解釈できませんでした。生のポインターの処理方法に問題があると確信しています。どんな助けでも大歓迎です。

関連リンク: 1 つの CUDA コードで CUB と Thrust を使用する方法

4

1 に答える 1