Skip to content

Commit

Permalink
[cmake] Allow to use clang++ -fsycl (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rbiessy authored Mar 4, 2025
1 parent b8b5244 commit 620fe8d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
9 changes: 8 additions & 1 deletion cmake/FindCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ check_cxx_compiler_flag("-fsycl" is_dpcpp)
if(is_dpcpp)
# Workaround for internal compiler error during linking if -fsycl is used
get_filename_component(SYCL_BINARY_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
find_library(SYCL_LIBRARY NAMES sycl PATHS "${SYCL_BINARY_DIR}/../lib" "${SYCL_BINARY_DIR}/lib" ENV LIBRARY_PATH ENV PATH)
find_library(SYCL_LIBRARY NAMES sycl
PATHS
"${SYCL_BINARY_DIR}/lib"
"${SYCL_BINARY_DIR}/../lib"
"${SYCL_BINARY_DIR}/../../lib"
ENV LIBRARY_PATH
ENV PATH
)
if(NOT SYCL_LIBRARY)
message(FATAL_ERROR "SYCL library is not found in ${SYCL_BINARY_DIR}/../lib, PATH, and LIBRARY_PATH")
endif()
Expand Down
13 changes: 7 additions & 6 deletions cmake/FindcuBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ find_package(CUDA 10.0 REQUIRED)
get_filename_component(SYCL_BINARY_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
# the OpenCL include file from cuda is opencl 1.1 and it is not compatible with DPC++
# the OpenCL include headers 1.2 onward is required. This is used to bypass NVIDIA OpenCL headers
find_path(OPENCL_INCLUDE_DIR CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/sycl/
${SYCL_BINARY_DIR}/../../include/sycl/
${SYCL_BINARY_DIR}/../include/
find_path(OPENCL_INCLUDE_DIR
NAMES CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/
${SYCL_BINARY_DIR}/../../include/
PATH_SUFFIXES sycl
)
# this is work around to avoid duplication half creation in both cuda and SYCL
add_compile_definitions(CUDA_NO_HALF)
Expand Down
12 changes: 7 additions & 5 deletions cmake/FindcuRAND.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ get_filename_component(SYCL_BINARY_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
if (NOT (ONEMATH_SYCL_IMPLEMENTATION STREQUAL "hipsycl"))
# the OpenCL include file from cuda is opencl 1.1 and it is not compatible with DPC++
# the OpenCL include headers 1.2 onward is required. This is used to bypass NVIDIA OpenCL headers
find_path(OPENCL_INCLUDE_DIR CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/sycl/
${SYCL_BINARY_DIR}/../include/
find_path(OPENCL_INCLUDE_DIR
NAMES CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/
${SYCL_BINARY_DIR}/../../include/
PATH_SUFFIXES sycl
)
endif()

Expand Down
12 changes: 7 additions & 5 deletions cmake/FindcuSOLVER.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ find_package(CUDA 10.0 REQUIRED)
get_filename_component(SYCL_BINARY_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
# the OpenCL include file from cuda is opencl 1.1 and it is not compatible with DPC++
# the OpenCL include headers 1.2 onward is required. This is used to bypass NVIDIA OpenCL headers
find_path(OPENCL_INCLUDE_DIR CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/sycl/
${SYCL_BINARY_DIR}/../include/
find_path(OPENCL_INCLUDE_DIR
NAMES CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/
${SYCL_BINARY_DIR}/../../include/
PATH_SUFFIXES sycl
)
# this is work around to avoid duplication half creation in both cuda and SYCL
add_compile_definitions(CUDA_NO_HALF)
Expand Down

0 comments on commit 620fe8d

Please sign in to comment.