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
- Host-to-Device Transfers
- Device-to-Host Transfers
- The Copy Direction Enum
- The PCIe Transfer Bottleneck