Skip to content

Commit b10bd15

Browse files
Validate HIP_TARGETS format and allow negative values (#2481)
This PR suggests validating the format of `HIP_TARGETS` (set via `--target-hip`) to ensure it starts with `gfx` (e.g., `gfx1030`). It also allows users to explicitly indicate that no AMD target should be used by passing values like `--target-hip=OFF` or `--target-hip=FALSE` matching the default behavior
1 parent 32e1b4e commit b10bd15

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Changed
1414

1515
* Adjusted the `pre-commit` configuration to run autoupdate weekly [#2479](https://github.com/IntelPython/dpnp/pull/2479)
16+
* Improved validation of `--target-hip` build option to only accept a gfx-prefixed value [#2481](https://github.com/IntelPython/dpnp/pull/2481)
1617

1718
### Fixed
1819

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,19 @@ if ("x${DPNP_SYCL_TARGETS}" STREQUAL "x")
106106
set(_use_onemkl_interfaces_cuda ON)
107107
endif()
108108

109-
if (NOT "x${HIP_TARGETS}" STREQUAL "x")
110-
set(_use_onemkl_interfaces_hip ON)
111-
112-
if ("x${_dpnp_sycl_targets}" STREQUAL "x")
113-
set(_dpnp_sycl_targets "amd_gpu_${HIP_TARGETS},spir64-unknown-unknown")
109+
if (HIP_TARGETS)
110+
if (HIP_TARGETS MATCHES "^gfx")
111+
if ("x${_dpnp_sycl_targets}" STREQUAL "x")
112+
set(_dpnp_sycl_targets "amd_gpu_${HIP_TARGETS},spir64-unknown-unknown")
113+
else()
114+
set(_dpnp_sycl_targets "amd_gpu_${HIP_TARGETS},${_dpnp_sycl_targets}")
115+
endif()
116+
set(_use_onemkl_interfaces_hip ON)
114117
else()
115-
set(_dpnp_sycl_targets "amd_gpu_${HIP_TARGETS},${_dpnp_sycl_targets}")
118+
message(FATAL_ERROR
119+
"Invalid value for HIP_TARGETS: \"${HIP_TARGETS}\". "
120+
"Expected an architecture name starting with 'gfx', e.g. 'gfx1030'."
121+
)
116122
endif()
117123
endif()
118124
else()

0 commit comments

Comments
 (0)