القوالب ونافذات الانزلاق
قسّم المناطق المجاورة إلى بلاطات مع خلايا هامشية.
القوالب ونافذات الانزلاق درس مجاني في CUDA Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في CUDA Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة CUDA Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
What a Stencil Is
A stencil computes each output from a fixed neighborhood of inputs, like averaging a pixel with the cells around it.
The Sliding Window
As you move along the array, the input window slides by one. Consecutive outputs share most of their inputs, so reuse is huge.
Perfect for Tiling
Because neighbors overlap, a tile loaded once feeds many outputs. Stencils are a textbook case where tiling shines.
Meet the Halo
To compute the edges of a tile you also need a few elements just outside it. Those extra border cells are called the halo.
Why the Halo Exists
The first thread in a tile needs its left neighbor, which belongs to the previous tile. Without halo cells that read goes wrong.
Sizing the Halo
For a radius-r stencil you load r extra cells on each side. A 3-point blur has radius 1, so one halo cell per side suffices.
A Padded Tile
Declare shared memory as blockDim plus 2 * radius so it holds the interior plus both halos in one tidy buffer.
__shared__ float tile[BLOCK + 2 * RADIUS];Loading the Interior
Each thread first loads its own element into the tile at an offset of radius, leaving room for the left halo in front.
tile[threadIdx.x + RADIUS] = in[gid];Loading the Halos
The first few threads do double duty, also fetching the left and right halo cells before the block synchronizes.
Then Sync and Stencil
After __syncthreads, each thread reads its neighbors entirely from the tile, never touching global memory again for that step.
Reuse Multiplier
Every interior value now serves 2r + 1 outputs from one shared-memory load. That is exactly the redundant traffic tiling removes.
Quick Check
Why does a tiled stencil need halo cells?
Recap
Stencils slide overlapping windows, so a halo of r extra cells per side lets a tile serve every output with one load each. ✅
الأسئلة الشائعة
هل درس «القوالب ونافذات الانزلاق» مجاني؟
نعم — نص درس «القوالب ونافذات الانزلاق» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة CUDA Academy، انتقل إلى CoddyKit PRO. تتضمن دورة CUDA Academy 4 دروس في المجموع.
ماذا ستتعلم في «القوالب ونافذات الانزلاق»؟
قسّم المناطق المجاورة إلى بلاطات مع خلايا هامشية. تتمرن على CUDA Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ CUDA Academy؟
لا تُشترط خبرة سابقة. CUDA Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «القوالب ونافذات الانزلاق»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس CUDA Academy هذا؟
نعم. كل درس في CUDA Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- مشكلة إعادة استخدام البيانات
- نمط التحميل والمزامنة والحساب
- القوالب ونافذات الانزلاق
- معالجة البلاطات الطرفية