Skip to content

feat(primbench): make AMD SMI and NVML soft dependencies - #5637

Merged
stanleytsang-amd merged 11 commits into
developfrom
users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies
Apr 22, 2026
Merged

stanleytsang-amd merged 11 commits into
developfrom
users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies

Conversation

@MyNameIsTrez

@MyNameIsTrez MyNameIsTrez commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The PR [rocPRIM] Warn/Prevent rocPRIM benchmarks from being built on Windows 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 on which it is based has been merged.

Technical Details

Here is the updated Dependencies section of the readme:

image

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"
    ]
}

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.

Monitoring still works
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. -lamd_smi && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
nvcc -o copy_benchmark examples/cuda/copy_benchmark.cu -I. -lnvidia-ml && ./copy_benchmark --json-out monitoring.json --csv-out monitoring.csv
Monitoring can now be turned off
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
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:

23,27d22
<             "monitoring": {
<                 "name": "amdsmi",
<                 "version": "25.3.0"
<             },
<             "temperature_type": "edge",
73,76d67
<             },
<             "gpu_temp_celsius": {
<                 "start": 50,
<                 "end": 48
Forgetting to pass -DPRIMBENCH_NO_MONITORING throws documented compilation errors
hipcc -o copy_benchmark examples/hip/copy_benchmark.cpp -I. && ./copy_benchmark
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'

Submission Checklist

@codecov-commenter

codecov-commenter commented Mar 20, 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    #5637   +/-   ##
========================================
  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 70cdadb
hipBLASLt 43.42% <ø> (ø) Carriedforward from 70cdadb
hipCUB 82.21% <ø> (ø) Carriedforward from 70cdadb
hipDNN 86.23% <ø> (ø) Carriedforward from 70cdadb
hipFFT 58.16% <ø> (ø) Carriedforward from 70cdadb
hipRAND 76.12% <ø> (ø) Carriedforward from 70cdadb
hipSOLVER 68.73% <ø> (ø) Carriedforward from 70cdadb
hipSPARSE 84.70% <ø> (ø) Carriedforward from 70cdadb
rocBLAS 48.12% <ø> (ø) Carriedforward from 70cdadb
rocFFT 52.39% <ø> (ø) Carriedforward from 70cdadb
rocPRIM 38.96% <ø> (ø)
rocRAND 57.09% <ø> (ø) Carriedforward from 70cdadb
rocSOLVER 77.72% <ø> (ø) Carriedforward from 70cdadb
rocSPARSE 71.33% <ø> (ø) Carriedforward from 70cdadb

*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/make-amdsmi-and-nvml-soft-dependencies branch 2 times, most recently from c32e0fe to a9fbbe1 Compare March 20, 2026 12:57
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch 3 times, most recently from f5b4ffa to bc28665 Compare April 1, 2026 21:10
@MyNameIsTrez MyNameIsTrez mentioned this pull request Apr 8, 2026
1 task done
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch from 28984c0 to 0bb409a Compare April 10, 2026 17:07
@MyNameIsTrez
MyNameIsTrez marked this pull request as ready for review April 10, 2026 17:07
@MyNameIsTrez
MyNameIsTrez requested review from a team as code owners April 10, 2026 17:07
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch from 0bb409a to f93a41c Compare April 10, 2026 17:22
@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch from f93a41c to 5a84121 Compare April 14, 2026 15:24
@MyNameIsTrez

Copy link
Copy Markdown
Contributor Author

Rebased.

@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch from 2140e55 to 669c836 Compare April 15, 2026 18:02
@MyNameIsTrez

MyNameIsTrez commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor Author

I added the commit feat(primbench): dynamic kernel warming in order to unhardcode the magic values threads_per_block = 256 and num_items = 1 << 20. Both the HIP and CUDA primbench examples still take roughly the same amount of time to warm up the GPU, which I expected.

stanleytsang-amd pushed a commit that referenced this pull request Apr 16, 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.
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

Copy link
Copy Markdown
Contributor

@MyNameIsTrez Please resolve the merge conflicts, thanks!

@MyNameIsTrez
MyNameIsTrez force-pushed the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch from 669c836 to d98dc96 Compare April 16, 2026 22:25
@stanleytsang-amd
stanleytsang-amd merged commit dd6042e into develop Apr 22, 2026
23 of 24 checks passed
@stanleytsang-amd
stanleytsang-amd deleted the users/mynameistrez/make-amdsmi-and-nvml-soft-dependencies branch April 22, 2026 14:33
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.

4 participants