Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

About

Udemy's CUDA programming Masterclass with Examples in ROCM/HIP.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

 

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROCM/HIP Programming Masterclass

CUDA examples ported to HIP. The same sources build for AMD GPUs with ROCm/HIP and for NVIDIA GPUs with HIP's CUDA backend (hipcc plus the CUDA Toolkit).

Course Link

Requirements

On Debian/Ubuntu, the distribution package includes both backends:

sudo apt install hipcc

Build

Build all examples with platform-aware flags:

./Scripts/build-examples.sh
./Scripts/build-examples.sh --run

The script auto-detects AMD vs NVIDIA. Force a backend with HIP_PLATFORM=amd or HIP_PLATFORM=nvidia.

AMD cross-compilation without a local GPU:

HIP_PLATFORM=amd EXTRA_HIPCC_FLAGS=--offload-arch=gfx90a \
    ./Scripts/build-examples.sh

Manual build:

cd 01-Hello
hipcc -std=c++17 -o 01-Hello.out 01-Hello.hip \
      -I ../Common ../Common/*.cpp ../Common/*.hip
./01-Hello.out

Common headers:

  • Common/hipCommon.hiph replaces cuda_common.cuh.
  • Common/hipHelpers.hiph contains optional RAII helpers.
  • Common/hipPlatform.hiph detects AMD vs NVIDIA and sets HIP_WARP_SIZE to 64 on AMD and 32 on NVIDIA.
  • Common/CUDA/ contains a testing-only HIP-to-CUDA compatibility header.

Dynamic parallelism

32-DynamicParallelism and 33-Reduction use device-side dynamic parallelism on NVIDIA and a host-driven fallback on AMD. On NVIDIA they need relocatable device code, which the build script adds automatically:

hipcc -std=c++17 -rdc=true -o example.out example.hip \
      -I ../Common ../Common/*.cpp ../Common/*.hip

On AMD, no -rdc flag is required.

CUDA 13.2 compatibility

ROCm 5.7's NVIDIA-backend headers do not compile against CUDA 13.2. The build script detects this and adds Common/CUDA/ automatically. For a manual build:

hipcc -std=c++17 -I ../Common/CUDA -o 01-Hello.out 01-Hello.hip \
      -I ../Common ../Common/*.cpp ../Common/*.hip

This compatibility header is not used on AMD/ROCm builds.

Profiling: use rocprof on ROCm and ncu/Nsight on CUDA.

Validation

  • NVIDIA RTX A6000, CUDA 13.2, hipcc 5.7.1: 66/66 examples built and ran successfully.
  • AMD cross-compile for gfx90a: 66/66 examples built successfully. Runtime validation still requires an AMD GPU/ROCm host.

Portability

  • AMD wavefronts are 64 lanes; NVIDIA warps are 32. Reduction examples use HIP_WARP_SIZE, so AMD uses 64-lane wavefronts and NVIDIA uses 32-lane warps.
  • Explicit gpuErrorCheck calls are intentional; they are part of the error handling lesson. hipHelpers.hiph hides checks only for RAII cleanup.
  • Examples 32 and 33 use dynamic parallelism on NVIDIA and a host-driven fallback on AMD.

Feedback

Pull requests and feedback are welcome.

About

Udemy's CUDA programming Masterclass with Examples in ROCM/HIP.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages