forked from andreasmang/claire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.mk
144 lines (120 loc) · 3.36 KB
/
config.mk
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
#directories
override APP_DIR := ./apps
override SRC_DIR := ./src
override OBJ_DIR := ./obj
override LIB_DIR := ./lib
override EXSRC_DIR := ./3rdparty
INCLUDES = ./include ./deps/3rdparty
BUILD_DIR = ./bin
INCLUDES += $(EXSRC_DIR)
#programs
CXX = mpicxx
NVCC = nvcc
RM = rm -f
MKDIR = mkdir -p
LIBRARIES = $(LIB_DIR)
LDFLAGS += -fopenmp
#locate dependencies
MPI_DIR = $(abspath $(subst bin,,$(dir $(shell which $(CXX)))))
INCLUDES += $(MPI_DIR)/include
INCLUDES += $(MPI_DIR)/include/mpi
LIBRARIES += $(MPI_DIR)/lib
CXXFLAGS += -g $(CXX_FLAGS)
LDFLAGS += -g $(LD_FLAGS)
ifeq ($(WITH_DEVELOP), yes)
CXXFLAGS += -DZEITGEIST
endif
ifeq ($(WITH_DEVELOP_EXTRA), yes)
CXXFLAGS += -DZEITGEIST_DEV
endif
ifeq ($(WITH_CUDA_MPI), yes)
CXXFLAGS += -DREG_HAS_MPICUDA
endif
ifeq ($(BUILD_TARGET), POWER9)
CXXFLAGS += -DREG_HAS_MPICUDA
CXXFLAGS += -DPOWER9
endif
ifeq ($(BUILD_GPU), yes)
ifeq ($(WITH_DOUBLE), yes)
$(error GPU build only supports single precision)
endif
CUDA_DIR = $(abspath $(subst bin,,$(dir $(shell which $(NVCC)))))
INCLUDES += $(CUDA_DIR)/include
LIBRARIES += $(CUDA_DIR)/lib
LIBRARIES += $(CUDA_DIR)/lib64
LDFLAGS += -lcuda -lcudart -lcufft -lcublas -lcusparse -lcusolver
NVCCFLAGS += -Xcompiler "$(CXXFLAGS)" --std=$(CPP_VERSION) -O3 -c $(NVCC_FLAGS)
CXXFLAGS += -DREG_HAS_CUDA
CXXFLAGS += -DREG_FFT_CUDA
ifeq ($(WITH_DEBUG),yes)
CXXFLAGS += -DREG_DBG_CUDA
LDFLAGS += -lnvToolsExt
endif
ifdef GPU_VERSION
NVCCFLAGS += -gencode arch=compute_$(GPU_VERSION),code=sm_$(GPU_VERSION)
endif
else
$(error This branch only supports GPU build)
endif
PETSC_DIR ?= ./deps/lib
INCLUDES += $(PETSC_DIR)/include
LIBRARIES += $(PETSC_DIR)/lib
LDFLAGS += -lpetsc -lf2clapack -lf2cblas
#python build needs shared library
PYTHON_DIR = /usr/include/python3.5
BUILD_SHARED ?= no
ifeq ($(BUILD_PYTHON),yes)
override BUILD_SHARED = yes
INCLUDES += $(PYTHON_DIR)
endif
GIT_VERSION := $(shell git describe --abbrev=4 --always --tags)
CXXFLAGS += -DGIT_VERSION=$(GIT_VERSION)
CXXFLAGS += -Wall -Wno-unused-function -c -std=$(CPP_VERSION)
ifeq ($(WITH_DEBUG), yes)
CXXFLAGS += -g
else
CXXFLAGS += -O3
#CXXFLAGS += -march=native
CXXFLAGS += -fopenmp
endif
#link ACCFFT and FFTW if not building for GPUs
ifneq ($(BUILD_GPU), yes)
FFTW_DIR ?= ./
ACCFFT_DIR ?= ./
INCLUDES += $(FFTW_DIR)/include
INCLUDES += $(ACCFFT_DIR)/include
LIBRARIES += $(FFTW_DIR)/lib
LIBRARIES += $(ACCFFT_DIR)/lib
LDFLAGS += -lfftw3_threads -lfftw3 -laccfft -laccfft_utils
ifneq ($(WITH_DOUBLE), yes)
LDFLAGS += -lfftw3f_threads -lfftw3f
endif
endif
ifeq ($(BUILD_SHARED), yes)
CXXFLAGS += -fPIC
#LDFLAGS += -shared
endif
ifeq ($(WITH_NIFTI), yes)
CXXFLAGS += -DREG_HAS_NIFTI
NIFTI_DIR ?= ./deps/lib
ZLIB_DIR ?= ./
INCLUDES += $(NIFTI_DIR)/include/nifti
LIBRARIES += $(NIFTI_DIR)/lib
LIBRARIES += $(ZLIB_DIR)/lib
LDFLAGS += -lnifticdf -lniftiio -lznz -lz
endif
ifeq ($(WITH_PNETCDF), yes)
CXXFLAGS += -DREG_HAS_PNETCDF
PNETCDF_DIR ?= ./
INCLUDES += $(PNETCDF_DIR)/include
LIBRARIES += $(PNETCDF_DIR)/lib
LDFLAGS += -lpnetcdf
endif
ifeq ($(BUILD_SHARED),yes)
LDFLAGS += -lclaire
endif
CACHE = "$(BUILD_GPU) $(BUILD_TEST) $(BUILD_PYTHON) $(WITH_NIFTI) $(WITH_PNETCDF) $(WITH_DOUBLE) $(WITH_DEBUG) $(BUILD_SHARED) $(WITH_DEBUG) $(BUILD_TARGET) $(GPU_VERSION) $(shell uname -a)"
OLD_CACHE = "$(shell touch make.cache; cat make.cache)"
ifneq ($(strip $(OLD_CACHE)), $(strip $(CACHE)))
PRESTEPS += clean
endif