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

Commit

Permalink
Apply enable-global-offset just to NVIDIA and AMD targets (#519)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pgorlani authored May 31, 2024
1 parent c2fdf04 commit db3160d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
19 changes: 11 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,17 @@ if (INSTALL_HEADER_ONLY)
check_cxx_compiler_flag("-fsycl" is_dpcpp)
if(is_dpcpp)
target_compile_definitions(portblas INTERFACE "SB_ENABLE_USM")
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
target_link_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
target_compile_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
message(STATUS "Adding -mllvm=-enable-global-offset=false to portblas")
endif()
check_cxx_compiler_flag("-mllvm=-enable-global-offset=false" support_disable_global_offset)
if (${support_disable_global_offset})
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
target_link_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
target_compile_options(portblas INTERFACE "-mllvm=-enable-global-offset=false")
message(STATUS "Adding -mllvm=-enable-global-offset=false to portblas")
endif()
endif()
endif()
if(${BLAS_ENABLE_COMPLEX})
target_compile_definitions(portblas INTERFACE "BLAS_ENABLE_COMPLEX")
Expand Down
17 changes: 10 additions & 7 deletions cmake/Modules/FindDPCPP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@ function(add_sycl_to_target)
target_link_options(${SB_ADD_SYCL_TARGET} PRIVATE -mllvm=-loopopt=0)
message(STATUS "Adding -fno-fast-math -mllvm=-loopopt=0 to target ${SB_ADD_SYCL_TARGET}")
endif()
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
target_link_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
target_compile_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
message(STATUS "Adding -mllvm=-enable-global-offset=false to target ${SB_ADD_SYCL_TARGET}")
if (${DPCPP_SYCL_TARGET} MATCHES "nvidia" OR ${DPCPP_SYCL_TARGET} MATCHES "amd")
# Apply only in case of NVIDIA_GPU and AMD_GPU targets.
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2024.1)
OR NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM")
# Apply only for oneAPI releases >= 2024.1 OR for intel/llvm.
target_link_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
target_compile_options(${SB_ADD_SYCL_TARGET} PRIVATE "-mllvm=-enable-global-offset=false")
message(STATUS "Adding -mllvm=-enable-global-offset=false to target ${SB_ADD_SYCL_TARGET}")
endif()
endif()
target_compile_options(${SB_ADD_SYCL_TARGET} PUBLIC ${DPCPP_FLAGS})
get_target_property(target_type ${SB_ADD_SYCL_TARGET} TYPE)
Expand Down

0 comments on commit db3160d

Please sign in to comment.