-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.mpi
110 lines (97 loc) · 2.51 KB
/
Makefile.mpi
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
# dirs
OBJDIR=objs
SRCDIR=src
LIBDIR=lib
UNAME=$(shell uname)
HOSTNAME=$(shell hostname)
# compiler
CXX=mpic++
# compile flags
CXXFLAGS+=-O3 -m64 -fopenmp #Wa,-q
ifeq ($(UNAME), Linux)
CXXFLAGS+=-mavx
endif
# include flags
INCFLAGS+=$(foreach d, $(VPATH), -I$d)
INCFLAGS+=-I$(LIBDIR)/glog/include
ifeq ($(HOSTNAME), latedays.andrew.cmu.edu)
INCFLAGS+=-I/opt/openmpi/include
INCFLAGS+=-I$(HOME)/tool/openblas/openblas/include
else
ifneq (,$(findstring andrew.cmu.edu,$(HOSTNAME)))
INCFLAGS+=-I$(HOME)/tool/openmpi/include
INCFLAGS+=-I$(HOME)/tool/openblas/openblas/include
else
ifneq (,$(findstring Zander,$(HOSTNAME)))
INCFLAGS+=-I$(LIBDIR)/openblas/include
endif
endif
endif
# link flags
LDFLAGS+=-lmpi -lmpi_cxx -lgfortran -lpthread -lopenblas -lglog
LDFLAGS+=-L$(LIBDIR)
LDFLAGS+=-L$(LIBDIR)/glog/lib
ifeq ($(HOSTNAME), latedays.andrew.cmu.edu)
LDFLAGS+=-L/opt/openmpi/lib
LDFLAGS+=-L$(HOME)/tool/openblas/openblas/lib
else
ifneq (,$(findstring andrew.cmu.edu,$(HOSTNAME)))
LDFLAGS+=-L$(HOME)/tool/openmpi/lib
LDFLAGS+=-L$(HOME)/tool/openblas/openblas/lib
else
ifneq (,$(findstring Zander,$(HOSTNAME)))
LDFLAGS+=-L$(LIBDIR)/openblas/lib
endif
endif
endif
# vpath
VPATH = $(SRCDIR) \
$(SRCDIR)/config \
$(SRCDIR)/helper \
$(SRCDIR)/sgd \
$(SRCDIR)/layer \
$(SRCDIR)/connection \
$(SRCDIR)/network \
$(SRCDIR)/master \
$(SRCDIR)/slave \
$(SRCDIR)/data
# src files
SRCS=\
$(SRCDIR)/main_mpi.cpp \
$(SRCDIR)/helper/matrix.cpp \
$(SRCDIR)/helper/nonlinearity.cpp \
$(SRCDIR)/sgd/sgd.cpp \
$(SRCDIR)/sgd/adagrad.cpp \
$(SRCDIR)/sgd/adadelta.cpp \
$(SRCDIR)/sgd/rmsprop.cpp \
$(SRCDIR)/layer/rnn_layer.cpp \
$(SRCDIR)/layer/rnn_input_layer.cpp \
$(SRCDIR)/layer/rnn_lstm_layer.cpp \
$(SRCDIR)/layer/rnn_softmax_layer.cpp \
$(SRCDIR)/layer/rnn_mse_layer.cpp \
$(SRCDIR)/connection/rnn_connection.cpp \
$(SRCDIR)/network/rnn_lstm.cpp \
$(SRCDIR)/network/rnn_translator.cpp \
$(SRCDIR)/master/master.cpp \
$(SRCDIR)/slave/slave.cpp \
$(SRCDIR)/data/mnist.cpp \
$(SRCDIR)/data/sequence_data.cpp
# obj files using patsubst matching
OBJS=$(SRCS:%.cpp=%.o)
# nothing to do here
# .PHONY:
# all comes first in the file, so it is the default
all : MPI
# compile main program parallelSGD from all objs
MPI: $(OBJS)
$(CXX) $(CXXFLAGS) $(INCFLAGS) $(LDFLAGS) $^ -o $@
# order-only prerequisites for OBJDIR
$(OBJS): | $(OBJDIR)
$(OBJDIR):
mkdir -p $@
# compile all objs from corresponding %.cpp file and all other *.h files
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCFLAGS) $(LDFLAGS) $< -c -o $@
# clean
clean:
rm -rf $(OBJS) MPI