나는 추력 라이브러리를 사용하여 CUDA에서 장치 배열의 접두어 합계를 계산하려고합니다. 내 배열은 cudaMalloc()
으로 할당됩니다. 내 요구 사항은 다음과 같습니다원시 포인터와 thrust :: iterators 변환
main()
{
Launch kernel 1 on data allocated through cudaMalloc()
// This kernel will poplulate some data d.
Use thrust to calculate prefix sum of d.
Launch kernel 2 on prefix sum.
}
내가 장치 반복자에 대한 포인터를 변환하는 방법이 필요하므로 내 커널 사이 어딘가에 추력을 사용하려는 돌아 왔을때 코드는 다음의 잘못?
int main()
{
int *a;
cudaMalloc((void**)&a,N*sizeof(int));
thrust::device_ptr<int> d=thrust::device_pointer_cast(a);
thrust::device_vector<int> v(N);
thrust::exclusive_scan(a,a+N,v);
return 0;
}
이 편집은 새로운 질문을하기위한 것입니까? – talonmies