Skip to content

Update HIP target handling using alias #2099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: update_cuda_build
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,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 MATCHES "^sm_")
Expand All @@ -76,41 +74,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}")
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_TARGET_HIP MATCHES "^gfx")
if(_dpctl_sycl_targets)
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}")
set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},${_dpctl_sycl_targets}")
else()
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown")
set(_dpctl_sycl_targets "amd_gpu_${DPCTL_TARGET_HIP},spir64-unknown-unknown")
endif()
else()
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})
else()
if (DEFINED ENV{DPCTL_TARGET_HIP})
set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP})
endif()
if ("${DPCTL_SYCL_TARGETS}" MATCHES "amdgcn-amd-amdhsa")
message(FATAL_ERROR
"Legacy target 'amdgcn-amd-amdhsa' is not supported. "
"Use alias form 'amd_gpu_<arch>' 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)
Expand Down
17 changes: 15 additions & 2 deletions docs/doc_sources/beginners_guides/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,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=<arch>"

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 (``<arch>``) 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:

Expand Down
Loading