CUDA warp scheduler क्या है? Eligible warp और stall से GPU bottleneck का निदान
CUDA warp scheduler, SM sub-partition में resident warps में से उस warp को चुनता है जो अगला instruction issue करने के लिए तैयार हो। Resident (active) warps बहुत हों, तब भी data dependency या barrier के कारण तैयार (eligible) warps कम रह सकते हैं और issue slot खाली जा सकता है। इसलिए scheduler को समझने के लिए केवल occupancy न देखें; eligible warps, वास्तविक issue activity और संभावित bottleneck को साथ में जाँचें। [NVIDIA Nsight Compute Profiling Guide](https://docs.nvidia.com/nsight-compute/ProfilingGuide/) [CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/)
CUDA warp scheduler क्या है? Eligible warp और stall से GPU bottleneck का निदान
CUDA warp scheduler, SM sub-partition में resident warps में से उस warp को चुनता है जो अगला instruction issue करने के लिए तैयार हो। Resident (active) warps बहुत हों, तब भी data dependency या barrier के कारण तैयार (eligible) warps कम रह सकते हैं और issue slot खाली जा सकता है। इसलिए scheduler को समझने के लिए केवल occupancy न देखें; eligible warps, वास्तविक issue activity और संभावित bottleneck को साथ में जाँचें। NVIDIA Nsight Compute Profiling Guide CUDA C++ Best Practices Guide
यह लेख 2026-11-22 को देखे गए NVIDIA CUDA और Nsight Compute के ऑनलाइन दस्तावेज़ों पर आधारित है। सटीक counter नाम और उनकी उपलब्धता GPU architecture तथा installed tool version के अनुसार बदल सकती है।
Warp scheduler instruction कैसे issue करता है?
जब CUDA block किसी SM पर चलता है, उसके threads warp के रूप में व्यवस्थित होते हैं। Nsight Compute उस warp को active कहता है जिसे scheduler द्वारा प्रबंधित pool में नियुक्त किया गया हो। Active होने का अर्थ यह नहीं कि वह उसी क्षण instruction चला रहा है। जब instruction decode हो चुका हो, input dependencies सुलझ गई हों और आवश्यक execution unit उपलब्ध हो, तब warp eligible होता है। Scheduler किसी eligible warp को चुनकर एक या अधिक instructions issue कर सकता है। यदि कोई warp तैयार न हो, तो संबंधित issue slot छोड़ दिया जाता है। ये शब्द और उनके aggregate, Nsight Compute के analysis model का हिस्सा हैं; सभी GPU generations में scheduler की संख्या या कोई खास policy समान न मानें। Nsight Compute Profiling Guide — Scheduler Statistics
इस संबंध को सरल रूप में ऐसे दिखाया जा सकता है:
SM sub-partition
Active Warps
├─ instruction/dependency/pipeline not ready → stalled
└─ instruction ready + dependencies resolved + pipeline available
→ Eligible Warps → scheduler selects → Issued Warp
Eligible Warps = 0 → issue slot skippedउदाहरण के लिए, global memory से पढ़ी गई value आने तक warp A आगे नहीं बढ़ सकता। यदि warp B के operands पहले से उपलब्ध हों, तो scheduler B को चुन सकता है। यह बदलाव स्वतंत्र काम चलाकर memory latency को छिपाता है। लेकिन यदि सभी resident warps एक ही data dependency या block barrier का इंतज़ार कर रहे हों, तो उस क्षण चुनने के लिए कोई eligible warp न हो सकता है। CUDA C++ Best Practices Guide — Differences Between Host and Device
Active warp और occupancy, eligible warp की गारंटी क्यों नहीं देते?
Occupancy, SM पर resident active warps की संख्या और उस SM पर device द्वारा रखे जा सकने वाले अधिकतम active warps का अनुपात है। यह बताता है कि कितने warps resident हैं, पर यह नहीं बताता कि वे अभी instruction issue कर सकते हैं या हर cycle में issue हो रहा है। Nsight Compute scheduler statistics में active, eligible और issued warps अलग-अलग दिखाता है। Occupancy ऊँची होने पर भी लंबी memory dependencies से eligible warps और issue activity कम हो सकती है। कम occupancy वाला kernel भी पर्याप्त independent work होने पर pipeline को व्यस्त रख सकता है। केवल ऊँची occupancy से अच्छा performance सुनिश्चित नहीं होता, और हर stall हटाना optimization का लक्ष्य नहीं है। Nsight Compute Profiling Guide Nsight Compute Compute Triage Guide
| अवलोकन | इसका संभावित अर्थ | आगे क्या जाँचें |
|---|---|---|
| Active warps बहुत हैं, पर eligible warps और issue activity कम हैं | कई warps resident हैं, लेकिन प्रतीक्षा कर सकते हैं | Stall का कारण खोजें और तय करें कि सीमा latency है या पहले से saturated throughput |
not_selected samples बहुत हैं | Warp eligible था, लेकिन उसी समय scheduler ने दूसरा warp चुना हो सकता है। Nsight Compute इसे अपने आप वास्तविक stall नहीं मानता। | selected या not_selected को प्रतीक्षा का कारण न समझें; issue-slot utilization के साथ उनका अर्थ देखें |
long_scoreboard samples प्रमुख हैं | कोई instruction memory operation के परिणाम की प्रतीक्षा कर सकता है | Sample हुए consumer instruction से dependencies को पीछे की ओर trace करें; source load, access pattern, cache reuse और independent work जाँचें |
| CTA barrier-wait samples बहुत हैं | कुछ warps उसी block के दूसरे warps से पहले barrier पर पहुँच सकते हैं | Barrier से पहले work imbalance या divergent paths देखें और जाँचें कि वहाँ synchronization चाहिए या नहीं |
| Compute या memory throughput पहले से ऊँचा है | Bottleneck scheduler readiness के बजाय pipeline या memory-system throughput हो सकता है | केवल warp count बढ़ाने के बजाय saturated resource के काम और efficiency का विश्लेषण करें |
long_scoreboard जैसे नाम Nsight Compute की collection methods और versions से जुड़ी sample categories हैं। मौजूदा Nsight Compute guidance बताती है कि memory-dependency sample उस consumer instruction से जुड़ सकता है जो परिणाम की प्रतीक्षा कर रहा है, न कि उस load से जिसने परिणाम बनाया। इसलिए sample वाली source line को धीमी memory request की जगह न मानें। selected और not_selected भी scheduler states हैं, वास्तविक stall causes नहीं। अपने tool version की metric definitions पढ़ें और samples को source तथा machine-instruction dependencies से मिलाएँ। Nsight Compute Compute Triage Guide — Warp Stall Breakdown
Nsight Compute में पहले कौन-से मान देखें?
CUDA kernels का विश्लेषण करते समय Nsight Compute का SchedulerStats section हर scheduler के theoretical, active, eligible और issued warps की तुलना करने में मदद करता है। SourceCounters के warp-stall samples को SpeedOfLight के compute और memory throughput के साथ देखने से खाली issue slot और पहले से व्यस्त pipeline में फर्क समझ आता है। Installed version के अनुसार section नाम बदल सकते हैं; पहले ncu --list-sections से उपलब्ध sections जाँचें। Nsight Compute Profiling Guide Nsight Compute CLI User Guide
Linux shell में executable की जाँच करने वाला command इस तरह दिखता है। Executable और उसके arguments को अपनी application के अनुसार बदलें और installed version में section नाम की पुष्टि करें।
ncu --section SchedulerStats --section SourceCounters --section SpeedOfLight ./appCollection में replay या कई passes लग सकते हैं और profiler स्वयं भी overhead जोड़ता है। इसलिए Nsight Compute report में दिया समय application का सामान्य runtime न मानें। पहले correctness जाँचें और उसी input के लिए सामान्य run में baseline time दर्ज करें। कारण खोजने के लिए profiling करें, फिर बदलाव को उन्हीं मूल measurement conditions में compare करें। Nsight Compute Profiling Guide — Metric Collection and Replay Nsight Compute CLI User Guide
Stall का कारण कैसे खोजें और बदलाव की पुष्टि कैसे करें?
नीचे की प्रक्रिया CUDA application, compatible NVIDIA GPU, CUDA Toolkit और installed Nsight Compute version मानकर चलती है। यह दोहराई जा सकने वाली workflow है; इस लेख की तैयारी के दौरान कोई GPU kernel run या profile नहीं किया गया।
**Baseline conditions तय करें।** GPU model, compute capability, driver/CUDA/Nsight Compute versions, kernel configuration और input लिखें। Correctness जाँचें और profiler के बिना कई सामान्य runs में kernel time मापें।
**लक्षित kernel की scheduler statistics देखें।** `SchedulerStats` में active, eligible और issued warps की तुलना करें और देखें कि issue activity कम है या नहीं। Installation में उपलब्ध analysis sections देखने के लिए `ncu --list-sections` चलाएँ।
**Throughput और stall samples की तुलना करें।** `SpeedOfLight` में देखें कि संबंधित compute या memory pipeline saturated है या नहीं। कम issue activity की व्याख्या चाहिए तभी `SourceCounters` के प्रतिनिधि stall samples को trace करें। सबसे अधिक दिखने वाला sample कारण पूरे kernel का bottleneck होना जरूरी नहीं।
**Evidence से मेल खाने वाला एक बदलाव करें।** Memory dependency के लिए consumer instruction, access pattern, reuse और independent work या pipelining की संभावनाएँ देखें। Barrier के लिए उससे पहले imbalance या अनावश्यक synchronization खोजें। Active warps कम हों तो registers, shared memory और block configuration जैसे सीमित resources जाँचें। बिना जाँच registers घटाने या occupancy बढ़ाने से spills या नया bottleneck बन सकता है।
**Correctness और वास्तविक समय फिर जाँचें।** उसी input से पुष्टि करें कि परिणाम सही है और profiler के बाहर मूल conditions में समय compare करें। Performance न सुधरे तो बदलाव वापस लें और दूसरी वजह देखें।
AMD wavefront samples की तुलना NVIDIA warp counters से ऐसे न करें जैसे दोनों एक ही metrics हों। उदाहरण के लिए, AMD CDNA 3/4 PC-sampling documentation WAITCNT, BARRIER_WAIT और ARBITER_NOT_WIN जैसी states को SIMD arbiter state से अलग बताती है और architecture तथा sample meanings की सीमा स्पष्ट करती है। AMD system-level analysis से शुरू होकर kernel और instruction tools तक जाने वाली अलग profiling workflow भी सुझाता है। AMD ROCm Profiling Tool Selection AMD ROCprofiler-SDK — CDNA3/CDNA4 PC Sampling
Warp scheduler latency छिपाने में मदद के लिए तैयार काम चुनता है; वह प्रतीक्षा का कारण नहीं हटाता और ऊँची occupancy को तेज execution में नहीं बदलता। Diagnosis में residency, issue के लिए readiness और वास्तविक throughput को अलग-अलग देखें; फिर profiler के संकेतों को instruction dependencies और सामान्य runtime से verify करें।
संदर्भ
- NVIDIA Nsight Compute Profiling Guide — Scheduler Statistics, Occupancy, and Stall Reasons
- NVIDIA CUDA C++ Best Practices Guide — Latency Hiding
- NVIDIA Nsight Compute Compute Triage Guide — Occupancy and Warp Stall Analysis
- NVIDIA Nsight Compute CLI User Guide
- AMD ROCm — Choosing the Right Profiling Tool
- AMD ROCprofiler-SDK — CDNA3 and CDNA4 PC Sampling