Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
167 lines (147 loc) · 5.29 KB
/
Copy pathmakefile
File metadata and controls
167 lines (147 loc) · 5.29 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
###########################################################
# 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)
# nvcc supports -MMD only on Linux.
DEPFLAGS = -MD
else # For linux
CFLAGS = -std=c++14 -O3 $(CUDA_ARCH) -Xcompiler="$(WARN_FLAGS)"
DEPFLAGS = -MMD
endif
DEPFLAGS += -MP -MF $(basename $@).d -MT $@
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
TB_LIBS = -lcublas -lcusolver
NEP_LIBS =
GNEP_LIBS =
ifndef OS
LIBS += -lpthread
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 integrate/*/*.cu) \
$(wildcard mc/*.cu) \
$(wildcard force/*.cu) \
$(wildcard force/*/*.cu) \
$(wildcard measure/*.cu) \
$(wildcard measure/*/*.cu) \
$(wildcard model/*.cu) \
$(wildcard utilities/*.cu) \
$(wildcard utilities/*/*.cu)
SOURCES_NEP = \
$(wildcard main_nep/*.cu) \
$(wildcard main_nep/*/*.cu) \
$(wildcard utilities/*.cu) \
$(wildcard utilities/*/*.cu)
SOURCES_GNEP = \
$(wildcard main_gnep/*.cu) \
$(wildcard utilities/*.cu) \
$(wildcard utilities/*/*.cu)
SOURCES_TB = \
$(wildcard main_tb/*.cu) \
utilities/error.cu \
utilities/main_common.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_TB = $(SOURCES_TB:.cu=.obj)
OBJ_GNEP = $(SOURCES_GNEP:.cu=.obj)
else
OBJ_GPUMD = $(SOURCES_GPUMD:.cu=.o)
OBJ_NEP = $(SOURCES_NEP:.cu=.o)
OBJ_TB = $(SOURCES_TB:.cu=.o)
OBJ_GNEP = $(SOURCES_GNEP:.cu=.o)
endif
###########################################################
# compiler-generated header dependencies
###########################################################
OBJECTS = $(sort $(OBJ_GPUMD) $(OBJ_NEP) $(OBJ_TB) $(OBJ_GNEP))
DEPFILES = $(addsuffix .d,$(basename $(OBJECTS)))
###########################################################
# executables
###########################################################
all: gpumd nep tb
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 =================================================
tb: $(OBJ_TB)
$(CC) $(LDFLAGS) $^ -o $@ $(TB_LIBS)
@echo =================================================
@echo The tb executable is successfully compiled!
@echo =================================================
###########################################################
# rules for building object files
###########################################################
ifdef OS # for Windows
$(OBJECTS): %.obj: %.cu
$(CC) $(CFLAGS) $(INC) $(DEPFLAGS) -c $< -o $@
else # for Linux
$(OBJECTS): %.o: %.cu
$(CC) $(CFLAGS) $(INC) $(DEPFLAGS) -c $< -o $@
endif
# Rebuild objects whose dependency files are missing, including older builds.
$(foreach obj,$(OBJECTS),$(if $(wildcard $(basename $(obj)).d),,$(obj))): FORCE
.PHONY: all clean FORCE
FORCE:
# Keep dependency targets after all so they cannot change the default goal.
-include $(wildcard $(DEPFILES))
###########################################################
# clean up
###########################################################
clean:
ifdef OS
del /s *.obj *.d *.exp *.lib *.exe
else
rm -f */*.o */*/*.o */*.d */*/*.d gpumd nep gnep tb
endif