-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
257 lines (216 loc) · 10.5 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# cmake lists for building CnC
cmake_minimum_required (VERSION 2.8.7)
project(CnC)
# include common defs
include( "CMake.inc" )
################################################################################
# options
option(BUILD_LIBS_FOR_MPI "Build additional libraries for using MPI-communication on distributed memory" FALSE)
option(BUILD_LIBS_FOR_ITAC "Build additional libraries for performance analysis with ITAC" FALSE)
option(CNC_PRODUCT_BUILD "Build an \"official\" binary release" FALSE)
################################################################################
# Project paths
set(CNC_SRC_ROOT ${CMAKE_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH "bin/${PARCH}")
set(LIBRARY_OUTPUT_PATH "lib/${PARCH}")
################################################################################
# source files for different libs
set( CNC_BASE_SOURCES "${CNC_SRC_ROOT}/src/dist/Buffer.cpp"
"${CNC_SRC_ROOT}/src/chronometer.cpp"
"${CNC_SRC_ROOT}/src/context_base.cpp"
"${CNC_SRC_ROOT}/src/debug.cpp"
"${CNC_SRC_ROOT}/src/dist/dist_init.cpp"
"${CNC_SRC_ROOT}/src/dist/distributable_context.cpp"
"${CNC_SRC_ROOT}/src/dist/distributor.cpp"
"${CNC_SRC_ROOT}/src/dist/factory.cpp"
"${CNC_SRC_ROOT}/src/item_collection_i.cpp"
"${CNC_SRC_ROOT}/src/scheduler_i.cpp"
"${CNC_SRC_ROOT}/src/simplest_scheduler.cpp"
"${CNC_SRC_ROOT}/src/statistics.cpp"
"${CNC_SRC_ROOT}/src/step_launcher_i.cpp"
"${CNC_SRC_ROOT}/src/step_instance_base.cpp"
"${CNC_SRC_ROOT}/src/tag_collection_i.cpp"
"${CNC_SRC_ROOT}/src/tbb_concurrent_queue_scheduler.cpp"
"${CNC_SRC_ROOT}/src/traceable.cpp"
"${CNC_SRC_ROOT}/src/cnc_stddef.cpp"
# RRN: It's actually the same for Mac as for linux:
"${CNC_SRC_ROOT}/src/tls_${CMAKE_SYSTEM_NAME}.cpp"
)
set( CNC_SOCKET_SOURCES "${CNC_SRC_ROOT}/src/dist/generic_comm/ChannelInterface.cpp"
"${CNC_SRC_ROOT}/src/dist/generic_comm/GenericCommunicator.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/pal_socket.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/pal_util.cpp"
"${CNC_SRC_ROOT}/src/dist/generic_comm/Settings.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/SocketChannelInterface.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/SocketClientInitializer.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/SocketCommunicator.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/SocketHostInitializer.cpp"
"${CNC_SRC_ROOT}/src/dist/generic_comm/ThreadExecuter.cpp"
)
set( CNC_MPI_SOURCES "${CNC_SRC_ROOT}/src/dist/generic_comm/ChannelInterface.cpp"
"${CNC_SRC_ROOT}/src/dist/generic_comm/GenericCommunicator.cpp"
"${CNC_SRC_ROOT}/src/dist/generic_comm/Settings.cpp"
"${CNC_SRC_ROOT}/src/dist/mpi_comm/MpiChannelInterface.cpp"
"${CNC_SRC_ROOT}/src/dist/mpi_comm/MpiClientInitializer.cpp"
"${CNC_SRC_ROOT}/src/dist/mpi_comm/MpiCommunicator.cpp"
"${CNC_SRC_ROOT}/src/dist/mpi_comm/MpiHostInitializer.cpp"
"${CNC_SRC_ROOT}/src/dist/generic_comm/ThreadExecuter.cpp"
"${CNC_SRC_ROOT}/src/dist/socket_comm/pal_util.cpp"
)
################################################################################
# Misc vars
set(CNC_LIBS cnc_socket)
################################################################################
# generic compiler options
include_directories("${CNC_SRC_ROOT}" "${CNC_SRC_ROOT}/src/dist/generic_comm")
if(CNC_PRODUCT_BUILD)
add_definitions("-DCNC_PRODUCT_BUILD")
endif(CNC_PRODUCT_BUILD)
if(SDL)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -GS")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -NXCompat -DynamicBase")
elseif(LINUX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector -fPIC -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif(CMAKE_SYSTEM_NAME)
endif(SDL)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
add_definitions("-D_LIB -D_WIN_DLL -DCNC_DLL_SUFX=${CNC_DLL_SFX} -DCNC_DLL_EXPORTS")
set(${CMAKE_SHARED_LINKER_FLAGS} "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL:NO /OPT:NOREF")
else()
endif(CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_DEBUG_POSTFIX "_debug${CNC_DLL_SFX}")
set(CMAKE_RELEASE_POSTFIX "${CNC_DLL_SFX}")
################################################################################
# base library
#increase if ABI changes
set(SOVERSION 0)
add_library(cnc SHARED ${CNC_BASE_SOURCES} )
set_target_properties(cnc PROPERTIES SOVERSION ${SOVERSION})
add_library(cnc_socket SHARED ${CNC_SOCKET_SOURCES} )
set_target_properties(cnc_socket PROPERTIES SOVERSION ${SOVERSION})
target_link_libraries(cnc ${CNC_ADD_LIBS})
target_link_libraries(cnc_socket general cnc ${CNC_ADD_LIBS})
################################################################################
# MPI stuff
if(BUILD_LIBS_FOR_MPI)
set(CNC_LIBS ${CNC_LIBS} cnc_mpi)
add_library(cnc_mpi SHARED ${CNC_MPI_SOURCES})
set(CNC_MPI_FLAGS "-DNO_MSG_TRACING -DPRE_SEND_MSGS")
set_target_properties(cnc_mpi PROPERTIES COMPILE_FLAGS "${CNC_MPI_FLAGS}" SOVERSION ${SOVERSION})
# doesn't seem to work: set_target_properties(cnc_mpi PROPERTIES INCLUDE_DIRECTORIES "${MPIROOT}/${MPIARCH}/include")
include_directories(${MPI_INC_DIR})
target_link_libraries(cnc_mpi cnc ${CNC_ADD_LIBS} ${MPI_LIB})
endif(BUILD_LIBS_FOR_MPI)
################################################################################
# ITAC stuff
if(BUILD_LIBS_FOR_ITAC)
set(CNC_LIBS ${CNC_LIBS} cnc_socket_itac)
add_library(cnc_socket_itac SHARED ${CNC_SOCKET_SOURCES} )
set(CNC_ITAC_FLAGS "${CNC_ITAC_FLAGS} -DINTERNAL_ITAC")
set_target_properties(cnc_socket_itac PROPERTIES COMPILE_FLAGS "${CNC_ITAC_FLAGS}" SOVERSION ${SOVERSION})
include_directories(${ITACROOT}/include)
#set_target_properties(cnc_socket_itac PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} "${ITACROOT}/include")
set_itac_link_flags(cnc_socket_itac)
target_link_libraries(cnc_socket_itac cnc ${CNC_ADD_LIBS} ${ITACCS_LIB})
if(BUILD_LIBS_FOR_MPI)
set(CNC_LIBS ${CNC_LIBS} cnc_mpi_itac)
add_library(cnc_mpi_itac SHARED ${CNC_MPI_SOURCES} )
set_target_properties(cnc_mpi_itac PROPERTIES COMPILE_FLAGS "${CNC_MPI_FLAGS} ${CNC_ITAC_FLAGS}" SOVERSION ${SOVERSION})
# doesn't seem to work: set_target_properties(cnc_mpi_itac PROPERTIES INCLUDE_DIRECTORIES "${MPIROOT}/${MPIARCH}/include" INCLUDE_DIRECTORIES "${ITACROOT}/include")
include_directories("${MPIROOT}/${MPIARCH}/include") # "${ITACROOT}/include")
set_itac_link_flags(cnc_mpi_itac)
target_link_libraries(cnc_mpi_itac cnc ${CNC_ADD_LIBS} ${MPI_LIB} ${ITAC_LIB})
endif(BUILD_LIBS_FOR_MPI)
endif(BUILD_LIBS_FOR_ITAC)
# {'option': 'cflags=-DWITHOUT_SENDER_THREAD'}
################################################################################
# add a target to generate API documentation with Doxygen
if (NOT DEFINED DATA)
set(DATA "share/icnc")
endif(NOT DEFINED DATA)
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CNC_SRC_ROOT}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
set(DOXY_DEPS
${CNC_SRC_ROOT}/doc/main.dox
${CNC_SRC_ROOT}/cnc/cnc.h
${CNC_SRC_ROOT}/cnc/debug.h
${CNC_SRC_ROOT}/cnc/default_tuner.h
${CNC_SRC_ROOT}/cnc/dist_cnc.h
${CNC_SRC_ROOT}/cnc/join.h
${CNC_SRC_ROOT}/cnc/reduce.h
${CNC_SRC_ROOT}/cnc/itac.h
${CNC_SRC_ROOT}/cnc/serializer.h
${CNC_SRC_ROOT}/cnc/default_partitioner.h
${CNC_SRC_ROOT}/cnc/internal/cnc_tag_hash_compare.h
${CNC_SRC_ROOT}/doc/code.dox
)
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${CNC_SRC_ROOT}/Doxyfile.in
DEPENDS ${DOXY_DEPS}
COMMENT "Generating HTML documentation"
)
ADD_CUSTOM_TARGET(doc ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html)
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html/ DESTINATION ${DATA}/doc/api)
endif(DOXYGEN_FOUND)
################################################################################
# Install
if(NOT DEFINED LIB)
set(LIB "lib/${PARCH}")
endif(NOT DEFINED LIB)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
install(TARGETS ${CNC_LIBS} RUNTIME DESTINATION bin/${PARCH})
install(TARGETS cnc LIBRARY DESTINATION ${LIB} RUNTIME DESTINATION bin/${PARCH} ARCHIVE DESTINATION ${LIB})
install(DIRECTORY ${CNC_SRC_ROOT}/src/dist/socket_comm/test/ DESTINATION ${DATA}/misc/distributed/socket FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_WRITE GROUP_READ FILES_MATCHING REGEX ".*(sh|bat)$")
else()
install(TARGETS cnc ${CNC_LIBS} LIBRARY DESTINATION ${LIB} RUNTIME DESTINATION bin/${PARCH})
install(DIRECTORY ${CNC_SRC_ROOT}/src/dist/socket_comm/test/ DESTINATION ${DATA}/misc/distributed/socket FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_WRITE GROUP_READ FILES_MATCHING REGEX ".*sh$")
install(DIRECTORY ${CNC_SRC_ROOT}/src/dist/socket_comm/test/ DESTINATION ${DATA}/misc/distributed/socket FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_WRITE GROUP_READ FILES_MATCHING REGEX ".*bat$")
endif()
install(DIRECTORY ${CNC_SRC_ROOT}/cnc DESTINATION include FILES_MATCHING PATTERN "*.h")
foreach(smpl fib
primes
mandelbrot
rtm_stencil
blackscholes
cholesky
matrix_inverse
FaceDetection
floyd_warshall
nqueens
dedup
uts
reduce_2d
count_words
count_all_words
db
hidden_graph
mpicnc
heat_equation
search_in_sorted_tree
raytracer
jacobi2d
auto_graph_pipeline)
install(DIRECTORY ${CNC_SRC_ROOT}/samples/${smpl} DESTINATION ${DATA}/samples/)
install(FILES samples/Makefile DESTINATION ${DATA}/samples/${smpl}/)
endforeach(smpl)
# example codes from eight patterns document
foreach(smpl reduce_rows
producer_consumer
partition_string
divide_conquer
red_rows_until_pred
gen_new_iter_space)
install(DIRECTORY ${CNC_SRC_ROOT}/samples/${smpl} DESTINATION ${DATA}/samples/eight_patterns/)
install(FILES samples/Makefile DESTINATION ${DATA}/samples/eight_patterns/${smpl}/)
endforeach(smpl)
install(FILES samples/CMakeLists.txt samples/Makefile samples/allsamples.sln DESTINATION ${DATA}/samples/)
option(ENABLE_TESTING "Enable in-source testing" FALSE)
if(ENABLE_TESTING)
enable_testing()
add_subdirectory(tests)
endif(ENABLE_TESTING)