-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
175 lines (148 loc) · 5.41 KB
/
CMakeLists.txt
File metadata and controls
175 lines (148 loc) · 5.41 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
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
#
# Copyright 2021 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# This file creates the basic target(s) needed by all backends
#
assert_defined_targets( backend_headers_nodefs backend_flags )
assert_valid_variables( ALP_UTILS_LIBRARY_OUTPUT_NAME BACKEND_LIBRARY_OUTPUT_NAME VERSION
SHMEM_BACKEND_INSTALL_DIR
)
# convenience variable: a few tests need the path of utility sources
set( ALP_UTILS_SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/utils"
CACHE INTERNAL "ALP utility sources path"
)
# little utility library needed by backends
add_library( alp_utils_static STATIC
${ALP_UTILS_SRC_PATH}/hpparser.c
)
set_target_properties( alp_utils_static PROPERTIES
OUTPUT_NAME "${ALP_UTILS_LIBRARY_OUTPUT_NAME}"
)
target_compile_definitions( alp_utils_static PRIVATE _GNU_SOURCE )
target_link_libraries( alp_utils_static
PRIVATE Threads::Threads backend_flags
PUBLIC alp_utils_headers
)
install( TARGETS alp_utils_static
EXPORT GraphBLASTargets
ARCHIVE DESTINATION "${ALP_UTILS_INSTALL_DIR}"
)
add_library( alp_utils_dynamic SHARED
${ALP_UTILS_SRC_PATH}/hpparser.c
)
set_target_properties( alp_utils_dynamic PROPERTIES
OUTPUT_NAME "${ALP_UTILS_LIBRARY_OUTPUT_NAME}"
)
target_compile_definitions( alp_utils_dynamic PRIVATE _GNU_SOURCE )
target_link_libraries( alp_utils_dynamic
PRIVATE Threads::Threads backend_flags
PUBLIC alp_utils_headers
)
install( TARGETS alp_utils_dynamic
EXPORT GraphBLASTargets
LIBRARY DESTINATION "${ALP_UTILS_INSTALL_DIR}"
)
### ACTUAL BACKEND IMPLEMENTATIONS
# target to compile all backend libraries
add_custom_target( libs ALL )
# the sources common to all single-process (aka shmem) backends
set( backend_reference_srcs
${CMAKE_CURRENT_SOURCE_DIR}/descriptors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rc.cpp
)
# source files common to all BSP-based backends
set( backend_bsp_srcs
${CMAKE_CURRENT_SOURCE_DIR}/bsp/utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bsp/collectives.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bsp/exec_broadcast_routines.cpp
)
# include only selected backends
if( WITH_REFERENCE_BACKEND OR WITH_OMP_BACKEND )
add_subdirectory( reference )
endif()
if( WITH_HYPERDAGS_BACKEND )
add_subdirectory( hyperdags )
endif()
if( WITH_NONBLOCKING_BACKEND )
add_subdirectory( nonblocking )
endif()
if( WITH_BSP1D_BACKEND OR WITH_HYBRID_BACKEND )
add_subdirectory( bsp1d )
endif()
# macro to create a target for the shared memory library, with all minimal properties
#
# Parameters:
# targetName name of the target
# targetType type of library (STATIC or SHARED)
# outDir directory to compile the binary to (not install)
#
macro( make_reference_target targetName targetType outDir )
add_library( "${targetName}" "${targetType}"
"${backend_reference_srcs}"
)
set_target_properties( "${targetName}" PROPERTIES
OUTPUT_NAME "${BACKEND_LIBRARY_OUTPUT_NAME}"
)
if( "${targetType}" STREQUAL "SHARED" )
set_target_properties( "${targetName}" PROPERTIES
SOVERSION "${VERSION}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${outDir}"
)
elseif( "${targetType}" STREQUAL "STATIC" )
set_target_properties( "${targetName}" PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${outDir}"
)
else()
message( FATAL_ERROR "Unknown library type: ${targetType}")
endif()
target_link_libraries( "${targetName}" PRIVATE backend_flags )
endmacro( make_reference_target )
### BINARY-ONLY TARGETS: create the actual library with all code inside
### but storing only the minimum interface definitions (e.g. no OMP);
### no default backend is set!
if( WITH_REFERENCE_BACKEND OR WITH_OMP_BACKEND OR WITH_NONBLOCKING_BACKEND )
# alias target for basic propagation of headers and definitions
# from existing header target, which depends on the enabled backends;
# use the most advanced ones, i.e. those of reference_omp if available
if( WITH_OMP_BACKEND_HEADERS )
set( backend_shmem_base_headers backend_reference_omp_headers)
elseif( WITH_REFERENCE_BACKEND_HEADERS )
set( backend_shmem_base_headers backend_reference_headers )
endif()
## STATIC
make_reference_target( backend_shmem_static STATIC "shmem" )
target_link_libraries( backend_shmem_static PRIVATE ${backend_shmem_base_headers} )
if( WITH_NONBLOCKING_BACKEND )
target_link_libraries( backend_shmem_static PRIVATE ${backend_nonblocking_headers} )
endif()
# this is the actual binary file, i.e. the one to be installed
install( TARGETS backend_shmem_static
EXPORT GraphBLASTargets
ARCHIVE DESTINATION "${SHMEM_BACKEND_INSTALL_DIR}"
)
## DYNAMIC
make_reference_target( backend_shmem_shared SHARED "shmem" )
target_link_libraries( backend_shmem_shared PRIVATE ${backend_shmem_base_headers} )
if( WITH_NONBLOCKING_BACKEND )
target_link_libraries( backend_shmem_shared PRIVATE ${backend_nonblocking_headers} )
endif()
install( TARGETS backend_shmem_shared
EXPORT GraphBLASTargets
LIBRARY DESTINATION "${SHMEM_BACKEND_INSTALL_DIR}"
)
add_dependencies( libs backend_shmem_static )
add_dependencies( libs backend_shmem_shared )
endif()