Skip to content

feat(primbench): support an extra backend - #5512

Merged
stanleytsang-amd merged 25 commits into
developfrom
users/mynameistrez/add-cuda-support-to-primbench
Apr 16, 2026
Merged

stanleytsang-amd merged 25 commits into
developfrom
users/mynameistrez/add-cuda-support-to-primbench

Conversation

@MyNameIsTrez

@MyNameIsTrez MyNameIsTrez commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

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

The PR feat(primbench): make AMD SMI and NVML soft dependencies also depends on this feat(primbench): support an extra backend PR, as it depends on the refactored code.

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",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}

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

codecov-commenter commented Mar 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project status has failed because the head coverage (77.72%) 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    65.53%   65.53%           
========================================
  Files         2045     2045           
  Lines       318558   318558           
  Branches     41872    41872           
========================================
  Hits        208741   208741           
  Misses       92486    92486           
  Partials     17331    17331           
Flag Coverage Δ *Carryforward flag
hipBLAS 90.67% <ø> (ø) Carriedforward from e8b1919
hipBLASLt 43.42% <ø> (ø) Carriedforward from e8b1919
hipCUB 82.21% <ø> (ø) Carriedforward from e8b1919
hipDNN 86.23% <ø> (ø) Carriedforward from e8b1919
hipFFT 58.16% <ø> (ø) Carriedforward from e8b1919
hipRAND 76.12% <ø> (ø) Carriedforward from e8b1919
hipSOLVER 68.73% <ø> (ø) Carriedforward from e8b1919
hipSPARSE 84.70% <ø> (ø) Carriedforward from e8b1919
rocBLAS 48.12% <ø> (ø) Carriedforward from e8b1919
rocFFT 52.39% <ø> (ø) Carriedforward from e8b1919
rocPRIM 38.96% <ø> (ø)
rocRAND 57.09% <ø> (ø) Carriedforward from e8b1919
rocSOLVER 77.72% <ø> (ø) Carriedforward from e8b1919
rocSPARSE 71.33% <ø> (ø) Carriedforward from e8b1919

*This pull request uses carry forward flags. Click here to find out more.

🚀 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 3 times, most recently from d79e040 to 3c4cc9f Compare March 20, 2026 10:11
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/add-cuda-support-to-primbench branch 3 times, most recently from 179665c to b0da0c7 Compare March 28, 2026 01:38
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/add-cuda-support-to-primbench branch from 19d397b to e8b1919 Compare April 10, 2026 16:55
@MyNameIsTrez
MyNameIsTrez marked this pull request as ready for review April 10, 2026 16:56
@MyNameIsTrez
MyNameIsTrez requested a review from a team as a code owner April 10, 2026 16:56
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/add-cuda-support-to-primbench branch from db0b448 to 70cdadb Compare April 14, 2026 15:18
@stanleytsang-amd
stanleytsang-amd merged commit 7692a35 into develop Apr 16, 2026
36 of 40 checks passed
@stanleytsang-amd
stanleytsang-amd deleted the users/mynameistrez/add-cuda-support-to-primbench branch April 16, 2026 21:23
assistant-librarian Bot pushed a commit to ROCm/rocPRIM that referenced this pull request Apr 16, 2026
feat(primbench): support an extra backend

## Motivation

The PR [feat(rocrand): use
primbench](ROCm/rocm-libraries#4454) requires
[primbench](https://github.com/ROCm/rocm-libraries/blob/develop/shared/primbench/README.md)
to support CUDA, since rocRAND contains cuRAND benchmarks.

The PR [feat(primbench): make AMD SMI and NVML soft
dependencies](ROCm/rocm-libraries#5637) also
depends on this `feat(primbench): support an extra backend` PR, as it
depends on the refactored code.

## 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](https://github.com/ROCm/rocm-libraries/pull/5512/commits), 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

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

### Setup

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

### Running the CUDA example benchmark

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

### Running the HIP example benchmark

```sh
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

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
stanleytsang-amd pushed a commit that referenced this pull request Apr 22, 2026
## Motivation

The PR [[rocPRIM] Warn/Prevent rocPRIM benchmarks from being built on
Windows](#5494) was merged as
a hotfix, since rocPRIM's benchmarks were not buildable on Windows
anymore.

This PR its commit `fix(rocprim): revert Windows hotfix PR #5494`
reverts that hotfix, and provides a *proper* fix, by turning AMD SMI and
NVML from hard dependencies into soft dependencies.

This PR will be undrafted once the PR [feat(primbench): support an extra
backend](#5512) on which it
is based has been merged.

## Technical Details


[Here](https://github.com/ROCm/rocm-libraries/tree/users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies/shared/primbench#dependencies)
is the updated Dependencies section of the readme:

<img width="1353" height="755" alt="image"
src="https://github.com/user-attachments/assets/ff8b98b5-1d1c-4fae-a6be-fd2ee7e7415c"
/>

## Test Plan

### VS Code dev containers

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

## Test Result

I have confirmed that Stream HPC's CI is now able to build rocPRIM's
benchmarks on Windows. It is crucial however for AMD's CI, or one of
AMD's reviewers, to confirm that rocPRIM's benchmarks now build and run
successfully on Windows for them too.

<details>
<summary>Monitoring still works</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```

</details>

<details>
<summary>Monitoring can now be turned off</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```

When monitoring is disabled, the `GPU °C` column is excluded from the
printed output:
```
Status of copy             Noise  Bytes/sec  Specialization   Index/2
─────────────────────────────────────────────────────────────────────
Success after 1s            0.1%   4.08e+11  type: char             0
Success after 1s            0.0%   5.33e+11  type: long long        1
```

The `monitoring`, `temperature_type` and `gpu_temp_celcius` keys are
also excluded from the JSON output:
```diff
23,27d22
<             "monitoring": {
<                 "name": "amdsmi",
<                 "version": "25.3.0"
<             },
<             "temperature_type": "edge",
73,76d67
<             },
<             "gpu_temp_celsius": {
<                 "start": 50,
<                 "end": 48
```

</details>

<details>
<summary>Forgetting to pass <code>-DPRIMBENCH_NO_MONITORING</code>
throws documented compilation errors</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. && ./copy_benchmark
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. && ./copy_benchmark
```

```
ld.lld: error: undefined symbol: amdsmi_get_lib_version
>>> referenced by copy_benchmark.cpp
```

```
/usr/bin/ld: /tmp/tmpxft_00007baa_00000000-11_copy_benchmark.o: in function `primbench::detail::monitor::get_temp() const':
tmpxft_00007baa_00000000-6_copy_benchmark.cudafe1.cpp:(.text._ZNK9primbench6detail7monitor8get_tempEv[_ZNK9primbench6detail7monitor8get_tempEv]+0x35): undefined reference to `nvmlDeviceGetTemperature'
```

</details>

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
assistant-librarian Bot pushed a commit to ROCm/rocPRIM that referenced this pull request Apr 22, 2026
feat(primbench): make AMD SMI and NVML soft dependencies
 (#5637)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

## Motivation

The PR [[rocPRIM] Warn/Prevent rocPRIM benchmarks from being built on
Windows](ROCm/rocm-libraries#5494) was merged as
a hotfix, since rocPRIM's benchmarks were not buildable on Windows
anymore.

This PR its commit `fix(rocprim): revert Windows hotfix PR #5494`
reverts that hotfix, and provides a *proper* fix, by turning AMD SMI and
NVML from hard dependencies into soft dependencies.

This PR will be undrafted once the PR [feat(primbench): support an extra
backend](ROCm/rocm-libraries#5512) on which it
is based has been merged.

## Technical Details

[Here](https://github.com/ROCm/rocm-libraries/tree/users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies/shared/primbench#dependencies)
is the updated Dependencies section of the readme:

<img width="1353" height="755" alt="image"
src="https://github.com/user-attachments/assets/ff8b98b5-1d1c-4fae-a6be-fd2ee7e7415c"
/>

## Test Plan

### VS Code dev containers

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

## Test Result

I have confirmed that Stream HPC's CI is now able to build rocPRIM's
benchmarks on Windows. It is crucial however for AMD's CI, or one of
AMD's reviewers, to confirm that rocPRIM's benchmarks now build and run
successfully on Windows for them too.

<details>
<summary>Monitoring still works</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```

</details>

<details>
<summary>Monitoring can now be turned off</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```

When monitoring is disabled, the `GPU °C` column is excluded from the
printed output:
```
Status of copy             Noise  Bytes/sec  Specialization   Index/2
─────────────────────────────────────────────────────────────────────
Success after 1s            0.1%   4.08e+11  type: char             0
Success after 1s            0.0%   5.33e+11  type: long long        1
```

The `monitoring`, `temperature_type` and `gpu_temp_celcius` keys are
also excluded from the JSON output:
```diff
23,27d22
<             "monitoring": {
<                 "name": "amdsmi",
<                 "version": "25.3.0"
<             },
<             "temperature_type": "edge",
73,76d67
<             },
<             "gpu_temp_celsius": {
<                 "start": 50,
<                 "end": 48
```

</details>

<details>
<summary>Forgetting to pass <code>-DPRIMBENCH_NO_MONITORING</code>
throws documented compilation errors</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. && ./copy_benchmark
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. && ./copy_benchmark
```

```
ld.lld: error: undefined symbol: amdsmi_get_lib_version
>>> referenced by copy_benchmark.cpp
```

```
/usr/bin/ld: /tmp/tmpxft_00007baa_00000000-11_copy_benchmark.o: in function `primbench::detail::monitor::get_temp() const':
tmpxft_00007baa_00000000-6_copy_benchmark.cudafe1.cpp:(.text._ZNK9primbench6detail7monitor8get_tempEv[_ZNK9primbench6detail7monitor8get_tempEv]+0x35): undefined reference to `nvmlDeviceGetTemperature'
```

</details>

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
aledudek pushed a commit that referenced this pull request May 20, 2026
## Motivation

The PR [feat(rocrand): use
primbench](#4454) requires
[primbench](https://github.com/ROCm/rocm-libraries/blob/develop/shared/primbench/README.md)
to support CUDA, since rocRAND contains cuRAND benchmarks.

The PR [feat(primbench): make AMD SMI and NVML soft
dependencies](#5637) also
depends on this `feat(primbench): support an extra backend` PR, as it
depends on the refactored code.

## 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](https://github.com/ROCm/rocm-libraries/pull/5512/commits), 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

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

### Setup

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

### Running the CUDA example benchmark

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

### Running the HIP example benchmark

```sh
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

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
aledudek pushed a commit that referenced this pull request May 20, 2026
## Motivation

The PR [[rocPRIM] Warn/Prevent rocPRIM benchmarks from being built on
Windows](#5494) was merged as
a hotfix, since rocPRIM's benchmarks were not buildable on Windows
anymore.

This PR its commit `fix(rocprim): revert Windows hotfix PR #5494`
reverts that hotfix, and provides a *proper* fix, by turning AMD SMI and
NVML from hard dependencies into soft dependencies.

This PR will be undrafted once the PR [feat(primbench): support an extra
backend](#5512) on which it
is based has been merged.

## Technical Details


[Here](https://github.com/ROCm/rocm-libraries/tree/users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies/shared/primbench#dependencies)
is the updated Dependencies section of the readme:

<img width="1353" height="755" alt="image"
src="https://github.com/user-attachments/assets/ff8b98b5-1d1c-4fae-a6be-fd2ee7e7415c"
/>

## Test Plan

### VS Code dev containers

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

## Test Result

I have confirmed that Stream HPC's CI is now able to build rocPRIM's
benchmarks on Windows. It is crucial however for AMD's CI, or one of
AMD's reviewers, to confirm that rocPRIM's benchmarks now build and run
successfully on Windows for them too.

<details>
<summary>Monitoring still works</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```

</details>

<details>
<summary>Monitoring can now be turned off</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```

When monitoring is disabled, the `GPU °C` column is excluded from the
printed output:
```
Status of copy             Noise  Bytes/sec  Specialization   Index/2
─────────────────────────────────────────────────────────────────────
Success after 1s            0.1%   4.08e+11  type: char             0
Success after 1s            0.0%   5.33e+11  type: long long        1
```

The `monitoring`, `temperature_type` and `gpu_temp_celcius` keys are
also excluded from the JSON output:
```diff
23,27d22
<             "monitoring": {
<                 "name": "amdsmi",
<                 "version": "25.3.0"
<             },
<             "temperature_type": "edge",
73,76d67
<             },
<             "gpu_temp_celsius": {
<                 "start": 50,
<                 "end": 48
```

</details>

<details>
<summary>Forgetting to pass <code>-DPRIMBENCH_NO_MONITORING</code>
throws documented compilation errors</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. && ./copy_benchmark
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. && ./copy_benchmark
```

```
ld.lld: error: undefined symbol: amdsmi_get_lib_version
>>> referenced by copy_benchmark.cpp
```

```
/usr/bin/ld: /tmp/tmpxft_00007baa_00000000-11_copy_benchmark.o: in function `primbench::detail::monitor::get_temp() const':
tmpxft_00007baa_00000000-6_copy_benchmark.cudafe1.cpp:(.text._ZNK9primbench6detail7monitor8get_tempEv[_ZNK9primbench6detail7monitor8get_tempEv]+0x35): undefined reference to `nvmlDeviceGetTemperature'
```

</details>

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
COrruDXC pushed a commit to COrruDXC/rocm-libraries that referenced this pull request Jun 4, 2026
## Motivation

The PR [feat(rocrand): use
primbench](ROCm#4454) requires
[primbench](https://github.com/ROCm/rocm-libraries/blob/develop/shared/primbench/README.md)
to support CUDA, since rocRAND contains cuRAND benchmarks.

The PR [feat(primbench): make AMD SMI and NVML soft
dependencies](ROCm#5637) also
depends on this `feat(primbench): support an extra backend` PR, as it
depends on the refactored code.

## 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](https://github.com/ROCm/rocm-libraries/pull/5512/commits), 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

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

### Setup

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

### Running the CUDA example benchmark

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

### Running the HIP example benchmark

```sh
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

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
stanleytsang-amd pushed a commit that referenced this pull request Sep 18, 2026
## Motivation

The PR [feat(rocrand): use
primbench](#4454) requires
[primbench](https://github.com/ROCm/rocm-libraries/blob/develop/shared/primbench/README.md)
to support CUDA, since rocRAND contains cuRAND benchmarks.

The PR [feat(primbench): make AMD SMI and NVML soft
dependencies](#5637) also
depends on this `feat(primbench): support an extra backend` PR, as it
depends on the refactored code.

## 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](https://github.com/ROCm/rocm-libraries/pull/5512/commits), 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

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

### Setup

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

### Running the CUDA example benchmark

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

### Running the HIP example benchmark

```sh
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

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
stanleytsang-amd pushed a commit that referenced this pull request Sep 18, 2026
## Motivation

The PR [[rocPRIM] Warn/Prevent rocPRIM benchmarks from being built on
Windows](#5494) was merged as
a hotfix, since rocPRIM's benchmarks were not buildable on Windows
anymore.

This PR its commit `fix(rocprim): revert Windows hotfix PR #5494`
reverts that hotfix, and provides a *proper* fix, by turning AMD SMI and
NVML from hard dependencies into soft dependencies.

This PR will be undrafted once the PR [feat(primbench): support an extra
backend](#5512) on which it
is based has been merged.

## Technical Details


[Here](https://github.com/ROCm/rocm-libraries/tree/users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies/shared/primbench#dependencies)
is the updated Dependencies section of the readme:

<img width="1353" height="755" alt="image"
src="https://github.com/user-attachments/assets/ff8b98b5-1d1c-4fae-a6be-fd2ee7e7415c"
/>

## Test Plan

### VS Code dev containers

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

## Test Result

I have confirmed that Stream HPC's CI is now able to build rocPRIM's
benchmarks on Windows. It is crucial however for AMD's CI, or one of
AMD's reviewers, to confirm that rocPRIM's benchmarks now build and run
successfully on Windows for them too.

<details>
<summary>Monitoring still works</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```

</details>

<details>
<summary>Monitoring can now be turned off</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```

When monitoring is disabled, the `GPU °C` column is excluded from the
printed output:
```
Status of copy             Noise  Bytes/sec  Specialization   Index/2
─────────────────────────────────────────────────────────────────────
Success after 1s            0.1%   4.08e+11  type: char             0
Success after 1s            0.0%   5.33e+11  type: long long        1
```

The `monitoring`, `temperature_type` and `gpu_temp_celcius` keys are
also excluded from the JSON output:
```diff
23,27d22
<             "monitoring": {
<                 "name": "amdsmi",
<                 "version": "25.3.0"
<             },
<             "temperature_type": "edge",
73,76d67
<             },
<             "gpu_temp_celsius": {
<                 "start": 50,
<                 "end": 48
```

</details>

<details>
<summary>Forgetting to pass <code>-DPRIMBENCH_NO_MONITORING</code>
throws documented compilation errors</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. && ./copy_benchmark
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. && ./copy_benchmark
```

```
ld.lld: error: undefined symbol: amdsmi_get_lib_version
>>> referenced by copy_benchmark.cpp
```

```
/usr/bin/ld: /tmp/tmpxft_00007baa_00000000-11_copy_benchmark.o: in function `primbench::detail::monitor::get_temp() const':
tmpxft_00007baa_00000000-6_copy_benchmark.cudafe1.cpp:(.text._ZNK9primbench6detail7monitor8get_tempEv[_ZNK9primbench6detail7monitor8get_tempEv]+0x35): undefined reference to `nvmlDeviceGetTemperature'
```

</details>

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
illsilin pushed a commit to igorluppi/rocm-libraries that referenced this pull request Oct 1, 2026
## Motivation

The PR [feat(rocrand): use
primbench](ROCm#4454) requires
[primbench](https://github.com/ROCm/rocm-libraries/blob/develop/shared/primbench/README.md)
to support CUDA, since rocRAND contains cuRAND benchmarks.

The PR [feat(primbench): make AMD SMI and NVML soft
dependencies](ROCm#5637) also
depends on this `feat(primbench): support an extra backend` PR, as it
depends on the refactored code.

## 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](https://github.com/ROCm/rocm-libraries/pull/5512/commits), 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

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

### Setup

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

### Running the CUDA example benchmark

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

### Running the HIP example benchmark

```sh
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

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
illsilin pushed a commit to igorluppi/rocm-libraries that referenced this pull request Oct 1, 2026
## Motivation

The PR [[rocPRIM] Warn/Prevent rocPRIM benchmarks from being built on
Windows](ROCm#5494) was merged as
a hotfix, since rocPRIM's benchmarks were not buildable on Windows
anymore.

This PR its commit `fix(rocprim): revert Windows hotfix PR ROCm#5494`
reverts that hotfix, and provides a *proper* fix, by turning AMD SMI and
NVML from hard dependencies into soft dependencies.

This PR will be undrafted once the PR [feat(primbench): support an extra
backend](ROCm#5512) on which it
is based has been merged.

## Technical Details


[Here](https://github.com/ROCm/rocm-libraries/tree/users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies/shared/primbench#dependencies)
is the updated Dependencies section of the readme:

<img width="1353" height="755" alt="image"
src="https://github.com/user-attachments/assets/ff8b98b5-1d1c-4fae-a6be-fd2ee7e7415c"
/>

## Test Plan

### VS Code dev containers

<details>
<summary>CUDA <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```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`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "cuda-minimal",
    "privileged": true,
    "runArgs": [
        "--gpus=all"
    ]
}
```

</details>

<details>
<summary>HIP <code>Dockerfile</code> +
<code>devcontainer.json</code></summary>

`Dockerfile`:
```Dockerfile
FROM rocm/rocm-terminal:latest
```

`devcontainer.json`:
```json
{
    "build": {
        "dockerfile": "Dockerfile"
    },
    "name": "hip-minimal",
    "runArgs": [
        "--device=/dev/kfd",
        "--device=/dev/dri"
    ]
}
```

</details>

## Test Result

I have confirmed that Stream HPC's CI is now able to build rocPRIM's
benchmarks on Windows. It is crucial however for AMD's CI, or one of
AMD's reviewers, to confirm that rocPRIM's benchmarks now build and run
successfully on Windows for them too.

<details>
<summary>Monitoring still works</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
```

</details>

<details>
<summary>Monitoring can now be turned off</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -DPRIMBENCH_NO_MONITORING && ./copy_benchmark --json-out no_monitoring.json --csv-out no_monitoring.csv
```

When monitoring is disabled, the `GPU °C` column is excluded from the
printed output:
```
Status of copy             Noise  Bytes/sec  Specialization   Index/2
─────────────────────────────────────────────────────────────────────
Success after 1s            0.1%   4.08e+11  type: char             0
Success after 1s            0.0%   5.33e+11  type: long long        1
```

The `monitoring`, `temperature_type` and `gpu_temp_celcius` keys are
also excluded from the JSON output:
```diff
23,27d22
<             "monitoring": {
<                 "name": "amdsmi",
<                 "version": "25.3.0"
<             },
<             "temperature_type": "edge",
73,76d67
<             },
<             "gpu_temp_celsius": {
<                 "start": 50,
<                 "end": 48
```

</details>

<details>
<summary>Forgetting to pass <code>-DPRIMBENCH_NO_MONITORING</code>
throws documented compilation errors</summary>

```sh
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. && ./copy_benchmark
```
```sh
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. && ./copy_benchmark
```

```
ld.lld: error: undefined symbol: amdsmi_get_lib_version
>>> referenced by copy_benchmark.cpp
```

```
/usr/bin/ld: /tmp/tmpxft_00007baa_00000000-11_copy_benchmark.o: in function `primbench::detail::monitor::get_temp() const':
tmpxft_00007baa_00000000-6_copy_benchmark.cudafe1.cpp:(.text._ZNK9primbench6detail7monitor8get_tempEv[_ZNK9primbench6detail7monitor8get_tempEv]+0x35): undefined reference to `nvmlDeviceGetTemperature'
```

</details>

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
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.

3 participants