返回课程
AI024 专业级

ROCm与HIP编程入门:实用教程

一份实用且现代的AMD GPU编程指南,涵盖ROCm和HIP。内容包括完整的软件栈、安装流程、构建工作流、内核编程、内存管理、性能工程、库使用、CUDA迁移以及生产环境调试实践。

5.0
30.0h
361 名学生
10 lessons
0 点赞
人工智能
开始学习

课程概述

📚 内容概要

一本实用且现代的 AMD GPU 编程指南,涵盖 ROCm 与 HIP。内容包括完整的软件栈、安装流程、构建工作流、内核编程、内存管理、性能工程、库使用、CUDA 迁移以及生产环境下的调试实践。

通过本次技术深度解析,掌握 AMD GPU 编程与 CUDA 到 HIP 的可移植性。

作者: EvoClass

致谢: 基于 AMD 官方 ROCm 与 HIP 文档资料,包括 ROCm、HIP 及 ROCm LLVM 等项目。

🎯 学习目标

  1. 用一句简洁的话定义 HIP 及其在 ROCm 生态系统中的角色。
  2. 区分 ROCm(平台)、HIP(接口)和 ROCm 库(构建模块)之间的差异。
  3. 识别从硬件到应用框架的 ROCm 架构分层结构。
  4. 定义 HIP SDK 与不同操作系统下 ROCm 平台之间的关系。
  5. 执行系统化的安装流程,包括支持矩阵验证和安装后路径配置。
  6. 编译并运行一个最小验证程序,以排查常见的驱动与环境访问问题。
  7. 理解稳健的构建策略对于平衡源码可移植性与架构特定性能的重要性。
  8. 使用 hipLaunchKernelGGL 宏实现可移植的内核启动,作为 CUDA 三重尖括号语法的替代方案。
  9. 配置面向生产的 CMake 项目,针对特定 ROCm 架构并管理外部库依赖。
  10. 描述 HIP 内核的组成结构,并应用基本的线程索引执行公式。

课程

Lesson

This lesson introduces the ROCm platform and the HIP programming model as a bridge for porting CUDA applications to AMD hardware. Students will learn how to use automated tools like hipify to migrate code while understanding the importance of architecture-aware tuning to achieve optimal performance.

This lesson covers the essential steps for installing and configuring the ROCm software stack, including dependency management, environment variable setup, and user permission requirements. Students will learn how to verify their system environment and ensure successful hardware-software communication through diagnostic tools and proper configuration.

This lesson explores the distinction between source portability and binary performance in the ROCm ecosystem, emphasizing that while HIP code is functionally portable, achieving peak throughput requires architecture-specific compilation. Students will learn to utilize the hipcc toolchain and CMake to manage build configurations that optimize code for specific hardware instruction sets.

This lesson introduces the HIP programming model, focusing on the transition from sequential CPU iteration to spatial GPU parallelism using the Parallel Pivot approach. Students will learn to map independent data tasks to thread grids, manage memory, and implement kernel execution with proper boundary checks and error handling.

AI024: Memory Management and Data Patterns (Lesson 5) explores the memory-centric nature of GPU performance, focusing on the Roofline Model and the critical importance of minimizing data movement between host and device. Students will learn to distinguish between memory-bound and compute-bound kernels while mastering strategies to optimize data residence and bandwidth utilization.

This lesson explores the transition from synchronous to asynchronous GPU execution, focusing on how to use HIP streams to decouple CPU and GPU tasks. Students will learn to optimize performance by implementing non-blocking memory transfers and kernel launches to maximize hardware utilization and eliminate execution bottlenecks.

This lesson introduces a systematic, data-driven approach to performance engineering on AMD GPUs, emphasizing the use of tools like rocprofv3 to identify bottlenecks rather than relying on intuition. Students will learn to follow a six-step scientific workflow to optimize memory access, instruction throughput, and hardware utilization while avoiding common performance "superstitions."

This lesson introduces the Library-First Engineering Principle, which emphasizes using optimized ROCm libraries like rocBLAS and rocFFT to reduce technical debt and ensure hardware portability. Students will learn to prioritize these vendor-tuned solutions over custom kernel development to achieve better performance and easier maintenance across evolving GPU architectures.

AI024: Porting CUDA Applications to HIP (Lesson 9) covers the systematic, incremental migration of CUDA code to the HIP platform using tools like HIPIFY-Clang and HIPIFY-Perl. Students will learn to distinguish between mechanical API translations and architectural optimizations, such as adjusting for warp-size differences, to ensure functional and performance parity on AMD ROCm hardware.

This lesson explores the GPU Developer’s Creed, which prioritizes functional correctness and architectural isolation over raw performance when working with ROCm and HIP. Students will learn to implement systematic debugging, testing, and CI/CD practices to ensure stable, reproducible, and accurate GPU kernel deployments.