0PricingLogin
CUDA Academy · Lesson

__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

  1. The __global__ Function Qualifier
  2. __device__ and __host__ Functions
  3. Separate Address Spaces
  4. The Life of a CUDA Program
← Back to CUDA Academy