문제

I am new to CUDA programming so I am curious as to how to do the following:

According to the question here: Using std::vector in cuda device code

we cannot use std::vector. I am trying to pass an argument like std::vector to a kernel. The void * describes memory pointers on the GPU/ device (cuda terminology).

What is the best way to do so? Maybe void ** ? will that work?

도움이 되었습니까?

해결책

That post seems clear but I'll repeat it in other words: you can't pass a std::vector to a CUDA kernel, the reason is the following:

  • CUDA kernels need to use device code, i.e. code that runs on your gpu or code that can be translated as such. In order to generate that code, almost everything you write needs to pass through a compilation chain which eventually generates intermediate code or executable code for your gpu.

  • By using STL constructs and algorithms you're using code that hasn't been written for the GPU and for which there's NO device equivalent code or emulation is slow/not even always possible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top