CUDA 編程指南
開發者學習 CUDA 編程模型並撰寫高效能代碼以在 NVIDIA GPU 上執行的官方全面資源。本指南涵蓋平台架構、程式介面、進階硬體功能及技術規格。
課程總覽
📚 內容概要
官方且全面的開發者資源,用於學習 CUDA 程式設計模型,以及如何撰寫可在 NVIDIA GPU 上執行的高效能程式碼。本指南涵蓋平台架構、程式介面、進階硬體功能與技術規格。
掌握平行運算藝術,使用業界標準的 NVIDIA CUDA 指南。
作者: NVIDIA Corporation
致謝: 版權所有 © 2007–2024 NVIDIA Corporation 及其附屬公司。保留一切權利。
🎯 學習目標
- 定義異質系統中主機(CPU)與裝置(GPU)的角色。
- 解釋 SIMT 程式設計模型,以及線程、區塊與網格的層次化組織。
- 区分 PTX(平行線程執行)與二進位碼(cubins),並說明即時(JIT)編譯如何促進相容性。
- 開發與編譯 CUDA 核心函數:撰寫 global 函數,以三箭頭語法設定執行方式,並管理 NVCC 編譯流程。
- 優化記憶體與資料搬移:區分統一記憶體、明確記憶體與對映記憶體模型,並實作頁鎖定主機記憶體以提升傳輸效率。
- 管理平行執行:使用 CUDA 流、事件與合作群組,以管理非同步任務並同步 CPU-GPU 操作。
- 進行複雜指標運算,並識別架構瓶頸(馮·諾伊曼與哈佛架構之差異)。
- 實作進階 CUDA 執行模式,包括程式控制的依賴核心啟動與異質批次記憶體傳輸。
- 利用硬體特定功能(如線程範圍、非同步代理與管道)以最大化併發性。
- 使用預取、使用提示與頁面大小管理等技術,配置與調校統一記憶體效能。
課程 共 5 课时 · 预计 30.0h
課程
Lesson
This lesson introduces the fundamental shift from latency-optimized CPU architectures to throughput-oriented GPU computing. Students will learn to distinguish between these processing models and understand how the CUDA programming platform enables massive parallel execution for data-intensive tasks.
This lesson introduces the fundamentals of CUDA kernel development, focusing on the SIMT execution model and the use of the __global__ specifier to launch parallel functions on GPU Streaming Multiprocessors. Students will learn how to manage asynchronous kernel execution, handle device memory, and structure code to ensure effective hardware utilization.
This lesson explores the fundamental differences between von Neumann and Harvard architectures, focusing on how memory access pathways impact computational performance. Students will learn to identify the von Neumann bottleneck, understand the benefits of split-cache Harvard designs, and analyze how modern systems utilize a Modified Harvard Architecture to balance throughput with programming flexibility.
AI021: Optimization, Graphs, and Hardware Accelerators (Lesson 4) explores the shift from CPU-bottlenecked stream execution to GPU-autonomous workflows. Students will learn to utilize modern primitives like CUDA Graphs, lazy loading, and asynchronous memory prefetching to minimize host-side overhead and maximize hardware efficiency.
This lesson explores the technical reference and language extensions in CUDA, focusing on the relationship between virtual architectures (PTX) and real hardware (SASS). Students will learn to manage compute capabilities, utilize architecture-specific macros, and navigate language constraints to ensure code portability and performance.