-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (104 loc) · 4.21 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
include(CheckCXXCompilerFlag)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(cuEDM CXX)
# Enable all warnings
# TODO Check if this works across all compilers we are using
add_compile_options(-Wall -Werror -Wno-unknown-pragmas)
# Build for native CPU architecture
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL
"RelWithDebInfo")
check_cxx_compiler_flag(-march=native CXX_SUPPORTS_MARCH)
if(CXX_SUPPORTS_MARCH)
add_compile_options("-march=native")
endif()
endif()
add_library(cuedm SHARED src/dataframe.cc src/lut.cc
src/nearest_neighbors_cpu.cc
src/simplex_cpu.cc src/cross_mapping_cpu.cc
src/embedding_dim_cpu.cc src/stats.cc)
add_executable(knn_bench src/knn_bench.cc)
add_executable(simplex_bench src/simplex_bench.cc)
add_executable(cross_mapping_bench src/cross_mapping_bench.cc)
target_link_libraries(knn_bench PRIVATE cuedm)
target_link_libraries(simplex_bench PRIVATE cuedm)
target_link_libraries(cross_mapping_bench PRIVATE cuedm)
# argh
add_subdirectory(src/thirdparty/argh)
target_link_libraries(knn_bench PRIVATE argh)
target_link_libraries(simplex_bench PRIVATE argh)
target_link_libraries(cross_mapping_bench PRIVATE argh)
# Enable OpenMP if available
find_package(OpenMP)
if(OpenMP_FOUND)
message(STATUS "OpenMP found, enabling multi-threading")
target_link_libraries(cuedm PRIVATE OpenMP::OpenMP_CXX)
else()
message(WARNING "OpenMP was NOT found, multi-threading is disabled")
endif()
# Enable GPU backend if ArrayFire and OpenMP are available
find_package(ArrayFire)
if(ArrayFire_FOUND AND OpenMP_FOUND)
message(STATUS "ArrayFire found, enabling GPU backend")
add_definitions(-DENABLE_GPU_KERNEL)
if(APPLE)
# Need to force the CPU backend since the OpenCL backend has bugs on macOS
# See: https://github.com/arrayfire/arrayfire/issues/2687
target_link_libraries(cuedm PRIVATE ArrayFire::afcpu)
else()
target_link_libraries(cuedm PRIVATE ArrayFire::af)
endif()
target_sources(cuedm PRIVATE src/nearest_neighbors_gpu.cc src/simplex_gpu.cc
src/cross_mapping_gpu.cc src/embedding_dim_gpu.cc)
else()
message(WARNING "ArrayFire was NOT found, GPU backend is disabled")
endif()
# Enable MPI if available
find_package(MPI)
if(MPI_CXX_FOUND)
message(STATUS "MPI found, enabling multi-node benchmarks")
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(src/thirdparty/json)
target_sources(cuedm PRIVATE src/mpi_master.cc src/mpi_worker.cc)
target_link_libraries(cuedm PRIVATE MPI::MPI_CXX
nlohmann_json::nlohmann_json)
add_executable(simplex_mpi_bench src/simplex_mpi_bench.cc)
target_link_libraries(simplex_mpi_bench PRIVATE cuedm MPI::MPI_CXX
nlohmann_json::nlohmann_json)
else()
message(WARNING "MPI was NOT found, multi-node benchmarks are disabled")
endif()
# HDF5
find_package(HDF5 REQUIRED)
set(USE_BOOST OFF)
set(HIGHFIVE_UNIT_TESTS OFF)
set(HIGHFIVE_EXAMPLES OFF)
add_subdirectory(src/thirdparty/highfive)
target_link_libraries(cuedm PRIVATE HighFive)
target_link_libraries(cross_mapping_bench PRIVATE HighFive)
# Tests
enable_testing()
add_subdirectory(src/thirdparty/catch2)
include(CTest)
include(src/thirdparty/catch2/contrib/Catch.cmake)
# Lookup table test
add_executable(lut_test test/lut_test.cc)
target_link_libraries(lut_test PRIVATE cuedm Catch2::Catch2)
catch_discover_tests(lut_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
# k-nearest neighbors test
add_executable(knn_test test/knn_test.cc)
target_link_libraries(knn_test PRIVATE cuedm Catch2::Catch2)
catch_discover_tests(knn_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
# Cross mapping test
add_executable(cross_mapping_test test/cross_mapping_test.cc)
target_link_libraries(cross_mapping_test PRIVATE cuedm Catch2::Catch2)
catch_discover_tests(cross_mapping_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
# Simplex test
add_executable(simplex_test test/simplex_test.cc)
target_link_libraries(simplex_test PRIVATE cuedm Catch2::Catch2)
catch_discover_tests(simplex_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)