0Pricing
CUDA Academy · Lesson

One Pointer, Both Sides

How cudaMallocManaged works.

The Two-Pointer Headache

So far you juggled two pointers: one for the host, one for the device. Unified Memory replaces that pain with a single pointer both sides can use. 🙂

Meet cudaMallocManaged

You allocate managed memory with cudaMallocManaged. It hands back one address that works in your CPU code and inside your kernels alike.

float *data;
cudaMallocManaged(&data, n * sizeof(float));

All lessons in this course

  1. One Pointer, Both Sides
  2. On-Demand Page Migration
  3. Prefetching with cudaMemPrefetchAsync
  4. Hints via cudaMemAdvise
← Back to CUDA Academy