Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Enhencement on build (#4760)
Browse files Browse the repository at this point in the history
  • Loading branch information
howard0su authored and piiswrong committed Jan 22, 2017
1 parent ead4be4 commit 04be299
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 48 deletions.
22 changes: 12 additions & 10 deletions amalgamation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ export OPENBLAS_ROOT=/usr/local/opt/openblas
# Whether use minimum build without blas and SSE, this will make the library super slow
ifndef MIN
export MIN=0
DEFS=-DMSHADOW_USE_CBLAS=1
else
DEFS=-DMSHADOW_USE_CBLAS=0
endif

ifndef ANDROID
export ANDROID=0
else
DEFS+=-DMSHADOW_USE_SSE=0
endif


.PHONY: all clean


CFLAGS=-std=c++11 -Wno-unknown-pragmas -Wall
DEFS+=-DMSHADOW_USE_CUDA=0 -DMSHADOW_USE_MKL=0 -DMSHADOW_RABIT_PS=0 -DMSHADOW_DIST_PS=0 -DMSHADOW_FORCE_STREAM -DMXNET_USE_OPENCV=1 -DMXNET_PREDICT_ONLY=1 -DDISABLE_OPENMP=1
CFLAGS=-std=c++11 -Wno-unknown-pragmas -Wall $(DEFS)
ifneq ($(MIN), 1)
CFLAGS += -I${OPENBLAS_ROOT} -I${OPENBLAS_ROOT}/include
LDFLAGS+= -L${OPENBLAS_ROOT} -L${OPENBLAS_ROOT}/lib -lopenblas
Expand All @@ -28,21 +33,19 @@ nnvm.d:
./prep_nnvm.sh

dmlc.d: dmlc-minimum0.cc
${CXX} ${CFLAGS} -MD -MF $@ \
${CXX} ${CFLAGS} -M -MT dmlc-minimum0.o \
-I ${MXNET_ROOT}/dmlc-core/include \
-D__MIN__=$(MIN) -c $+
rm dmlc-minimum0.o
-D__MIN__=$(MIN) $+ > dmlc.d


mxnet_predict0.d: mxnet_predict0.cc nnvm.d dmlc.d
${CXX} ${CFLAGS} -MD -MF $@ \
${CXX} ${CFLAGS} -M -MT mxnet_predict0.o \
-I ${MXNET_ROOT}/ -I ${MXNET_ROOT}/mshadow/ -I ${MXNET_ROOT}/dmlc-core/include \
-I ${MXNET_ROOT}/nnvm/include \
-I ${MXNET_ROOT}/include \
-D__MIN__=$(MIN) -c mxnet_predict0.cc
-D__MIN__=$(MIN) mxnet_predict0.cc > mxnet_predict0.d
cat dmlc.d >> mxnet_predict0.d
cat nnvm.d >> mxnet_predict0.d
rm mxnet_predict0.o

mxnet_predict-all.cc: mxnet_predict0.d dmlc-minimum0.cc nnvm.cc mxnet_predict0.cc
@echo "Generating amalgamation to " $@
Expand All @@ -61,7 +64,6 @@ jni_libmxnet_predict.so: jni_libmxnet_predict.o
${CXX} ${CFLAGS} -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)

ifneq ($(ANDROID), 1)
LDFLAGS+= -lrt
android:
else
CFLAGS+= -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -O3
Expand All @@ -70,7 +72,7 @@ else
endif

libmxnet_predict.js: mxnet_predict-all.cc
emcc -std=c++11 -O2 -D__MXNET_JS__ -o $@ $+ \
emcc -std=c++11 -O2 $(DEFS) -DMSHADOW_USE_SSE=0 -D__MXNET_JS__ -o $@ $+ \
-s EXPORTED_FUNCTIONS="['_MXPredCreate', '_MXPredGetOutputShape', '_MXPredSetInput', '_MXPredForward', '_MXPredPartialForward', '_MXPredGetOutput', '_MXPredFree', '_MXNDListCreate', '_MXNDListGet', '_MXNDListFree']" \
-s ALLOW_MEMORY_GROWTH=1

Expand Down
24 changes: 0 additions & 24 deletions amalgamation/mxnet_predict0.cc
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
// mexnet.cc

#define MSHADOW_FORCE_STREAM

#ifndef MSHADOW_USE_CBLAS
#if (__MIN__ == 1)
#define MSHADOW_USE_CBLAS 0
#else
#define MSHADOW_USE_CBLAS 1
#endif
#endif

#define MSHADOW_USE_CUDA 0
#define MSHADOW_USE_MKL 0
#define MSHADOW_RABIT_PS 0
#define MSHADOW_DIST_PS 0

#if defined(__ANDROID__) || defined(__MXNET_JS__)
#define MSHADOW_USE_SSE 0
#endif

#define MXNET_USE_OPENCV 0
#define MXNET_PREDICT_ONLY 1
#define DISABLE_OPENMP 1


#include "src/ndarray/ndarray_function.cc"
#include "src/ndarray/ndarray.cc"

Expand Down
15 changes: 1 addition & 14 deletions amalgamation/prep_nnvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,7 @@ cd ../nnvm/amalgamation
make clean
make nnvm.d
cp nnvm.d ../../amalgamation/
echo '#define MSHADOW_FORCE_STREAM
#ifndef MSHADOW_USE_CBLAS
#if (__MIN__ == 1)
#define MSHADOW_USE_CBLAS 0
#else
#define MSHADOW_USE_CBLAS 1
#endif
#endif
#define MSHADOW_USE_CUDA 0
#define MSHADOW_USE_MKL 0
#define MSHADOW_RABIT_PS 0
#define MSHADOW_DIST_PS 0
echo '
#include "mshadow/tensor.h"
#include "mxnet/base.h"
#include "dmlc/json.h"
Expand Down

0 comments on commit 04be299

Please sign in to comment.