Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit db3160d

Browse files
authored
Apply enable-global-offset just to NVIDIA and AMD targets (#519)
This patch restricts the application of the enable-global-offset flag just to NVIDIA and AMD targets since it could be not supported for other compilations.
1 parent c2fdf04 commit db3160d

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

CMakeLists.txt

+11-8
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,17 @@ if (INSTALL_HEADER_ONLY)
150150
check_cxx_compiler_flag("-fsycl" is_dpcpp)
151151
if(is_dpcpp)
152152
target_compile_definitions(portblas INTERFACE "SB_ENABLE_USM")
153-
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
154-
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
155-
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
156-
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
157-
target_link_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
158-
target_compile_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
159-
message(STATUS "Adding -mllvm=-enable-global-offset=false to portblas")
160-
endif()
153+
check_cxx_compiler_flag("-mllvm=-enable-global-offset=false" support_disable_global_offset)
154+
if (${support_disable_global_offset})
155+
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
156+
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
157+
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
158+
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
159+
target_link_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
160+
target_compile_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
161+
message(STATUS "Adding -mllvm=-enable-global-offset=false to portblas")
162+
endif()
163+
endif()
161164
endif()
162165
if(${BLAS_ENABLE_COMPLEX})
163166
target_compile_definitions(portblas INTERFACE "BLAS_ENABLE_COMPLEX")

cmake/Modules/FindDPCPP.cmake

+10-7
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,16 @@ function(add_sycl_to_target)
105105
target_link_options(${SB_ADD_SYCL_TARGET} PRIVATE -mllvm=-loopopt=0)
106106
message(STATUS "Adding -fno-fast-math -mllvm=-loopopt=0 to target ${SB_ADD_SYCL_TARGET}")
107107
endif()
108-
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
109-
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
110-
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
111-
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
112-
target_link_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
113-
target_compile_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
114-
message(STATUS "Adding -mllvm=-enable-global-offset=false to target ${SB_ADD_SYCL_TARGET}")
108+
if (${DPCPP_SYCL_TARGET} MATCHES "nvidia" OR ${DPCPP_SYCL_TARGET} MATCHES "amd")
109+
# Apply only in case of NVIDIA_GPU and AMD_GPU targets.
110+
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
111+
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
112+
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
113+
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
114+
target_link_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
115+
target_compile_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
116+
message(STATUS "Adding -mllvm=-enable-global-offset=false to target ${SB_ADD_SYCL_TARGET}")
117+
endif()
115118
endif()
116119
target_compile_options(${SB_ADD_SYCL_TARGET} PUBLIC ${DPCPP_FLAGS})
117120
get_target_property(target_type ${SB_ADD_SYCL_TARGET} TYPE)

0 commit comments

Comments
 (0)