From 8ab60e4ab812b943346a638ae2b6023feed15b24 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 5 Jun 2025 07:41:35 -0700 Subject: [PATCH 1/4] Clean up DPCTL_TARGET_HIP handling --- CMakeLists.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 125621d94d..67a66f084e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,24 +80,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 7330a00d19cf657672173f6e8637f877c56f83fc Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 6 Jun 2025 06:05:03 -0700 Subject: [PATCH 2/4] 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 67a66f084e..8111f6bb85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,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 (DPCTL_TARGET_CUDA) @@ -74,28 +73,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 73e4c90c282b1fc54f06cf57ee7109c8b6a59f78 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 6 Jun 2025 06:10:20 -0700 Subject: [PATCH 3/4] 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 2e1734134d..6592554094 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -197,11 +197,24 @@ which requires specifying a compute architecture string: .. 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" + Multi-target build ~~~~~~~~~~~~~~~~~~ From 499eeeddac72697ca58b7c20c87cf1d96d9b90ec Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 20 Jun 2025 02:03:20 -0700 Subject: [PATCH 4/4] Allow negative values for DPCTL_TARGET_HIP --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8111f6bb85..7d95176d12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x") set(_dpctl_sycl_targets "nvidia_gpu_${_dpctl_cuda_arch},spir64-unknown-unknown") endif() - if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x") + if (DPCTL_TARGET_HIP) if(DPCTL_TARGET_HIP MATCHES "^gfx") if(_dpctl_sycl_targets) set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},${_dpctl_sycl_targets}")