0Pricing
CUDA Academy · Leçon

Pourquoi la mémoire paginable est lente

Tamponnez les données derrière un malloc ordinaire.

Pourquoi la mémoire paginable est lente est une leçon CUDA Academy gratuite sur CoddyKit. Ceci est la leçon 1 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage CUDA Academy, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours CUDA Academy comprend 4 leçons au total.

Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.

Where Your Data Lives

Normal C++ buffers from malloc sit in pageable host memory. It feels free, but the GPU cannot copy from it directly, and that small detail costs you speed.

What Pageable Means

Memory is pageable when the operating system may move its pages around or swap them to disk at any moment. Great for flexibility, tricky for hardware that needs fixed addresses.

The GPU Speaks DMA

The GPU pulls data using DMA, a direct hardware transfer that needs a physical address that will not move. Pageable pages break that promise, so they cannot be used directly.

The Hidden Staging Step

To work around this, the driver copies your pageable buffer into a hidden staging buffer first, then sends that to the GPU. You pay for an extra copy you never wrote. 😮

Two Copies, Not One

So a single cudaMemcpy from pageable memory is really two copies: host to staging, then staging to device. That doubled work is exactly why pageable transfers feel sluggish.

An Ordinary malloc

Here is the buffer everyone reaches for first. It works, but every transfer from h_data quietly goes through that staging detour.

float* h_data = (float*)malloc(N * sizeof(float));
cudaMemcpy(d_data, h_data, bytes, cudaMemcpyHostToDevice);

Why the OS Cares

The OS keeps memory pageable so it can overcommit RAM and serve many programs at once. That convenience is what blocks the GPU from reading your pages directly.

Bandwidth You Lose

Pageable transfers often reach only half of your link's peak bandwidth. The staging copy eats CPU cycles and memory traffic that real transfers could have used.

It Blocks Overlap Too

Because the staging copy is synchronous, pageable transfers cannot truly overlap with kernels. You lose the async tricks that make streams worthwhile.

When It Still Hurts

For one tiny copy nobody notices. But in a loop that ships data every iteration, the staging tax compounds and quietly dominates your runtime.

The Fix Is Coming

The cure is asking CUDA for a buffer that cannot be paged out, called pinned memory. The GPU reads it directly, no staging, no doubled copy.

Quick Check

Why is a transfer from ordinary pageable memory slower than it needs to be?

Recap

Pageable buffers can move, so the GPU cannot DMA them directly. The driver stages them first, doubling the copy. The fix ahead is pinned memory. 🚀

Questions Fréquemment Posées

La leçon « Pourquoi la mémoire paginable est lente » est-elle gratuite ?

Oui — le texte complet de « Pourquoi la mémoire paginable est lente » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours CUDA Academy, passe à CoddyKit PRO. Le cours CUDA Academy comprend 4 leçons au total.

Qu'est-ce que j'apprendrai dans « Pourquoi la mémoire paginable est lente » ?

Tamponnez les données derrière un malloc ordinaire. Tu pratiques CUDA Academy avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.

Dois-je avoir de l'expérience pour commencer CUDA Academy ?

Aucune expérience préalable n'est requise. CUDA Academy sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 1 sur 4.

Combien de temps prend la leçon « Pourquoi la mémoire paginable est lente » ?

La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.

Peux-tu écrire et exécuter du code dans cette leçon CUDA Academy ?

Oui. Chaque leçon CUDA Academy inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.

Toutes les leçons de ce cours

  1. Pourquoi la mémoire paginable est lente
  2. Mémoire épinglée avec cudaMallocHost
  3. cudaMemcpyAsync dans un flux
  4. Le pipeline à double tampon
← Retour à CUDA Academy