Skip to content

feat(primbench): support an extra backend#5512

Draft
MyNameIsTrez wants to merge 16 commits intodevelopfrom
users/mynameistrez/add-cuda-support-to-primbench
Draft

feat(primbench): support an extra backend#5512
MyNameIsTrez wants to merge 16 commits intodevelopfrom
users/mynameistrez/add-cuda-support-to-primbench

Conversation

@MyNameIsTrez
Copy link
Contributor

@MyNameIsTrez MyNameIsTrez commented Mar 17, 2026

Motivation

The PR feat(rocrand): use primbench requires primbench to support CUDA, since rocRAND contains cuRAND benchmarks.

Technical Details

I've spent a few hours on cleaning up the commit history. I recommend reviewing this PR by clicking on the first commit in the Commits tab, and then clicking the Next button to scroll through the commits chronologically.

The first commit is feat(primbench): support CUDA and is by far the largest and most complex, so I recommend reviewing the other commits first since they're nice and small.

The feat(primbench): support vector CLI args commit was also required for rocRAND, since its benchmarks accept an array of values: --lambda 1 2 3.

Two flags were removed

Even though this PR adds CUDA support to primbench.hpp, it went down from 4075 lines to 3593 lines. This is mostly the result of me deciding to remove the flags --output-hip-device-properties-context and --output-amdsmi-context.

These flags were used to dump an extreme amount of extra context to the JSON output, but I have not actually found the extra context useful even once while updating all 53 rocPRIM benchmarks to use primbench.

Porting these flags to CUDA would have been a nightmare, and removing these two flags has made the library significantly more maintainable. In the future we might decide to output a few of the most useful context fields to the JSON output again.

Test Plan

VS Code dev containers

CUDA Dockerfile + devcontainer.json

Dockerfile:

FROM nvidia/cuda:12.9.1-devel-ubuntu24.04

RUN apt update && apt install -y git cmake ninja-build wget

RUN wget -qO- https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor > /etc/apt/keyrings/rocm.gpg

RUN echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 noble main" > /etc/apt/sources.list.d/rocm.list

RUN tee /etc/apt/preferences.d/rocm-pin-600 <<'EOF'
Package: *
Pin: origin repo.radeon.com
Pin-Priority: 600
EOF

RUN apt update && apt install -y hip-base

ENV HIP_PLATFORM=nvidia

devcontainer.json:

{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
HIP Dockerfile + devcontainer.json

Dockerfile:

FROM rocm/rocm-terminal:latest

devcontainer.json:

{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "privileged": true
}

Setup

git checkout users/mynameistrez/add-cuda-support-to-primbench && \
cd shared/primbench

Running the CUDA example benchmark

nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark

Running the HIP example benchmark

hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark

Test Result

The above commands work for me, and the JSON and CSV output looks correct.

Submission Checklist

@MyNameIsTrez MyNameIsTrez force-pushed the users/mynameistrez/add-cuda-support-to-primbench branch 6 times, most recently from 58d791c to 4743f41 Compare March 17, 2026 16:35
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project status has failed because the head coverage (77.21%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5512      +/-   ##
===========================================
- Coverage    66.57%   64.27%   -2.29%     
===========================================
  Files         1836     1988     +152     
  Lines       282885   308555   +25670     
  Branches     39734    40299     +565     
===========================================
+ Hits        188308   198317   +10009     
- Misses       78211    93495   +15284     
- Partials     16366    16743     +377     
Flag Coverage Δ *Carryforward flag
hipBLAS 90.67% <ø> (ø) Carriedforward from 1f1c69c
hipBLASLt 43.55% <ø> (ø) Carriedforward from 1f1c69c
hipCUB 82.38% <ø> (ø) Carriedforward from 1f1c69c
hipDNN 84.98% <ø> (-0.01%) ⬇️ Carriedforward from 1f1c69c
hipFFT 56.36% <ø> (ø) Carriedforward from 1f1c69c
hipRAND 76.12% <ø> (ø) Carriedforward from 1f1c69c
hipSOLVER 68.81% <ø> (ø) Carriedforward from 1f1c69c
hipSPARSE 84.70% <ø> (ø) Carriedforward from 1f1c69c
rocBLAS 47.97% <ø> (ø) Carriedforward from 1f1c69c
rocFFT 47.37% <ø> (ø) Carriedforward from 1f1c69c
rocPRIM 39.04% <ø> (?)
rocRAND 57.07% <ø> (ø) Carriedforward from 1f1c69c
rocSOLVER 77.21% <ø> (ø) Carriedforward from 1f1c69c
rocSPARSE 71.48% <ø> (ø) Carriedforward from 1f1c69c

*This pull request uses carry forward flags. Click here to find out more.
see 152 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MyNameIsTrez MyNameIsTrez force-pushed the users/mynameistrez/add-cuda-support-to-primbench branch from 8a8c064 to 51b7779 Compare March 18, 2026 17:20
@MyNameIsTrez MyNameIsTrez force-pushed the users/mynameistrez/add-cuda-support-to-primbench branch from 51b7779 to 3e9ed1b Compare March 18, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants