forked from Xtra-Computing/FedTree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
128 lines (105 loc) · 3.87 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
cmake_minimum_required(VERSION 3.15)
#cmake_policy(SET CMP0104 NEW)
#cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0042 NEW)
project(FedTree LANGUAGES C CXX)
if(MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
endif()
option(BUILD_SHARED_LIBS "Build as a shared library" ON)
option(USE_CUDA "Compile with CUDA for homomorphic encryption" OFF)
option(USE_CUDA_ARRAY "Compile with CUDA for training" OFF)
option(DISTRIBUTED "Build for distributed computing" ON)
option(USE_DOUBLE "Use double as gradient_type" OFF)
set(BUILD_TESTS OFF CACHE BOOL "Build Tests")
set(NTL_PATH "/usr/local" CACHE STRING "NTL Path")
find_package(OpenMP REQUIRED)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if (MSVC AND BUILD_SHARED_LIBS)
set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()
if (USE_CUDA)
message("Compile with CUDA")
find_package(CUDA REQUIRED QUIET)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11 -lineinfo --expt-extended-lambda --default-stream per-thread")
include_directories(${PROJECT_SOURCE_DIR}/CGBN/include)
add_subdirectory(${PROJECT_SOURCE_DIR}/thrust/)
find_package(Thrust REQUIRED)
thrust_create_target(ThrustOMP HOST CPP DEVICE OMP)
include_directories(${NTL_PATH}/include/)
else ()
message("Complie without CUDA")
#set(Thrust_DIR "${PROJECT_SOURCE_DIR}/thrust/cmake/")
add_subdirectory(${PROJECT_SOURCE_DIR}/thrust/)
find_package(Thrust REQUIRED)
thrust_create_target(ThrustOMP HOST CPP DEVICE OMP)
# include_directories(/usr/local/include/)
include_directories(${NTL_PATH}/include/)
endif ()
# Require the users to install gRPC in prior.
if(DISTRIBUTED)
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
message(STATUS "Using protobuf ${Protobuf_VERSION}")
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
set(_REFLECTION gRPC::grpc++_reflection)
if(CMAKE_CROSSCOMPILING)
find_program(_PROTOBUF_PROTOC protoc)
else()
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
endif()
find_package(gRPC CONFIG REQUIRED)
set(_GRPC_GRPCPP gRPC::grpc++)
if(CMAKE_CROSSCOMPILING)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
else()
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
endif()
endif()
#if (DISTRIBUTED)
# include(FetchContent)
# FetchContent_Declare(
# gRPC
# GIT_REPOSITORY https://github.com/grpc/grpc
# GIT_TAG v1.35.0 # e.g v1.28.0
# )
# set(FETCHCONTENT_QUIET OFF)
# FetchContent_MakeAvailable(gRPC)
#endif ()
if (CMAKE_VERSION VERSION_LESS "3.1")
add_compile_options("-std=c++11")
else ()
set(CMAKE_CXX_STANDARD 11)
endif ()
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()
# for easylogging++ configuration
add_definitions("-DELPP_FEATURE_PERFORMANCE_TRACKING")
add_definitions("-DELPP_THREAD_SAFE")
add_definitions("-DELPP_STL_LOGGING")
add_definitions("-DELPP_NO_LOG_TO_FILE")
# includes
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
if(USE_CUDA)
list(REMOVE_ITEM COMMON_INCLUDES "${PROJECT_SOURCE_DIR}/include/FedTree/Encryption/paillier.h")
else()
list(REMOVE_ITEM COMMON_INCLUDES "${PROJECT_SOURCE_DIR}/include/FedTree/Encryption/paillier_gpu.h")
endif()
set(DATASET_DIR ${PROJECT_SOURCE_DIR}/dataset/)
configure_file(include/FedTree/config.h.in config.h)
include_directories(${COMMON_INCLUDES})
if (USE_CUDA)
include_directories(${PROJECT_SOURCE_DIR}/cub)
endif ()
add_subdirectory(${PROJECT_SOURCE_DIR}/src/FedTree)
if (BUILD_TESTS)
message("Building tests")
add_subdirectory(src/test)
endif ()
# configuration file