質問

私はCUDAと数字の大きな配列をソートするために必要なので、

、私は推力を使用してと一緒に来。これまでのところ、良いので...しかし、私は、データを含む推力:: host_vectorを持つ、「手書き」カーネルを呼び出すために何をしたい?

私のアプローチは、(backcopyが欠落している)でした

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);
}

カーネル次のようになります。

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

しかし、コンパイルはして失敗します:

  

エラー:引数の型の「フロート**」であります   型のパラメータと互換性がありません   "推力:: host_vector> *"

えっ!私は私がfloatとint型生のポインタを与えていたと思いましたか?または私は何かが足りないのですか?

役に立ちましたか?

解決

あなたは、コールが入っている関数の名前でカーネルを呼び出しているではないカーネルの名前 - 。したがって、パラメータの不一致

変更:

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

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

と何が起こるか見ています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top