J'essaie de faire un scan de somme parallèle sur un vecteur de test. J'utilise à la fois Thrust et bibliothèque CUB à cet effetUtilisation de CUB et de Thrust pour l'analyse de somme parallèle
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);
L'erreur que je reçois est
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
je ne pouvais pas interpréter correctement l'erreur et je suis sûr qu'il ya un problème avec la façon dont je Je manipule des pointeurs bruts. Toute aide est appréciée.
Lien connexe: How to use CUB and Thrust in one CUDA code
Pouvez-vous modifier votre question pour inclure la commande de compilation que vous utilisez pour ce code? – talonmies