Question

depuis que je devais trier de grands tableaux de nombres avec CUDA, je suis venu avec l'utilisation poussée. Jusqu'à présent, si bien ... mais que quand je veux appeler un noyau « écrit à la main », ayant une poussée :: host_vector contenant les données?

Mon approche était (backcopy manque):

int CUDA_CountAndAdd_Kernel(thrust::host_vector<float> *samples, thrust::host_vector<int> *counts, int n) {

 thrust::device_ptr<float> dSamples = thrust::device_malloc<float>(n);
 thrust::copy(samples->begin(), samples->end(), dSamples);

 thrust::device_ptr<int> dCounts = thrust::device_malloc<int>(n);
 thrust::copy(counts->begin(), counts->end(), dCounts);

 float *dSamples_raw = thrust::raw_pointer_cast(dSamples);
 int *dCounts_raw = thrust::raw_pointer_cast(dCounts);

 CUDA_CountAndAdd_Kernel<<<1, n>>>(dSamples_raw, dCounts_raw);

 thrust::device_free(dCounts);
 thrust::device_free(dSamples);
}

Le noyau ressemble à:

__global__ void CUDA_CountAndAdd_Kernel_Device(float *samples, int *counts) 

Mais la compilation échoue avec:

  

erreur: argument de type "float **" est   incompatible avec le paramètre de type   "Poussée :: host_vector> *"

Huh ?! Je pensais que je donne flotteur et pointeurs premières int? Ou suis-je manque quelque chose?

Était-ce utile?

La solution

Vous appelez le noyau avec le nom de la fonction de l'appel est, pas le nom du noyau -. Par conséquent, la non-concordance des paramètres

Changement:

CUDA_CountAndAdd_Kernel<<<1, n>>>(dSamples_raw, dCounts_raw);

à

CUDA_CountAndAdd_Kernel_Device<<<1, n>>>(dSamples_raw, dCounts_raw);

et voir ce qui se passe.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top