0Pricing
CUDA Academy · Lesson

The Copy Direction Enum

cudaMemcpyKind and getting it right.

The Fourth Argument

Every cudaMemcpy ends with a direction flag of type cudaMemcpyKind. It tells the runtime which way the bytes travel. 🧭

cudaMemcpy(dst, src, bytes, kind);

Host to Device

Use cudaMemcpyHostToDevice to upload inputs from CPU RAM into GPU memory before a kernel runs.

cudaMemcpy(d_a, h_a, bytes, cudaMemcpyHostToDevice);

All lessons in this course

  1. Host-to-Device Transfers
  2. Device-to-Host Transfers
  3. The Copy Direction Enum
  4. The PCIe Transfer Bottleneck
← Back to CUDA Academy