|
6 | 6 | message(CHECK_START "Looking for DPC++") |
7 | 7 | unset(missingDpcppComponents) |
8 | 8 |
|
9 | | -cmake_path(CONVERT "${CMAKE_CXX_COMPILER}" TO_CMAKE_PATH_LIST compiler_path) |
10 | | -cmake_path(GET compiler_path PARENT_PATH compiler_bin_dir) |
11 | | -cmake_path(GET compiler_bin_dir PARENT_PATH compiler_root_dir) |
| 9 | +find_package(IntelSYCL QUIET) |
| 10 | +if (IntelSYCL_FOUND) |
| 11 | + set(DPCPP_FOUND TRUE) |
| 12 | + set(DPCPP_FLAGS "${SYCL_FLAGS}") |
| 13 | + set(DPCPP_INCLUDE_DIRS "${SYCL_INCLUDE_DIR};${SYCL_INCLUDE_SYCL_DIR}") |
| 14 | + set(DPCPP_LIBRARIES "${SYCL_LIBRARY}") |
| 15 | +else() |
| 16 | + cmake_path(CONVERT "${CMAKE_CXX_COMPILER}" TO_CMAKE_PATH_LIST cxx_path) |
| 17 | + cmake_path(GET cxx_path PARENT_PATH cxx_bin_dir) |
| 18 | + cmake_path(GET cxx_bin_dir PARENT_PATH cxx_root_dir) |
12 | 19 |
|
13 | | -find_path( |
14 | | - SYCL_INCLUDE_DIRS |
15 | | - NAMES |
16 | | - sycl/sycl.hpp |
17 | | - PATHS |
18 | | - ENV SYCL_ROOT |
19 | | - /opt/intel/oneapi/compiler/latest/linux |
20 | | - ${SYCL_ROOT} |
21 | | - ${compiler_root_dir} |
22 | | - PATH_SUFFIXES |
23 | | - include |
24 | | - include/sycl |
25 | | - include/CL |
26 | | - include/sycl/CL |
27 | | -) |
| 20 | + find_path( |
| 21 | + DPCPP_INCLUDE_DIRS |
| 22 | + NAMES |
| 23 | + sycl/sycl.hpp |
| 24 | + PATHS |
| 25 | + ENV SYCL_ROOT |
| 26 | + ${SYCL_ROOT} |
| 27 | + ENV CMPLR_ROOT |
| 28 | + ${cxx_root_dir} |
| 29 | + PATH_SUFFIXES |
| 30 | + include |
| 31 | + include/sycl |
| 32 | + include/CL |
| 33 | + include/sycl/CL |
| 34 | + ) |
| 35 | + set(DPCPP_INCLUDE_DIRS "${DPCPP_INCLUDE_DIRS};${DPCPP_INCLUDE_DIRS}/sycl") |
28 | 36 |
|
29 | | -find_library( |
30 | | - SYCL_LIBRARIES |
31 | | - NAMES |
32 | | - sycl libsycl |
33 | | - PATHS |
34 | | - ENV SYCL_ROOT |
35 | | - /opt/intel/oneapi/compiler/latest/linux |
36 | | - ${SYCL_ROOT} |
37 | | - ${compiler_root_dir} |
38 | | - PATH_SUFFIXES |
39 | | - lib |
40 | | -) |
| 37 | + find_library( |
| 38 | + DPCPP_LIBRARIES |
| 39 | + NAMES |
| 40 | + sycl libsycl |
| 41 | + PATHS |
| 42 | + ENV SYCL_ROOT |
| 43 | + ${SYCL_ROOT} |
| 44 | + ENV CMPLR_ROOT |
| 45 | + ${cxx_root_dir} |
| 46 | + PATH_SUFFIXES |
| 47 | + lib |
| 48 | + ) |
41 | 49 |
|
42 | | -if(NOT OCCA_DPCPP_COMPILER_FLAGS) |
43 | | - if(DEFINED ENV{OCCA_DPCPP_COMPILER_FLAGS}) |
44 | | - set(SYCL_FLAGS $ENV{OCCA_DPCPP_COMPILER_FLAGS}) |
45 | | - else() |
46 | | - set(SYCL_FLAGS -fsycl) |
47 | | - endif() |
| 50 | + set(DPCPP_FLAGS -fsycl) |
48 | 51 | endif() |
49 | 52 |
|
| 53 | +if (NOT SYCL_FLAGS) |
| 54 | + set(DPCPP_FLAGS SYCL_FLAGS) |
| 55 | +endif() |
| 56 | +# TODO: Check if the backend compiler supports DPCPP_FLAGS |
| 57 | + |
50 | 58 | include(FindPackageHandleStandardArgs) |
51 | 59 | find_package_handle_standard_args( |
52 | | - DPCPP |
53 | | - REQUIRED_VARS |
54 | | - SYCL_INCLUDE_DIRS |
55 | | - SYCL_LIBRARIES |
56 | | - SYCL_FLAGS |
57 | | - ) |
| 60 | + DPCPP |
| 61 | + REQUIRED_VARS |
| 62 | + DPCPP_INCLUDE_DIRS |
| 63 | + DPCPP_LIBRARIES |
| 64 | + DPCPP_FLAGS |
| 65 | +) |
58 | 66 |
|
59 | | -if(DPCPP_FOUND AND NOT TARGET OCCA::depends::DPCPP) |
| 67 | +if (DPCPP_FOUND AND NOT TARGET OCCA::depends::DPCPP) |
60 | 68 | # Create our wrapper imported target |
61 | 69 | # Put it in the OCCA namespace to make it clear that we created it. |
62 | 70 | add_library(OCCA::depends::DPCPP INTERFACE IMPORTED) |
63 | | - separate_arguments(SYCL_FLAGS UNIX_COMMAND "${SYCL_FLAGS}") |
64 | | - target_compile_options(OCCA::depends::DPCPP INTERFACE ${SYCL_FLAGS}) |
| 71 | + separate_arguments(DPCPP_FLAGS UNIX_COMMAND "${DPCPP_FLAGS}") |
| 72 | + target_compile_options(OCCA::depends::DPCPP INTERFACE ${DPCPP_FLAGS}) |
65 | 73 | set_target_properties(OCCA::depends::DPCPP PROPERTIES |
66 | | - INTERFACE_INCLUDE_DIRECTORIES "${SYCL_INCLUDE_DIRS};${SYCL_INCLUDE_DIRS}/sycl" |
67 | | - INTERFACE_LINK_LIBRARIES "${SYCL_LIBRARIES}" |
| 74 | + INTERFACE_INCLUDE_DIRECTORIES "${DPCPP_INCLUDE_DIRS}" |
| 75 | + INTERFACE_LINK_LIBRARIES "${DPCPP_LIBRARIES}" |
68 | 76 | ) |
69 | 77 | endif() |
0 commit comments