Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00
..

Transpose

Overview

This example performs a tiled 2D matrix transpose on the GPU using HIP. Each thread block uses a 32x32 shared memory tile to coalesce global memory accesses, and the host launches the kernel from multiple CPU threads - each with its own HIP stream - to exercise concurrent GPU execution. The workload is useful for profiling kernel dispatch latency, multi-stream overlap, and memory throughput under sustained GPU load. Optional MPI support adds an MPI_Alltoall phase to test distributed profiling.

Source Files

  • transpose.cpp - Defines the transpose_a kernel (shared-memory tiled transpose), the run() worker that allocates device memory and iterates kernel launches, and verify() for correctness checking.

Prerequisites

  • CMake 3.25+
  • HIP runtime and hipcc compiler
  • (Optional) MPI for distributed transpose

Building

Standalone build:

cmake -B <build_dir> -S <project_root>/examples/transpose -DCMAKE_PREFIX_PATH=/opt/rocm
cmake --build <build_dir>

As part of the examples suite:

cmake -B <build_dir> -S <project_root>/examples/ -DCMAKE_PREFIX_PATH=/opt/rocm
cmake --build <build_dir> --target transpose

To enable MPI support:

cmake -B build -DTRANSPOSE_USE_MPI=ON -DCMAKE_PREFIX_PATH=/opt/rocm transpose/
cmake --build build

Running

# Default: 2 threads, 500 iterations, sync every 10
./transpose

# Custom: 4 threads, 100 iterations, sync every 5
./transpose 4 100 5

Arguments:

Position Description Default
1 Number of CPU threads (each gets a HIP stream) 2
2 Number of kernel iterations 500
3 Synchronize every N iterations 10

Profiling with rocprofiler-systems

rocprof-sys-run -- ./transpose 4 200 10
Variable Value Purpose
ROCPROFSYS_ROCM_DOMAINS hip_runtime_api,kernel_dispatch,memory_copy Trace HIP API calls, kernel launches, and memory transfers
ROCPROFSYS_ROCM_EVENTS SQ_WAVES,GRBM_COUNT Sample GPU hardware counters
ROCPROFSYS_TRACE true Generate Perfetto trace
ROCPROFSYS_PROFILE true Generate call-stack profile
rocprof-sys-run \
    -e ROCPROFSYS_ROCM_DOMAINS=hip_runtime_api,kernel_dispatch,memory_copy \
    -e ROCPROFSYS_TRACE=true \
    -- ./transpose 4 200 10