forked from brucefan1983/GPUMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
191 lines (173 loc) · 6.16 KB
/
Copy pathmakefile
File metadata and controls
191 lines (173 loc) · 6.16 KB
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
###########################################################
# Note:
# 1) You can modify -arch=sm_60 according to
# your GPU architecture. For compute capability < 6.0,
# need to add -DUSE_KEPLER to CFLAGS.
# 2) For Windows systems, if you get errors like
# c1xx : fatal error C1083: Cannot open source file: ...
# You can consider removing -Xcompiler "/wd 4819"
# 3) Add -DUSE_PLUMED to CFLAGS when use the PLUMED plugin
# and remove it otherwise.
###########################################################
###########################################################
# some flags
###########################################################
CC = nvcc
CUDA_ARCH=-arch=sm_60
WARN_FLAGS = -Wall -Wextra
WARN_FLAGS += -Wno-sign-compare -Wno-unused-parameter
WARN_FLAGS += -Wnull-dereference -Wstringop-overflow -Wstringop-truncation -Wrestrict
WARN_FLAGS += -Wduplicated-cond -Wduplicated-branches -Wlogical-op
WARN_FLAGS += -Wsequence-point -Wswitch-default
WARN_FLAGS += -Wcast-align -Wcast-qual -Wvla
WARN_FLAGS += -Wformat -Wformat-security -Wformat-overflow -Wformat-truncation
ifdef OS # For Windows with the cl.exe compiler
CFLAGS = -O3 $(CUDA_ARCH)
else # For linux
CFLAGS = -std=c++14 -O3 $(CUDA_ARCH) -Xcompiler="$(WARN_FLAGS)"
endif
ifeq ($(GNEP_TEST_DIAGNOSTICS),1)
CFLAGS += -DGNEP_TEST_DIAGNOSTICS
endif
ifeq ($(GNEP_TEST_FIXED_SCALER),1)
CFLAGS += -DUSE_FIXED_SCALER
endif
INC = -I./
LDFLAGS =
LIBS = -lcublas -lcusolver -lcufft
NEP_LIBS =
GNEP_LIBS =
ifndef OS
NEP_LIBS += -ldl
GNEP_LIBS += -lpthread
endif
###########################################################
# source files
###########################################################
SOURCES_GPUMD = \
$(wildcard main_gpumd/*.cu) \
$(wildcard minimize/*.cu) \
$(wildcard phonon/*.cu) \
$(wildcard integrate/*.cu) \
$(wildcard mc/*.cu) \
$(wildcard force/*.cu) \
$(wildcard measure/*.cu) \
$(wildcard model/*.cu) \
$(wildcard utilities/*.cu)
SOURCES_NEP = \
$(wildcard main_nep/*.cu) \
$(wildcard utilities/*.cu)
SOURCES_GNEP = \
$(wildcard main_gnep/*.cu) \
$(wildcard utilities/*.cu)
###########################################################
# object files
###########################################################
ifdef OS # For Windows with the cl.exe compiler
OBJ_GPUMD = $(SOURCES_GPUMD:.cu=.obj)
OBJ_NEP = $(SOURCES_NEP:.cu=.obj)
OBJ_GNEP = $(SOURCES_GNEP:.cu=.obj)
else
OBJ_GPUMD = $(SOURCES_GPUMD:.cu=.o)
OBJ_NEP = $(SOURCES_NEP:.cu=.o)
OBJ_GNEP = $(SOURCES_GNEP:.cu=.o)
endif
###########################################################
# headers
###########################################################
HEADERS = \
$(wildcard utilities/*.cuh) \
$(wildcard main_gpumd/*.cuh) \
$(wildcard integrate/*.cuh) \
$(wildcard mc/*.cuh) \
$(wildcard minimize/*.cuh) \
$(wildcard force/*.cuh) \
$(wildcard measure/*.cuh) \
$(wildcard model/*.cuh) \
$(wildcard phonon/*.cuh) \
$(wildcard main_nep/*.cuh) \
$(wildcard main_gnep/*.cuh)
###########################################################
# executables
###########################################################
all: gpumd nep gpumd_replica
.PHONY: all gpumd_replica clean_replica clean
# Keep replica objects separate and share the selected compiler and architecture.
gpumd_replica:
$(MAKE) -C main_replica CC="$(CC)" CUDA_ARCH="$(CUDA_ARCH)"
gpumd: $(OBJ_GPUMD)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
@echo =================================================
@echo The gpumd executable is successfully compiled!
@echo =================================================
nep: $(OBJ_NEP)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS) $(NEP_LIBS)
@echo =================================================
@echo The nep executable is successfully compiled!
@echo =================================================
gnep: $(OBJ_GNEP)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS) $(GNEP_LIBS)
@echo =================================================
@echo The gnep executable is successfully compiled!
@echo =================================================
###########################################################
# rules for building object files
###########################################################
ifdef OS # for Windows
integrate/%.obj: integrate/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
mc/%.obj: mc/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
minimize/%.obj: minimize/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
force/%.obj: force/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
measure/%.obj: measure/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
main_gpumd/%.obj: main_gpumd/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
utilities/%.obj: utilities/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
model/%.obj: model/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
phonon/%.obj: phonon/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
main_nep/%.obj: main_nep/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
main_gnep/%.obj: main_gnep/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
else # for Linux
integrate/%.o: integrate/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
mc/%.o: mc/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
minimize/%.o: minimize/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
force/%.o: force/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
measure/%.o: measure/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
main_gpumd/%.o: main_gpumd/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
utilities/%.o: utilities/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
model/%.o: model/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
phonon/%.o: phonon/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
main_nep/%.o: main_nep/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
main_gnep/%.o: main_gnep/%.cu $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
endif
###########################################################
# clean up
###########################################################
clean_replica:
$(MAKE) -C main_replica clean
clean: clean_replica
ifdef OS
del /s *.obj *.exp *.lib *.exe
else
rm -f */*.o gpumd nep gnep
endif