This repository has been archived by the owner on May 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 423
/
Makefile
124 lines (100 loc) · 2.95 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
ifndef config
ifdef CXXNET_CONFIG
config = $(CXXNET_CONFIG)
else ifneq ("$(wildcard ./config.mk)","")
config = config.mk
else
config = make/config.mk
endif
endif
# use customized config file
include $(config)
# all tge possible warning tread
WARNFLAGS= -Wall -Wno-unused-parameter -Wno-unknown-pragmas
CFLAGS = -g -O3 -msse3 -funroll-loops -I./mshadow/ -fopenmp
CFLAGS += -DMSHADOW_FORCE_STREAM $(WARNFLAGS)
LDFLAGS = -lm -lz -pthread
NVCCFLAGS = --use_fast_math -g -O3 -ccbin $(CXX)
ifeq ($(USE_CUDA), 0)
CFLAGS += -DMSHADOW_USE_CUDA=0
else
LDFLAGS += -lcudart -lcublas -lcurand
endif
ifneq ($(USE_CUDA_PATH), NONE)
CFLAGS += -I$(USE_CUDA_PATH)/include
LDFLAGS += -L$(USE_CUDA_PATH)/lib64
endif
ifeq ($(USE_BLAS), mkl)
LDFLAGS += -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5
else
CFLAGS += -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0
endif
ifeq ($(USE_BLAS), openblas)
LDFLAGS += -lopenblas
else ifeq ($(USE_BLAS), atlas)
LDFLAGS += -lcblas
else ifeq ($(USE_BLAS), blas)
LDFLAGS += -lblas
endif
# setup opencv
ifeq ($(USE_OPENCV),1)
CFLAGS+= -DCXXNET_USE_OPENCV=1
LDFLAGS+= `pkg-config --libs opencv`
else
CFLAGS+= -DCXXNET_USE_OPENCV=0
endif
# customize cudnn path
ifeq ($(USE_CUDNN), 1)
CFLAGS += -DCXXNET_USE_CUDNN=1
endif
ifneq ($(USE_CUDNN_PATH), NONE)
CFLAGS += -I$(USE_CUDNN_PATH)
LDFLAGS += -L$(USE_CUDNN_PATH) -lcudnn
endif
ifneq ($(ADD_CFLAGS), NONE)
CFLAGS += $(ADD_CFLAGS)
endif
ifneq ($(ADD_LDFLAGS), NONE)
LDFLAGS += $(ADD_LDFLAGS)
endif
ifeq ($(USE_DIST_PS),1)
CFLAGS+= -DMSHADOW_DIST_PS=1
else
CFLAGS+= -DMSHADOW_DIST_PS=0
endif
# specify tensor path
BIN = bin/cxxnet
OBJ = layer_cpu.o updater_cpu.o nnet_cpu.o data.o main.o nnet_ps_server.o
CUOBJ = layer_gpu.o updater_gpu.o nnet_gpu.o
CUBIN =
ifeq ($(USE_CUDA), 0)
CUDEP =
else
CUDEP = $(CUOBJ)
endif
.PHONY: clean all
ifeq ($(USE_DIST_PS), 1)
BIN += bin/cxxnet.ps
endif
all: $(BIN)
layer_cpu.o layer_gpu.o: src/layer/layer_impl.cpp src/layer/layer_impl.cu\
src/layer/*.h src/layer/*.hpp src/utils/*.h src/plugin/*.hpp
updater_cpu.o updater_gpu.o: src/updater/updater_impl.cpp src/updater/updater_impl.cu\
src/layer/layer.h src/updater/*.hpp src/updater/*.h src/utils/*.h
nnet_cpu.o nnet_gpu.o: src/nnet/nnet_impl.cpp src/nnet/nnet_impl.cu src/layer/layer.h\
src/updater/updater.h src/utils/*.h src/nnet/*.hpp src/nnet/*.h
nnet_ps_server.o: src/nnet/nnet_ps_server.cpp src/utils/*.h src/nnet/*.hpp src/nnet/*.h
data.o: src/io/data.cpp src/io/*.hpp
main.o: src/cxxnet_main.cpp
bin/cxxnet: src/local_main.cpp $(OBJ) $(CUDEP)
bin/cxxnet.ps: $(OBJ) $(CUDEP) libps.a libps_main.a
$(BIN) :
$(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.a, $^) $(LDFLAGS)
$(OBJ) :
$(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) )
$(CUOBJ) :
$(NVCC) -c -o $@ $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" $(filter %.cu, $^)
$(CUBIN) :
$(NVCC) -o $@ $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" -Xlinker "$(LDFLAGS)" $(filter %.cu %.cpp %.o, $^)
clean:
$(RM) $(OBJ) $(BIN) $(CUBIN) $(CUOBJ) *~ */*~ */*/*~