Skip to content

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

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

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

Conversation

@harz05

@harz05 harz05 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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
Contributor Author

HIP tests, AMD MI100:

image

@harz05

harz05 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

CUDA Tests, Nvidia H100

image

@sanjibansg sanjibansg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks very nice! Thanks, this is very useful. We could run the tests and subsequently merge once the PR #11 is merged.

Comment thread tests/gpu_tests.tpp Outdated
Comment thread tests/gpu/unit_test.tpp
@harz05

harz05 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Overall looks very nice! Thanks, this is very useful. We could run the tests and subsequently merge once the PR #11 is merged.

thanks, i'll do the required changes and rebase it, once the other pr is merged

@sanjibansg sanjibansg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more comments to increase the scope, and avoiding passing a name to the gpu test function, since that could be redundant.

Comment thread tests/gpu/unit_test.tpp Outdated
Comment thread tests/cpu/unit_test.tpp
@sanjibansg

Copy link
Copy Markdown
Member

/runtest h100-47gb

@github-actions

Copy link
Copy Markdown

/runtest (h100-47gb): triggered - view run

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.

Test fixtures for AMD and Nvidia GPUs

2 participants