GPU Programming

Why does pinning (page-locking) CPU memory before transferring it to the GPU speed up the transfer?

  1. AThe OS will not move or evict those pages, so the GPU can DMA directly without an intermediate copy, and asynchronous transfers become possible
  2. BPinning compresses the data
  3. CPinning upgrades the PCI Express generation
Show answer and explanation

Answer: A. The OS will not move or evict those pages, so the GPU can DMA directly without an intermediate copy, and asynchronous transfers become possible

The OS can move ordinary memory to another physical page or evict it to storage at any time, so letting the GPU's DMA access it directly would be unsafe. Normally, therefore, the data is first copied into a temporary pinned buffer before transfer. Using pinned memory from the start removes that extra copy and also allows asynchronous transfers that overlap with CPU work.

  • A. Correct. Overusing it can starve the OS of memory, though.
  • B. Nothing is compressed.
  • C. The generation does not change.
Practice this topic Back to topic

More GPU Programming questions

  1. What is the main purpose of using multiple CUDA streams?
  2. A program that launches a very small kernel thousands of times in a row is slow. What is the most suitable improvement?
  3. Which describes CUDA unified memory?
  4. When a GPU performs element-wise addition of two large arrays (c[i] = a[i] + b[i]), what mainly determines performance?
  5. Why is double-precision (FP64) performance on many consumer gaming GPUs much lower than single-precision (FP32), for example one thirty-second?