-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
210 lines (183 loc) · 5.82 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
#==============================================================================
#
# CMakeLists.txt
#
#==============================================================================
cmake_minimum_required(VERSION 2.8.12)
#cmake_policy(SET CMP0004 OLD)
#cmake_policy(SET CMP0074 NEW)
string(STRIP "${CMAKE_EXE_LINKER_FLAGS}" CMAKE_EXE_LINKER_FLAGS)
project("genomics_gpu")
MESSAGE("--------------------")
MESSAGE("Compiler ID: ${CMAKE_C_COMPILER_ID}")
set(HIPLOCAL_DIR "${CMAKE_SOURCE_DIR}/scripts")
#--------------------
# Dirs, Files.
SET(INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/driver
)
SET(LIB_SOURCES
src/assertions.cc
src/utils.cc
src/env.cc
src/magma_wrapper.cc
src/mirrored_buf.cc
src/compressed_buf.cc
src/histograms.cc
src/tc.cc
src/decomp_mgr.cc
src/linalg.cc
src/vectors.cc
src/metrics.cc
src/vector_sums.cc
src/checksum.cc
src/comm_xfer_utils.cc
src/compute_metrics_2way_block_nums.cc
src/compute_metrics_2way_block_finalize.cc
src/compute_metrics_3way_block_nonlinalg.cc
src/compute_metrics_3way_block_linalg.cc
src/compute_metrics_3way_block.cc
src/compute_metrics_2way.cc
src/compute_metrics_3way.cc
src/compute_metrics.cc
)
SET(ACCEL_SOURCES
src/tc.cc
src/compressed_buf.cc
src/vector_sums.cc
)
SET(LIB_INCLUDES
src/assertions.hh
src/assertions.i.hh
src/utils.hh
src/types.hh
src/env.hh
src/formulas.hh
src/magma_wrapper.hh
src/mirrored_buf.hh
src/compressed_buf.hh
src/compressed_buf.i.hh
src/histograms.hh
src/tc.hh
src/tc_helpers.i.hh
src/tc_in.i.hh
src/tc_solve.i.hh
src/tc_out.i.hh
src/decomp_mgr.hh
src/linalg.hh
src/vectors.hh
src/metrics.hh
src/metrics_2way_indexing.i.hh
src/metrics_2way_accessors.i.hh
src/metrics_3way_indexing.i.hh
src/metrics_3way_accessors.i.hh
src/vector_sums.hh
src/checksum.hh
src/comm_xfer_utils.hh
src/compute_metrics_2way_block.hh
src/compute_metrics_3way_block.hh
src/compute_metrics_2way.hh
src/compute_metrics_3way.hh
src/compute_metrics.cc
)
SET(DRIVER_SOURCES
driver/driver.cc
driver/vectors_io.cc
driver/metrics_io.cc
driver/test_problems.cc
)
SET(TEST_TARGETS
env_test
metrics_test
driver_test
perf_test
)
#--------------------
# Preliminaries.
if(USE_MPI)
find_package(MPI REQUIRED)
endif()
if(USE_CUDA)
find_package(CUDA REQUIRED)
CUDA_INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
# see https://stackoverflow.com/questions/36021233/
# cmake-cuda-compile-cpp-files-in-cuda-mode-x-cu
# Interpret cc file as cu file.
# NOTE: order of next lines matters.
# set_source_files_properties(src/tc.cc
# PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
# set_source_files_properties(src/assertions.cc
# PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
foreach(ACCEL_SOURCE ${ACCEL_SOURCES})
set_source_files_properties(${ACCEL_SOURCE}
PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
endforeach()
CUDA_ADD_LIBRARY(genomics_metrics STATIC ${LIB_SOURCES} ${CUDA_SOURCES})
elseif(USE_HIP) #=========================================
if(NOT DEFINED HIP_PATH)
if(NOT DEFINED ENV{HIP_PATH})
message(FATAL_ERROR "Could not find HIP..")
else()
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to HIP install")
endif()
endif()
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
find_package(HIPLOCAL QUIET)
if(HIPLOCAL_FOUND)
message(STATUS "Found HIP: " ${HIP_VERSION})
else()
message(FATAL_ERROR "Could not find HIP.")
endif()
set(CMAKE_LINKER "${ROCM_PATH}/bin/hipcc")
set_source_files_properties(${LIB_SOURCES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_library(genomics_metrics ${LIB_SOURCES} HIPCC_OPTIONS ${CMAKE_CXX_FLAGS})
set_source_files_properties(driver/genomics_metric.cc ${DRIVER_SOURCES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
#set_property(TARGET tgt PROPERTY HIP_ARCHITECTURES gfx801 gfx900)
else()
ADD_LIBRARY(genomics_metrics STATIC ${LIB_SOURCES} ${CUDA_SOURCES})
endif()
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
#--------------------
# Main executable, lib.
if(USE_HIP)
hip_add_executable(genomics_metric driver/genomics_metric.cc ${DRIVER_SOURCES} HIPCC_OPTIONS ${CMAKE_CXX_FLAGS})
set_property(TARGET genomics_metric PROPERTY HIP_ARCHITECTURES ${COMET_HIP_ARCHITECTURES})
else()
ADD_EXECUTABLE(genomics_metric driver/genomics_metric.cc ${DRIVER_SOURCES})
endif()
TARGET_LINK_LIBRARIES(genomics_metric genomics_metrics)
TARGET_LINK_LIBRARIES(genomics_metric ${CMAKE_EXE_LINKER_FLAGS})
install(FILES ${LIB_INCLUDES} DESTINATION include)
install(TARGETS genomics_metrics DESTINATION lib)
install(TARGETS genomics_metric DESTINATION bin)
#--------------------
# Tester.
if(TESTING)
enable_testing()
foreach(TEST_TARGET ${TEST_TARGETS})
ADD_EXECUTABLE(${TEST_TARGET} testing/${TEST_TARGET}.cc ${DRIVER_SOURCES})
TARGET_LINK_LIBRARIES(${TEST_TARGET} genomics_metrics)
TARGET_LINK_LIBRARIES(${TEST_TARGET} ${CMAKE_EXE_LINKER_FLAGS})
if("${TEST_TARGET}" STREQUAL "perf_test")
if(NOT "${TEST_COMMAND_PERF}" STREQUAL "")
if("${FP_PRECISION}" STREQUAL "DOUBLE")
add_test(${TEST_TARGET} bash -c
"date && cd ${CMAKE_INSTALL_PREFIX} && ${TEST_COMMAND_PERF} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET} && date")
endif()
endif()
else()
add_test(${TEST_TARGET} bash -c
"date && cd ${CMAKE_INSTALL_PREFIX} && ${TEST_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET} && date")
set(UNUSED_NO_WARN_1, ${FP_PRECISION})
endif()
endforeach()
else()
# turn off unused var warnings
set(UNUSED_NO_WARN_1, ${TEST_COMMAND})
set(UNUSED_NO_WARN_1, ${TEST_COMMAND_PERF})
set(UNUSED_NO_WARN_1, ${FP_PRECISION})
endif()
MESSAGE("--------------------")
#==============================================================================