التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb
نقاط التوقف وفحص كل خيط
التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb درس مجاني في CUDA Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في CUDA Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة CUDA Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Meet cuda-gdb
When a kernel misbehaves, cuda-gdb lets you pause it and look inside, just like gdb does for ordinary CPU programs. 🔍
Build with Debug Info
cuda-gdb needs symbols, so compile your kernel with -G to add full device debug information before you debug.
nvcc -g -G vecadd.cu -o vecaddWhy -G Matters
The -G flag disables many optimizations so line numbers and variables stay accurate, which makes stepping through device code trustworthy.
Launch the Debugger
Start a session by handing your binary to cuda-gdb, then type run to execute it under debugger control.
cuda-gdb ./vecaddSet a Breakpoint in a Kernel
Place a breakpoint right inside the kernel by naming the function, so execution pauses the moment a thread reaches it.
(cuda-gdb) break vecAddKernelMany Threads, One Stop
Thousands of threads may hit that breakpoint, so cuda-gdb stops and focuses on one thread at a time for inspection.
Step Line by Line
Use next to run the current line and pause on the following one, walking through your kernel's logic step by step.
(cuda-gdb) nextInspect a Variable
Check what a thread actually computed by asking cuda-gdb to print a local variable while you are paused inside the kernel.
(cuda-gdb) print iSwitch the Focused Thread
Move attention to a specific thread with cuda thread, picking the exact block and lane you want to inspect.
(cuda-gdb) cuda block 0 thread 5Read the Built-in Indices
You can print threadIdx and blockIdx just like normal variables, confirming exactly which data element this thread handles.
(cuda-gdb) print threadIdx.xContinue Execution
When you are done poking around, type continue to resume the program until the next breakpoint or until it finishes.
(cuda-gdb) continueQuick Check
Which compiler flag adds device debug information for cuda-gdb?
Recap
You compiled with -G, set a kernel breakpoint, stepped lines, switched threads, and printed indices. That is the core cuda-gdb loop. 🎉
الأسئلة الشائعة
هل درس «التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb» مجاني؟
نعم — نص درس «التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة CUDA Academy، انتقل إلى CoddyKit PRO. تتضمن دورة CUDA Academy 4 دروس في المجموع.
ماذا ستتعلم في «التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb»؟
نقاط التوقف وفحص كل خيط تتمرن على CUDA Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ CUDA Academy؟
لا تُشترط خبرة سابقة. CUDA Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس CUDA Academy هذا؟
نعم. كل درس في CUDA Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- التنقّل خطوة بخطوة في النوى باستخدام cuda-gdb
- العثور على تسرّبات الذاكرة باستخدام memcheck
- اكتشاف حالات التسابق باستخدام racecheck
- اكتشاف أخطاء المزامنة باستخدام synccheck