Skip to content
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
26 changes: 26 additions & 0 deletions cmake/FindCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@ if(is_dpcpp)
list(APPEND UNIX_INTERFACE_LINK_OPTIONS
-fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend
--offload-arch=${HIP_TARGETS})
# Recent DPC++/LLVM defaults to AMD code object ABI version 6, which is
# only supported by ROCm 6.3+. When building against an older ROCm, fall
# back to code object version 5 so the ROCm device library can be found.
# See https://github.com/uxlfoundation/oneMath/issues/687
if(NOT CMAKE_CXX_FLAGS MATCHES "-mcode-object-version")
set(_onemath_rocm_version_file "")
foreach(_onemath_rocm_root "$ENV{ROCM_PATH}" "$ENV{HIPROOT}" "/opt/rocm")
if(_onemath_rocm_root AND EXISTS "${_onemath_rocm_root}/.info/version")
set(_onemath_rocm_version_file "${_onemath_rocm_root}/.info/version")
break()
endif()
endforeach()
if(_onemath_rocm_version_file)
file(READ "${_onemath_rocm_version_file}" _onemath_rocm_version)
string(STRIP "${_onemath_rocm_version}" _onemath_rocm_version)
if(_onemath_rocm_version MATCHES "^([0-9]+)\\.([0-9]+)")
set(_onemath_rocm_ver "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
if(_onemath_rocm_ver VERSION_LESS "6.3")
message(STATUS "Detected ROCm ${_onemath_rocm_ver} (< 6.3); "
"adding -mcode-object-version=5 for AMD targets")
list(APPEND UNIX_INTERFACE_COMPILE_OPTIONS -mcode-object-version=5)
list(APPEND UNIX_INTERFACE_LINK_OPTIONS -mcode-object-version=5)
endif()
endif()
endif()
endif()
endif()
if(ENABLE_CURAND_BACKEND OR ENABLE_CUSOLVER_BACKEND OR ENABLE_CUSPARSE_BACKEND OR ENABLE_ROCBLAS_BACKEND
OR ENABLE_ROCRAND_BACKEND OR ENABLE_ROCSOLVER_BACKEND OR ENABLE_ROCSPARSE_BACKEND)
Expand Down
16 changes: 16 additions & 0 deletions docs/building_the_project_with_dpcpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ A few often-used architectures are listed below:
For a host with ROCm installed, the device architecture can be retrieved via the
``rocminfo`` tool. The architecture will be displayed in the ``Name:`` row.

.. note::

Recent versions of the DPC++/LLVM compiler default to AMD code object ABI
version 6, which is only supported by ROCm 6.3 and higher. When building
against ROCm < 6.3 this results in an error such as::

clang++: error: cannot find ROCm device library for ABI version 6, which
requires ROCm 6.3 or higher

This is a toolchain (compiler/ROCm) compatibility issue and is not specific to
oneMath: it affects any HIP or SYCL-on-AMD application built with a recent
enough compiler. To build with ROCm < 6.3, downgrade the code object version
by adding ``-mcode-object-version=5`` to the compiler flags, for example::

cmake <build options> -DCMAKE_CXX_FLAGS="-mcode-object-version=5" ..

.. _build_for_other_SYCL_devices:

Building for other SYCL devices
Expand Down
Loading