From 184814d19df866726f47a2d403915de641cd08a4 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 5 Jun 2025 07:41:35 -0700 Subject: [PATCH 1/3] Clean up DPCTL_TARGET_HIP handling --- CMakeLists.txt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f11cb95c6b..cc68947d15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x") endif() set(_dpctl_sycl_targets "nvidia_gpu_${_dpctl_cuda_arch},spir64-unknown-unknown") endif() + if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x") set(_dpctl_amd_targets ${DPCTL_TARGET_HIP}) if(_dpctl_sycl_targets) @@ -75,24 +76,11 @@ if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x") else() set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown") endif() - else() - if (DEFINED ENV{DPCTL_TARGET_HIP}) - set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP}) - if(_dpctl_sycl_targets) - set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}") - else() - set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown") - endif() - endif() endif() else() set(_dpctl_sycl_targets ${DPCTL_SYCL_TARGETS}) if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x") set(_dpctl_amd_targets ${DPCTL_TARGET_HIP}) - else() - if (DEFINED ENV{DPCTL_TARGET_HIP}) - set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP}) - endif() endif() endif() From 79b7ab573208e604d54c752915a83b79852b5a48 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 6 Jun 2025 06:05:03 -0700 Subject: [PATCH 2/3] Simplify DPCTL_TARGET_HIP handling using aliases --- CMakeLists.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc68947d15..4ed49a7d0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,6 @@ set(_dpctl_sycl_target_link_options) set(_dpctl_sycl_targets) set(_dpctl_cuda_arch) -set(_dpctl_amd_targets) if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x") if (NOT "x${DPCTL_TARGET_CUDA}" STREQUAL "x") if (DPCTL_TARGET_CUDA STREQUAL "ON") @@ -70,28 +69,33 @@ if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x") endif() if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x") - set(_dpctl_amd_targets ${DPCTL_TARGET_HIP}) - if(_dpctl_sycl_targets) - set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}") + if(DPCTL_TARGET_HIP MATCHES "^gfx") + if(_dpctl_sycl_targets) + set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},${_dpctl_sycl_targets}") + else() + set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},spir64-unknown-unknown") + endif() else() - set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown") + message(FATAL_ERROR + "Invalid value for DPCTL_TARGET_HIP: \"${DPCTL_TARGET_HIP}\". " + "Expected something starting with 'gfx', e.g. 'gfx1030'." + ) endif() endif() else() - set(_dpctl_sycl_targets ${DPCTL_SYCL_TARGETS}) - if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x") - set(_dpctl_amd_targets ${DPCTL_TARGET_HIP}) + if ("${DPCTL_SYCL_TARGETS}" MATCHES "amdgcn-amd-amdhsa") + message(FATAL_ERROR + "Legacy target 'amdgcn-amd-amdhsa' is not supported. " + "Use alias form 'amd_gpu_' instead." + ) endif() + set(_dpctl_sycl_targets ${DPCTL_SYCL_TARGETS}) endif() if (_dpctl_sycl_targets) message(STATUS "Compiling for -fsycl-targets=${_dpctl_sycl_targets}") list(APPEND _dpctl_sycl_target_compile_options -fsycl-targets=${_dpctl_sycl_targets}) list(APPEND _dpctl_sycl_target_link_options -fsycl-targets=${_dpctl_sycl_targets}) - if(_dpctl_amd_targets) - list(APPEND _dpctl_sycl_target_compile_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets}) - list(APPEND _dpctl_sycl_target_link_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets}) - endif() endif() add_subdirectory(libsyclinterface) From 3bfba7e2d18b24cd7781478c61177a2409a5dbcf Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 6 Jun 2025 06:10:20 -0700 Subject: [PATCH 3/3] Update docs to clarify AMD build selection --- .../beginners_guides/installation.rst | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/doc_sources/beginners_guides/installation.rst b/docs/doc_sources/beginners_guides/installation.rst index 7bc8410058..617c3fc1d3 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -187,11 +187,24 @@ To build for AMD devices, use: .. code-block:: bash - python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030" + python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=" -Note that the `oneAPI for AMD GPUs` plugin requires the architecture be specified and only +Note that the `oneAPI for AMD GPUs` plugin requires the architecture be specified and only one architecture can be specified at a time. +To determine the architecture code (````) for your AMD GPU, run: + +.. code-block:: bash + rocminfo | grep 'Name: *gfx.*' + +This will print names like ``gfx90a``, ``gfx1030``, etc. +You can then use one of them as the argument to ``-DDPCTL_TARGET_HIP``. + +For example: + +.. code-block:: bash + python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030" + It is, however, possible to build for Intel devices, CUDA devices, and an AMD device architecture all at once: