-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsycl.cmake
More file actions
62 lines (56 loc) · 2.66 KB
/
sycl.cmake
File metadata and controls
62 lines (56 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SPDX-FileCopyrightText: 2021 SeisSol Group
#
# SPDX-License-Identifier: BSD-3-Clause
set(DEVICE_SOURCE_FILES device.cpp
interfaces/sycl/Control.cpp
interfaces/sycl/Copy.cpp
interfaces/sycl/Events.cpp
interfaces/sycl/Graphs.cpp
interfaces/sycl/Memory.cpp
interfaces/sycl/Streams.cpp
interfaces/sycl/DeviceContext.cpp
interfaces/sycl/DeviceCircularQueueBuffer.cpp
interfaces/sycl/DeviceType.cpp
algorithms/sycl/ArrayManip.cpp
algorithms/sycl/BatchManip.cpp
algorithms/sycl/Debugging.cpp
algorithms/sycl/Reduction.cpp
)
add_library(device ${DEVICE_LIBTYPE} ${DEVICE_SOURCE_FILES})
if ((${DEVICE_BACKEND} STREQUAL "acpp") OR (${DEVICE_BACKEND} STREQUAL "hipsycl"))
if (DEVICE_ARCH MATCHES "sm_*")
if (CMAKE_CXX_COMPILER_ID MATCHES "NVHPC|PGI")
set(SYCL_USE_NVHPC_DEFAULT ON)
else()
set(SYCL_USE_NVHPC_DEFAULT OFF)
endif()
option(SYCL_USE_NVHPC "For Nvidia GPUs, use nvhpc instead of CUDA/nvcc." ${SYCL_USE_NVHPC_DEFAULT})
if (SYCL_USE_NVHPC)
# we assume that hipsycl was compiled with nvhpc compiler collection
string(REPLACE sm_ cc NVCPP_ARCH ${DEVICE_ARCH})
set(HIPSYCL_TARGETS "cuda-nvcxx:${NVCPP_ARCH}" CACHE STRING "" FORCE)
set(ACPP_TARGETS "cuda-nvcxx:${NVCPP_ARCH}" CACHE STRING "" FORCE)
else()
set(HIPSYCL_TARGETS "cuda:${DEVICE_ARCH}" CACHE STRING "" FORCE)
set(ACPP_TARGETS "cuda:${DEVICE_ARCH}" CACHE STRING "" FORCE)
target_compile_options(device PRIVATE -Wno-unknown-cuda-version)
endif()
elseif(DEVICE_ARCH MATCHES "gfx*")
set(HIPSYCL_TARGETS "hip:${DEVICE_ARCH}" CACHE STRING "" FORCE)
set(ACPP_TARGETS "hip:${DEVICE_ARCH}" CACHE STRING "" FORCE)
else()
set(HIPSYCL_TARGETS "${DEVICE_BACKEND}:${DEVICE_ARCH}" CACHE STRING "" FORCE)
set(ACPP_TARGETS "${DEVICE_BACKEND}:${DEVICE_ARCH}" CACHE STRING "" FORCE)
endif()
# hipSYCL or OpenSYCL is deemed to old now. If you _really_ should need it, look for the package right here.
find_package(AdaptiveCpp REQUIRED)
find_package(OpenMP REQUIRED)
target_compile_options(device PRIVATE -Wno-unknown-cuda-version)
# we need to link both to OpenMP_CXX and the OpenMP_CXX_FLAGS (otherwise some symbols won't be found)
target_link_libraries(device PRIVATE OpenMP::OpenMP_CXX)
target_link_libraries(device PRIVATE ${OpenMP_CXX_FLAGS})
add_sycl_to_target(TARGET device SOURCES ${DEVICE_SOURCE_FILES})
else()
find_package(DpcppFlags REQUIRED)
target_link_libraries(device PRIVATE dpcpp::device_flags)
endif()