-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathCMakeLists.txt
153 lines (141 loc) · 5.98 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
set(INSTALLED_TARGETS_LIST "")
if(NOT TARGET cosma)
set(cosma_src_files blas.cpp
buffer.cpp
communicator.cpp
context.cpp
interval.cpp
layout.cpp
local_multiply.cpp
mapper.cpp
math_utils.cpp
matrix.cpp
memory_pool.cpp
multiply.cpp
one_sided_communicator.cpp
strategy.cpp
two_sided_communicator.cpp
random_generator.hpp
cinterface.cpp
environment_variables.cpp
)
if (GPU)
list(APPEND cosma_src_files "pinned_buffers.cpp")
if (COSMA_WITH_NCCL)
list(APPEND cosma_src_files "gpu/nccl_utils.cpp")
endif()
if (COSMA_WITH_GPU_AWARE_MPI)
list(APPEND cosma_src_files "gpu/gpu_aware_mpi_utils.cpp")
endif()
endif()
add_library(cosma ${cosma_src_files})
target_include_directories(cosma PUBLIC
$<BUILD_INTERFACE:${cosma_SOURCE_DIR}/src>
)
if (COSMA_WITH_NCCL)
target_include_directories(cosma PUBLIC ${NCCL_INCLUDE_DIRS}
)
endif()
target_compile_features(cosma PUBLIC cxx_std_14)
target_link_libraries(cosma PUBLIC MPI::MPI_CXX
costa
${BLAS_TARGET}
)
if (COSMA_WITH_NCCL)
target_link_libraries(cosma PUBLIC ${NCCL_TARGET}
${GPU_TARGET}
)
endif()
target_compile_definitions(cosma PUBLIC ${BLAS_DEF})
if (COSMA_WITH_NCCL)
target_compile_definitions(cosma PUBLIC ${NCCL_DEF}
${GPU_DEFF}
)
endif()
if (COSMA_WITH_GPU_AWARE_MPI)
target_compile_definitions(cosma PUBLIC ${MPI_DEF}
${GPU_DEFF}
)
target_link_libraries(cosma PUBLIC ${GPU_TARGET})
endif()
if(COSMA_WITH_PROFILING)
target_link_libraries(cosma PRIVATE semiprof)
target_compile_definitions(cosma PRIVATE COSMA_WITH_PROFILING)
endif()
list(APPEND INSTALLED_TARGETS_LIST "cosma")
endif()
# if SCALAPACK is found and cosma_pxgemm library is not already created
# then create it here and link it to the profiler if needed
# build as a shared library is necessary here because of the function interposing
if(SCALAPACK_TARGET AND NOT TARGET cosma_pxgemm AND BUILD_SHARED_LIBS)
add_library(cosma_pxgemm scalapack.cpp
pxgemm_params.hpp
cosma_pxgemm.cpp
pxgemm.cpp
)
target_link_libraries(cosma_pxgemm PUBLIC cosma
costa_scalapack
${BLAS_TARGET}
${SCALAPACK_TARGET}
${SCALAPACK_DEPENDENCIES}
)
if(COSMA_WITH_PROFILING)
target_link_libraries(cosma_pxgemm PRIVATE semiprof)
target_compile_definitions(cosma_pxgemm PRIVATE COSMA_WITH_PROFILING)
endif()
list(APPEND INSTALLED_TARGETS_LIST "cosma_pxgemm")
endif()
# this is a library exposing the prefixed scalapack API (with cosma/COSMA prefix)
# it is aimed for users who don't want to overwrite the available scalapack API with cosma.
# if SCALAPACK is found and cosma_prefixed_pxgemm library is not already created
# then create it here and link it to the profiler if needed
if(SCALAPACK_TARGET AND NOT TARGET cosma_prefixed_pxgemm)
add_library(cosma_prefixed_pxgemm scalapack.cpp
pxgemm_params.hpp
prefixed_pxgemm.cpp
cosma_pxgemm.cpp
)
target_link_libraries(cosma_prefixed_pxgemm PUBLIC cosma
costa_prefixed_scalapack
${BLAS_TARGET}
${SCALAPACK_TARGET}
${SCALAPACK_DEPENDENCIES}
)
if(COSMA_WITH_PROFILING)
target_link_libraries(cosma_prefixed_pxgemm PRIVATE semiprof)
target_compile_definitions(cosma_prefixed_pxgemm PRIVATE COSMA_WITH_PROFILING)
endif()
list(APPEND INSTALLED_TARGETS_LIST "cosma_prefixed_pxgemm")
endif()
# the following library is aimed only for testing purposes
# it provides templated cosma::pxgemm call without
# pxgemm.h, so that pxgemm calls of scalapack are not overwritten
# and can still be compared to scalapack for correctness check
if(SCALAPACK_TARGET AND NOT TARGET cosma_pxgemm_cpp)
add_library(cosma_pxgemm_cpp scalapack.cpp
pxgemm_params.hpp
cosma_pxgemm.cpp
)
target_link_libraries(cosma_pxgemm_cpp PUBLIC cosma
costa
${BLAS_TARGET}
${SCALAPACK_TARGET}
${SCALAPACK_DEPENDENCIES}
)
if(COSMA_WITH_PROFILING)
target_link_libraries(cosma_pxgemm_cpp PRIVATE semiprof)
target_compile_definitions(cosma_pxgemm_cpp PRIVATE COSMA_WITH_PROFILING)
endif()
list(APPEND INSTALLED_TARGETS_LIST "cosma_pxgemm_cpp")
endif()
if(COSMA_WITH_INSTALL AND INSTALLED_TARGETS_LIST)
install(TARGETS ${INSTALLED_TARGETS_LIST}
EXPORT cosma_targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(EXPORT cosma_targets
FILE cosmaTargets.cmake
NAMESPACE cosma::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cosma")
endif()