forked from ternaus/quest-qmc
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
203 lines (152 loc) · 5.52 KB
/
Makefile
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
############################################################################
# QUEST Makefile
############################################################################
QUEST_DIR = $(shell pwd)
# 1) gnu, 2) intel
COMPILER = intel
# 1) default, 2) mkl_seq, 3) mkl_par 4) intel
LAPACK = intel
# intel MKL library path
MKLPATH = $(MKLROOT)/lib/intel64
# MAGMA library path
MAGMAPATH =
# nVidia CUDA installation path
CUDAPATH =
# Checkboard decomposition
FLAG_CKB = #-DDQMC_CKB
# GPU version equal-time Green's function kernel
#FLAG_ASQRD = -DDQMC_ASQRD
# GPU version time-dependent Green's function kernel
FLAG_BSOFI = #-DDQMC_BSOFI
# Enabling nVidia CUDA support in DQMC
FLAG_CUDA = #-DDQMC_CUDA
# --------------------------------------------------------------------------
# Check ASQRD and CKB compatibility
# --------------------------------------------------------------------------
ifdef FLAG_ASQRD
ifdef FLAG_CKB
$(error ASQRD method does not support checkerboard decomposition at the moment. \
Please turn off the flag FLAG_CKB or FLAG_ASQRD)
endif
endif
# --------------------------------------------------------------------------
# Compiler and flags
# --------------------------------------------------------------------------
ifndef COMPILER
$(error "COMPILER" is not defined in the Makefile.)
endif
ifeq ($(COMPILER), intel)
FC = ifort
CXX = icpc
FC_FLAGS = -m64 -warn all -O3 -unroll
#FC_FLAGS = -m64 -g -traceback -check all -O0 -ftrapuv -debug all
#CXX_FLAGS = -m64 -g -traceback -O0 -check-uninit -ftrapuv -debug all
CXX_FLAGS = -m64 -Wall -O3 -unroll $(CUDAINC) $(MAGMAINC)
endif
ifeq ($(COMPILER), gnu)
FC = gfortran
CXX = g++
FC_FLAGS = -std=legacy -fopenmp -m64 -Wall -O3 -funroll-loops
CXX_FLAGS = -m64 -Wall -O3 -funroll-loops $(CUDAINC) $(MAGMAINC)
endif
# --------------------------------------------------------------------------
# C++ libraries
# --------------------------------------------------------------------------
CXXLIB = -lstdc++ #-lrt
# --------------------------------------------------------------------------
# BLAS and LAPACK
# --------------------------------------------------------------------------
ifndef LAPACK
$(error "LAPACK" is not defined in the Makefile.)
endif
ifeq ($(LAPACK), default)
libOpenBLAS = $(QUEST_DIR)/OpenBLAS/libopenblas.a
# Pass if the target is 'clean' or 'lapack'
ifneq ($(MAKECMDGOALS), clean)
ifneq ($(MAKECMDGOALS), lapack)
ifeq ($(wildcard $(libOpenBLAS)),)
$(error It appears that LAPACK is set to be "default", but libopenblas.a is missing. \
Use "make lapack" to build the required library.)
endif
endif
endif
LAPACKLIB = $(libOpenBLAS)
endif
ifeq ($(LAPACK), mkl_seq)
ifdef MKLPATH
#LAPACKLIB = -L$(MKLPATH) -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread
LAPACKLIB = -L$(MKLPATH) -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread
else
$(error "MKLPATH" is not defined in the Makefile.)
endif
endif
ifeq ($(LAPACK), mkl_par)
ifdef MKLPATH
LAPACKLIB = -L$(MKLPATH) -mkl:parallel -lpthread
else
$(error "MKLPATH" is not defined in the Makefile.)
endif
endif
ifeq ($(LAPACK), intel)
LAPACKLIB = -mkl=sequential -static-intel
endif
# --------------------------------------------------------------------------
# MAGMA library path
# --------------------------------------------------------------------------
ifdef MAGMAPATH
MAGMALIB = -L$(MAGMAPATH)/lib -lmagma -lmagmablas -lmagma
MAGMAINC = -I$(MAGMAPATH)/include
endif
# --------------------------------------------------------------------------
# CUDA compiler and libraries
# --------------------------------------------------------------------------
ifdef CUDAPATH
ifeq ($(MAGMAINC),)
$(error In Makefile, variable MAGMATH is not defined in Makefile)
endif
NVCC = $(CUDAPATH)/bin/nvcc
CU_FLAGS = -O3 -Xptxas -v -m 64 -arch sm_20 $(MAGMAINC)
CUDALIB = -L$(CUDAPATH)/lib64 -lcublas -lcudart -lcuda
CUDAINC = -I$(CUDAPATH)/include
endif
# --------------------------------------------------------------------------
# DQMC library
# --------------------------------------------------------------------------
DQMCLIB = libdqmc.a
# --------------------------------------------------------------------------
# Libraries required by driver routines
# --------------------------------------------------------------------------
LIB = $(CXXLIB) $(LAPACKLIB) $(CUDALIB) $(MAGMALIB)
INC = $(MPIINC)
# --------------------------------------------------------------------------
# Archiver and flags
# --------------------------------------------------------------------------
ifeq ($(COMPILER), intel)
ARCH = xiar
else ifeq ($(COMPILER), gnu)
ARCH = ar
endif
ARFLAG = cr
RANLIB = ranlib
# --------------------------------------------------------------------------
# Optional complication flags
# -D_SXX, -D_QMC_MPI
# --------------------------------------------------------------------------
PRG_FLAGS = $(FLAG_BSOFI) $(FLAG_ASQRD) $(FLAG_CKB) $(FLAG_CUDA)
FLAGS = $(FC_FLAGS) $(PRG_FLAGS)
# --------------------------------------------------------------------------
export
.PHONY: libdqmc example libopenblas clean
all : libdqmc example
libdqmc :
(cd SRC; $(MAKE))
example : libdqmc
(cd EXAMPLE; $(MAKE))
lapack : libopenblas
libopenblas :
(cd $(QUEST_DIR)/OpenBLAS; $(MAKE))
clean :
(cd $(QUEST_DIR)/OpenBLAS; $(MAKE) clean)
(cd $(QUEST_DIR)/SRC; $(MAKE) clean)
(cd $(QUEST_DIR)/EXAMPLE; $(MAKE) clean)
(rm -f $(QUEST_DIR)/$(DQMCLIB))