Skip to content

[tests] remove cuda/hip test duplication with a templated fixture - #13

Open
harz05 wants to merge 2 commits into
ML4EP:devfrom
harz05:test/gpu-fixtures
Open

[tests] remove cuda/hip test duplication with a templated fixture#13
harz05 wants to merge 2 commits into
ML4EP:devfrom
harz05:test/gpu-fixtures

Conversation

@harz05

@harz05 harz05 commented Aug 13, 2026

Copy link
Copy Markdown

Closes #12

The CUDA and HIP test functions were verbatim, differing only in the platform/device/tag types and the name prefix. The approach used to remove duplication is by using a template file tests/gpu_tests.tpp that is parameterised with the alpaka tag.
Platform and device types come from the tag through TagToAcc, Dev, Platform and main() instantiates it once per enabled
backend

Changes made to tests/CMakeLists.txt file:

  • CUDA arch was a plain set(... 86), which shadows the cache entry so -D was ignored. Defaults to native behind if(NOT DEFINED) now.
  • CMAKE_HIP_ARCHITECTURES was pinned to gfx1100. Left unset so CMake takes it from rocm_agent_enumerator.
  • CUDA goes through check_language with test_cuda guarded, same as HIP already did.
  • OpenBLAS lookup also accepts the shared lib and /usr/lib64 for RHEL family.
  • test_hip needs ${CMAKE_CURRENT_SOURCE_DIR} on its include path, it compiles a copy of test.cc from the build dir so the include of the .tpp would not resolve otherwise.

Testing

No architecture or backend flags needed, cmake picks up whatever is on the machine:

git clone --depth 1 https://github.com/alpaka-group/alpaka
git clone -b test/gpu-fixtures https://github.com/harz05/sofieBLAS
cmake -S sofieBLAS/tests -B build -DALPAKA_BASE=$PWD/alpaka
cmake --build build -j

./build/test_cpu
./build/test_cuda   # for nvidia gpu
./build/test_hip    # for amd gpu

Ran this on two machines:

  • NVIDIA H100, CUDA 13.1: test_cpu 17/17, test_cuda 13/13
  • AMD Instinct MI100 (gfx908), ROCm 7.2: test_cpu 17/17, test_hip 13/13

Results screenshot in the comments below

@harz05

harz05 commented Aug 13, 2026

Copy link
Copy Markdown
Author

HIP tests, AMD MI100:

image

@harz05

harz05 commented Aug 13, 2026

Copy link
Copy Markdown
Author

CUDA Tests, Nvidia H100

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant