-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
118 lines (104 loc) · 4.07 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
cmake_minimum_required(VERSION 3.1)
project(QCSimulatorRoot)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
find_package(CUDA REQUIRED)
find_package(OpenMP REQUIRED)
find_package(Nccl REQUIRED)
find_package(MPI REQUIRED)
find_library(CUTT cutt "${PROJECT_SOURCE_DIR}/third-party/cutt/cutt/lib")
include_directories(${PROJECT_SOURCE_DIR}/third-party/cutt/cutt/include)
include_directories(${PROJECT_SOURCE_DIR}/third-party/dbg-macro)
MESSAGE(STATUS "Found CUTT: ${CUTT}")
set(CMAKE_CXX_FLAGS "-std=c++14 -O2 -g -Wall ${OpenMP_CXX_FLAGS}")
set(CUDA_NVCC_FLAGS "-Xcompiler -fopenmp -std=c++14 -O2 -g -arch=compute_70 -code=sm_70 --ptxas-options=-v -lineinfo -keep")
set(BACKEND "group" CACHE STRING "Backend mode, one of [serial, group, group-serial, blas, mix, blas-advance]")
MESSAGE(STATUS "Backend: ${BACKEND}")
option(SHOW_SCHEDULE "Print the schedule" ON)
option(SHOW_SUMMARY "Show the running details" ON)
option(MEASURE_STAGE "Measure time of each stage" OFF)
option(MICRO_BENCH "Compile micro-benchmarks" OFF)
option(EVALUATOR_PREPROCESS "compile evaluator preprocess" OFF)
option(DISABLE_ASSERT "Use assert in cuda runtime" ON)
option(USE_DOUBLE "double or float" ON)
option(ENABLE_OVERLAP "overlap" ON)
option(USE_MPI "use mpi" OFF)
option(OVERLAP_MAT "overlap initMatirx" ON)
option(LOG_EVALUATOR "show logging of evaluator" OFF)
if (BACKEND STREQUAL "serial")
add_definitions(-DBACKEND=0)
elseif(BACKEND STREQUAL "group")
add_definitions(-DBACKEND=1)
elseif(BACKEND STREQUAL "group-serial")
add_definitions(-DBACKEND=2)
elseif(BACKEND STREQUAL "blas")
add_definitions(-DBACKEND=3)
elseif(BACKEND STREQUAL "mix")
add_definitions(-DBACKEND=4)
elseif(BACKEND STREQUAL "blas-advance")
add_definitions(-DBACKEND=5)
else()
MESSAGE(ERROR "invalid mode")
endif()
if (SHOW_SCHEDULE)
add_definitions(-DSHOW_SCHEDULE)
endif(SHOW_SCHEDULE)
if (SHOW_SUMMARY)
add_definitions(-DSHOW_SUMMARY)
endif(SHOW_SUMMARY)
if (MEASURE_STAGE)
add_definitions(-DMEASURE_STAGE)
endif(MEASURE_STAGE)
if (DISABLE_ASSERT)
add_definitions(-DNDEBUG)
else()
add_definitions(-DDEBUG)
endif(DISABLE_ASSERT)
if (ENABLE_OVERLAP)
add_definitions(-DENABLE_OVERLAP)
endif(ENABLE_OVERLAP)
if (USE_DOUBLE)
MESSAGE(STATUS "Float type: Double")
add_definitions(-DUSE_DOUBLE)
else()
MESSAGE(STATUS "Float type: Float")
endif(USE_DOUBLE)
if (OVERLAP_MAT)
add_definitions(-DOVERLAP_MAT)
endif(OVERLAP_MAT)
if (USE_MPI)
add_definitions(-DUSE_MPI=1)
else()
add_definitions(-DUSE_MPI=0)
endif(USE_MPI)
set(COALESCE "3" CACHE STRING "coalescing size")
MESSAGE(STATUS "coalesce = ${COALESCE}")
add_definitions(-DCOALESCE_GLOBAL_DEFINED=${COALESCE})
set(MAT "6" CACHE STRING "mat size")
MESSAGE(STATUS "mat size = ${MAT}")
add_definitions(-DBLAS_MAT_LIMIT_DEFINED=${MAT})
set(MIN_MAT "4" CACHE STRING "min mat size")
MESSAGE(STATUS "min mat size = ${MIN_MAT}")
add_definitions(-DMIN_MAT_SIZE_DEFINED=${MIN_MAT})
set(THREAD_DEP "7" CACHE STRING "thread dep")
MESSAGE(STATUS "thread_dep = ${THREAD_DEP}")
add_definitions(-DTHREAD_DEP_DEFINED=${THREAD_DEP})
if (EVALUATOR_PREPROCESS)
set(PROCESS process)
add_executable(process evaluator-preprocess/process.cpp)
target_link_libraries(process QCSimulator ${CUTT} ${OpenMP_CXX_FLAGS} ${CUDA_CUBLAS_LIBRARIES} ${MPI_CXX_LIBRARIES} ${NCCL_LIBRARY})
add_definitions(-DUSE_EVALUATOR_PREPROCESS)
endif(EVALUATOR_PREPROCESS)
if(LOG_EVALUATOR)
add_definitions(-DLOG_EVALUATOR)
endif(LOG_EVALUATOR)
include_directories ("${PROJECT_SOURCE_DIR}/src")
add_subdirectory("src")
add_executable(main main.cpp)
target_link_libraries(main QCSimulator ${CUTT} ${OpenMP_CXX_FLAGS} ${CUDA_CUBLAS_LIBRARIES} ${MPI_CXX_LIBRARIES} ${NCCL_LIBRARY})
if (MICRO_BENCH)
set(BENCHMARKS local-single local-ctr two-group-h bench-blas)
foreach(BENCHMARK IN LISTS BENCHMARKS)
add_executable(${BENCHMARK} micro-benchmark/${BENCHMARK}.cpp)
target_link_libraries(${BENCHMARK} QCSimulator ${CUTT} ${OpenMP_CXX_FLAGS} ${CUDA_CUBLAS_LIBRARIES} ${MPI_CXX_LIBRARIES} ${NCCL_LIBRARY})
endforeach(BENCHMARK IN LISTS BENCHMARKS)
endif(MICRO_BENCH)