-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
81 lines (68 loc) · 2.67 KB
/
CMakeLists.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cmake_minimum_required(VERSION 3.5)
project(device_submodule)
#set(CMAKE_CXX_CLANG_TIDY clang-tidy)
option(USE_GRAPH_CAPTURING "Enable graph capturing (if it is supported)" ON)
# check INTERFACE
if (NOT DEFINED DEVICE_BACKEND)
message(FATAL_ERROR "DEVICE_BACKEND variable has not been provided into the submodule")
else()
set(FOUND OFF)
foreach(VARIANT cuda hip oneapi hipsycl)
if (${DEVICE_BACKEND} STREQUAL ${VARIANT})
set(FOUND ON)
endif()
endforeach()
if (NOT FOUND)
message(FATAL_ERROR "DEVICE_BACKEND must be either cuda, hip, opeapi, or hipsycl. Given: ${DEVICE_BACKEND}")
endif()
endif()
if (NOT DEFINED DEVICE_ARCH)
message(FATAL_ERROR "DEVICE_ARCH is not defined. "
"Supported for example: sm_60, sm_61, sm_70, sm_71, gfx906, gfx908, dg1, bdw, skl, Gen8, Gen9, Gen11, Gen12LP")
endif()
#check REAL_SIZE
if (NOT DEFINED REAL_SIZE_IN_BYTES)
message(FATAL_ERROR "REAL_SIZE_IN_BYTES variable has not been provided into the submodule")
else()
set(FOUND OFF)
foreach(VARIANT 4 8)
if (${REAL_SIZE_IN_BYTES} EQUAL ${VARIANT})
set(FOUND ON)
endif()
endforeach()
if (NOT FOUND)
message(FATAL_ERROR "REAL_SIZE_IN_BYTES must be either 4 or 8. Given: ${REAL_SIZE}")
endif()
endif()
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
option(ENABLE_PROFILING_MARKERS "Enable profiling markers (if available)" OFF)
string(TOLOWER ${DEVICE_BACKEND} BACKEND_FOLDER)
string(TOUPPER ${DEVICE_BACKEND} BACKEND_UPPER_CASE)
# define device library
if (${DEVICE_BACKEND} STREQUAL "cuda")
set(BACKEND_FOLDER "cuda")
include(cuda.cmake)
elseif(${DEVICE_BACKEND} STREQUAL "hip")
set(BACKEND_FOLDER "hip")
include(hip.cmake)
elseif((${DEVICE_BACKEND} STREQUAL "oneapi") OR (${DEVICE_BACKEND} STREQUAL "hipsycl"))
set(BACKEND_FOLDER "sycl")
include(sycl.cmake)
endif()
# common options
target_compile_features(device PRIVATE cxx_std_17)
if (USE_GRAPH_CAPTURING)
target_compile_definitions(device PRIVATE DEVICE_USE_GRAPH_CAPTURING)
endif()
if (ENABLE_PROFILING_MARKERS)
target_compile_definitions(device PRIVATE PROFILING_ENABLED)
endif()
target_compile_definitions(device PRIVATE DEVICE_${BACKEND_UPPER_CASE}_LANG REAL_SIZE=${REAL_SIZE_IN_BYTES})
if (LOG_LEVEL_MASTER)
target_compile_definitions(device PRIVATE LOG_LEVEL=${LOG_LEVEL_MASTER})
endif()
target_include_directories(device PRIVATE .
interfaces/${BACKEND_FOLDER}
interfaces/common
algorithms/${BACKEND_FOLDER}
submodules)