0Pricing
CUDA Academy · درس

لماذا الذاكرة القابلة لترحيل الصفحات بطيئة

ضع البيانات مؤقتًا خلف malloc العادي.

لماذا الذاكرة القابلة لترحيل الصفحات بطيئة درس مجاني في CUDA Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في CUDA Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة CUDA Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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. 🚀

الأسئلة الشائعة

هل درس «لماذا الذاكرة القابلة لترحيل الصفحات بطيئة» مجاني؟

نعم — نص درس «لماذا الذاكرة القابلة لترحيل الصفحات بطيئة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة CUDA Academy، انتقل إلى CoddyKit PRO. تتضمن دورة CUDA Academy 4 دروس في المجموع.

ماذا ستتعلم في «لماذا الذاكرة القابلة لترحيل الصفحات بطيئة»؟

ضع البيانات مؤقتًا خلف malloc العادي. تتمرن على CUDA Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ CUDA Academy؟

لا تُشترط خبرة سابقة. CUDA Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «لماذا الذاكرة القابلة لترحيل الصفحات بطيئة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس CUDA Academy هذا؟

نعم. كل درس في CUDA Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. لماذا الذاكرة القابلة لترحيل الصفحات بطيئة
  2. الذاكرة المثبّتة باستخدام cudaMallocHost
  3. استخدام cudaMemcpyAsync في Stream
  4. خط أنابيب التخزين المزدوج
← العودة إلى CUDA Academy