关于CUDA里面的global、host、device

在CUDA的GPU编程里面,函数分为三类,前缀分别为__global__、__host__、__device__。

(1)__host__

如果没有标明前缀,那么函数默认为__host__,可以理解为CPU函数,这些函数不能被global和device函数所调用。

(2)__global__

前缀注明__global__,则这个函数可以被GPU调用,并且这个函数可以调用__device__前缀的函数。

(3)__device__

__device__表明这个函数是在GPU里面运行的。

Leave a Reply

Your email address will not be published. Required fields are marked *