Skip to content

Commit 716d3ff

Browse files
authored
Merge pull request #2099 from IntelPython/update_amd_build
Update HIP target handling using alias
2 parents 84a90dc + a8b9a1f commit 716d3ff

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

CMakeLists.txt

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ set(_dpctl_sycl_target_link_options)
5656

5757
set(_dpctl_sycl_targets)
5858
set(_dpctl_cuda_arch)
59-
set(_dpctl_amd_targets)
6059

6160
if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x")
6261
if (DPCTL_TARGET_CUDA)
@@ -73,42 +72,34 @@ if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x")
7372
set(_dpctl_sycl_targets "nvidia_gpu_${_dpctl_cuda_arch},spir64-unknown-unknown")
7473
endif()
7574

76-
if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x")
77-
set(_dpctl_amd_targets ${DPCTL_TARGET_HIP})
78-
if(_dpctl_sycl_targets)
79-
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}")
80-
else()
81-
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown")
82-
endif()
83-
else()
84-
if (DEFINED ENV{DPCTL_TARGET_HIP})
85-
set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP})
75+
if (DPCTL_TARGET_HIP)
76+
if(DPCTL_TARGET_HIP MATCHES "^gfx")
8677
if(_dpctl_sycl_targets)
87-
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}")
78+
set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},${_dpctl_sycl_targets}")
8879
else()
89-
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown")
80+
set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},spir64-unknown-unknown")
9081
endif()
82+
else()
83+
message(FATAL_ERROR
84+
"Invalid value for DPCTL_TARGET_HIP: \"${DPCTL_TARGET_HIP}\". "
85+
"Expected something starting with 'gfx', e.g. 'gfx1030'."
86+
)
9187
endif()
9288
endif()
9389
else()
94-
set(_dpctl_sycl_targets ${DPCTL_SYCL_TARGETS})
95-
if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x")
96-
set(_dpctl_amd_targets ${DPCTL_TARGET_HIP})
97-
else()
98-
if (DEFINED ENV{DPCTL_TARGET_HIP})
99-
set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP})
100-
endif()
90+
if ("${DPCTL_SYCL_TARGETS}" MATCHES "amdgcn-amd-amdhsa")
91+
message(FATAL_ERROR
92+
"Legacy target 'amdgcn-amd-amdhsa' is not supported. "
93+
"Use alias form 'amd_gpu_<arch>' instead."
94+
)
10195
endif()
96+
set(_dpctl_sycl_targets ${DPCTL_SYCL_TARGETS})
10297
endif()
10398

10499
if (_dpctl_sycl_targets)
105100
message(STATUS "Compiling for -fsycl-targets=${_dpctl_sycl_targets}")
106101
list(APPEND _dpctl_sycl_target_compile_options -fsycl-targets=${_dpctl_sycl_targets})
107102
list(APPEND _dpctl_sycl_target_link_options -fsycl-targets=${_dpctl_sycl_targets})
108-
if(_dpctl_amd_targets)
109-
list(APPEND _dpctl_sycl_target_compile_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets})
110-
list(APPEND _dpctl_sycl_target_link_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets})
111-
endif()
112103
endif()
113104

114105
add_subdirectory(libsyclinterface)

docs/doc_sources/beginners_guides/installation.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,24 @@ which requires specifying a compute architecture string:
197197

198198
.. code-block:: bash
199199
200-
python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030"
200+
python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=<arch>"
201201
202-
Note that the `oneAPI for AMD GPUs` plugin requires the architecture be specified and only
202+
Note that the `oneAPI for AMD GPUs` plugin requires the architecture be specified and only
203203
one architecture can be specified at a time.
204204

205+
To determine the architecture code (``<arch>``) for your AMD GPU, run:
206+
207+
.. code-block:: bash
208+
rocminfo | grep 'Name: *gfx.*'
209+
210+
This will print names like ``gfx90a``, ``gfx1030``, etc.
211+
You can then use one of them as the argument to ``-DDPCTL_TARGET_HIP``.
212+
213+
For example:
214+
215+
.. code-block:: bash
216+
python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030"
217+
205218
Multi-target build
206219
~~~~~~~~~~~~~~~~~~
207220

0 commit comments

Comments
 (0)