forked from celerity/celerity-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
191 lines (166 loc) · 4.81 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
cmake_minimum_required(VERSION 3.5.1)
project(celerity_runtime)
set(Celerity_VERSION 0.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
find_package(Boost 1.65.0 REQUIRED)
find_package(MPI 2.0 REQUIRED)
find_package(Threads REQUIRED)
# Find SYCL implementation.
# We first check if hipSYCL can be found, otherwise we try ComputeCpp.
find_package(hipSYCL CONFIG)
if(NOT hipSYCL_FOUND)
find_package(ComputeCpp REQUIRED)
if(NOT COMPUTECPP_USER_FLAGS MATCHES "-D_CRT_SECURE_NO_WARNINGS")
set(
COMPUTECPP_USER_FLAGS "${COMPUTECPP_USER_FLAGS};-D_CRT_SECURE_NO_WARNINGS=1"
CACHE STRING "" FORCE
)
endif()
endif()
include(Download_spdlog)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake Build Type" FORCE)
endif()
if(MSVC)
# Add includes to library so they show up in generated VS project
file(GLOB_RECURSE INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
endif()
if(CMAKE_GENERATOR STREQUAL "Ninja")
# Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support.
# Rationale in https://github.com/ninja-build/ninja/issues/814
set(CMAKE_SYCL_FLAGS "${CMAKE_SYCL_FLAGS} -fdiagnostics-color=always")
endif()
set(SOURCES
src/buffer_transfer_manager.cc
src/command_graph.cc
src/config.cc
src/device_queue.cc
src/executor.cc
src/graph_generator.cc
src/graph_serializer.cc
src/mpi_support.cc
src/print_graph.cc
src/runtime.cc
src/scheduler.cc
src/task.cc
src/task_manager.cc
src/transformers/naive_split.cc
src/user_bench.cc
src/worker_job.cc
)
add_library(
celerity_runtime
STATIC
${SOURCES}
${INCLUDES}
)
set_property(TARGET celerity_runtime PROPERTY CXX_STANDARD 14)
target_include_directories(
celerity_runtime
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/celerity>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor>
$<INSTALL_INTERFACE:include/celerity/vendor>
${Boost_INCLUDE_DIRS}
${ComputeCpp_INCLUDE_DIRECTORY}
${MPI_CXX_INCLUDE_PATH}
$<BUILD_INTERFACE:${spdlog_INCLUDE_DIRS}>
)
target_link_libraries(
celerity_runtime
PUBLIC
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${MPI_CXX_LIBRARIES}
)
set(DEVICE_SOURCES "")
if(hipSYCL_FOUND)
# For hipSYCL we have to pass all source files into add_sycl_to_target
# Don't just do it in general (yields better ComputeCpp build performance)
set(DEVICE_SOURCES ${SOURCES})
endif()
add_sycl_to_target(
TARGET celerity_runtime
SOURCES ${DEVICE_SOURCES}
)
if(MSVC)
target_compile_options(celerity_runtime PRIVATE /MP /W3 /D_CRT_SECURE_NO_WARNINGS)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
target_compile_options(celerity_runtime PRIVATE -Wall -Wextra -Wno-unused-parameter)
endif()
if(hipSYCL_FOUND)
# Boost currently (as of 1.71) does not enable variadic macros
# when it detects CUDA compilation.
# Since we are using Clang however (via hipSYCL) instead of NVCC,
# the macros can and should be enabled.
# See https://github.com/boostorg/preprocessor/issues/24
target_compile_definitions(celerity_runtime PUBLIC BOOST_PP_VARIADICS=1)
endif()
# Examples
option(CELERITY_BUILD_EXAMPLES "Build various example applications" ON)
if(CELERITY_BUILD_EXAMPLES)
add_subdirectory(examples/convolution)
add_subdirectory(examples/matmul)
add_subdirectory(examples/syncing)
add_subdirectory(examples/wave_sim)
set_property(
TARGET convolution matmul syncing wave_sim
PROPERTY FOLDER "examples"
)
endif()
# Tests
enable_testing(true)
add_subdirectory(test)
# Install
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include/celerity/celerity
)
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/allscale/
DESTINATION include/celerity/vendor/allscale
)
install(
FILES ${PROJECT_SOURCE_DIR}/vendor/ctpl.h
DESTINATION include/celerity/vendor
)
install(
DIRECTORY ${spdlog_INCLUDE_DIRS}/spdlog/
DESTINATION include/celerity/vendor/spdlog
)
install(
TARGETS celerity_runtime
EXPORT install_exports
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/celerity-config-version.cmake"
VERSION ${Celerity_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
EXPORT install_exports
FILE "celerity-targets.cmake"
NAMESPACE Celerity::
DESTINATION lib/cmake
)
set(CELERITY_INSTALL_LOCATION ${CMAKE_INSTALL_PREFIX})
if(hipSYCL_FOUND)
set(CELERITY_SYCL_IMPL "hipSYCL")
else()
set(CELERITY_SYCL_IMPL "ComputeCpp")
endif()
configure_file(
${PROJECT_SOURCE_DIR}/cmake/celerity-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/celerity-config.cmake
@ONLY
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/celerity-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/celerity-config-version.cmake
DESTINATION lib/cmake
)