نمط التحميل والمزامنة والحساب
جهّز البلاطات قبل إجراء العمليات الحسابية عليها.
نمط التحميل والمزامنة والحساب درس مجاني في CUDA Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في CUDA Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة CUDA Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Three Simple Phases
Tiling follows one rhythm in every kernel: load a tile into shared memory, sync, then compute from the fast copy.
Phase One: Load
In the load phase, each thread reads one element from global memory and stores it into a shared-memory tile its whole block can see.
tile[threadIdx.x] = in[globalIndex];A Cooperative Effort
Loading is a team job. Every thread fetches its slice, so together the block stages one full tile with a single coalesced pass.
Phase Two: Sync
Before anyone reads a neighbor s value, all threads must finish loading. __syncthreads is the barrier that guarantees the tile is ready.
__syncthreads();Why Sync Is Mandatory
Skip the barrier and a thread may read a tile slot that its neighbor has not written yet. That is a race and gives wrong results. 💥
Phase Three: Compute
Now every value lives on chip. In the compute phase threads read tile entries freely, since shared memory is orders faster than global.
Fast Reuse Pays Off
Because the tile sits in shared memory, a value loaded once is reused by many threads with almost no extra cost. That is the whole win.
Sometimes Sync Again
If the compute phase writes back into the same tile for a next step, add a second __syncthreads before reusing those slots.
All Threads or None
Every thread in the block must reach __syncthreads. If some skip it inside a branch, the kernel deadlocks or misbehaves.
A Reusable Skeleton
Load, sync, compute is a template you will reuse for convolutions, matrix multiply, and reductions throughout this category.
Mind the Tile Size
The shared tile must fit the block. Tile width usually equals blockDim, so each thread owns exactly one slot to load and reuse.
Quick Check
Why is __syncthreads needed between load and compute?
Recap
Tiling is load, sync, compute: stage a tile cooperatively, barrier so it is complete, then reuse it fast on chip. ✅
الأسئلة الشائعة
هل درس «نمط التحميل والمزامنة والحساب» مجاني؟
نعم — نص درس «نمط التحميل والمزامنة والحساب» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة CUDA Academy، انتقل إلى CoddyKit PRO. تتضمن دورة CUDA Academy 4 دروس في المجموع.
ماذا ستتعلم في «نمط التحميل والمزامنة والحساب»؟
جهّز البلاطات قبل إجراء العمليات الحسابية عليها. تتمرن على CUDA Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ CUDA Academy؟
لا تُشترط خبرة سابقة. CUDA Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «نمط التحميل والمزامنة والحساب»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس CUDA Academy هذا؟
نعم. كل درس في CUDA Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- مشكلة إعادة استخدام البيانات
- نمط التحميل والمزامنة والحساب
- القوالب ونافذات الانزلاق
- معالجة البلاطات الطرفية