__device__ and __host__ Functions
Where each kind of function may run.
Beyond the Kernel
Kernels are entry points, but most code lives in helpers. CUDA gives two more qualifiers to say where a plain function may run. Let us meet them.
The __device__ Qualifier
A __device__ function runs on the GPU and is callable only from other GPU code, like a kernel or another device function.
__device__ int square(int x) {
return x * x;
}All lessons in this course
- The __global__ Function Qualifier
- __device__ and __host__ Functions
- Separate Address Spaces
- The Life of a CUDA Program