-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build mkldnn as static lib on mac/linux #13197
Changes from 24 commits
b8a0203
bc6c482
15a41fc
42b3353
5af258a
32ab9ce
e2422d6
372f697
67e4dff
150b324
890cf1d
89b11c6
f29c254
40fd0ac
0302290
23fd7d9
d103ec8
c9e8bd2
0d0f407
b300b88
b336ef0
b9be823
46ee0bd
45e8cd8
ed31e12
6a02949
13304ba
530a82c
1172bc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,8 +131,13 @@ ifeq ($(USE_MKLDNN), 1) | |
CFLAGS += -I$(MKLROOT)/include | ||
LDFLAGS += -L$(MKLROOT)/lib | ||
endif | ||
CFLAGS += -I$(MKLDNNROOT)/include | ||
LDFLAGS += -L$(MKLDNNROOT)/lib -lmkldnn -Wl,-rpath,'$${ORIGIN}' | ||
|
||
ifneq ($(UNAME_S), Windows) | ||
LIB_DEP += $(MKLDNNROOT)/lib/libmkldnn.a | ||
else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation does not look right, could you please double check? |
||
CFLAGS += -I$(MKLDNNROOT)/include | ||
LDFLAGS += -L$(MKLDNNROOT)/lib -lmkldnn -Wl,-rpath,'$${ORIGIN}' | ||
endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's for the ifeq on line 126. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why isn't this aligned with L126 then? |
||
endif | ||
|
||
# setup opencv | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,20 @@ ifeq ($(USE_MKLDNN), 1) | |
MKLDNN_SUBMODDIR = $(ROOTDIR)/3rdparty/mkldnn | ||
MKLDNN_BUILDDIR = $(MKLDNN_SUBMODDIR)/build | ||
MXNET_LIBDIR = $(ROOTDIR)/lib | ||
MKLDNN_LIBRARY_TYPE=STATIC | ||
ifeq ($(UNAME_S), Darwin) | ||
OMP_LIBFILE = $(MKLDNNROOT)/lib/libiomp5.dylib | ||
MKLML_LIBFILE = $(MKLDNNROOT)/lib/libmklml.dylib | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.0.dylib | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.a | ||
else ifeq ($(UNAME_S), Windows) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NVM, seems this is correct syntax in Makefile. |
||
OMP_LIBFILE = $(MKLDNNROOT)/lib/libiomp5.so | ||
MKLML_LIBFILE = $(MKLDNNROOT)/lib/libmklml_intel.so | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.so | ||
MKLDNN_LIBRARY_TYPE=SHARED | ||
else | ||
OMP_LIBFILE = $(MKLDNNROOT)/lib/libiomp5.so | ||
MKLML_LIBFILE = $(MKLDNNROOT)/lib/libmklml_intel.so | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.so.0 | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.a | ||
endif | ||
endif | ||
|
||
|
@@ -37,7 +43,7 @@ mkldnn_build: $(MKLDNN_LIBFILE) | |
$(MKLDNN_LIBFILE): | ||
mkdir -p $(MKLDNNROOT) | ||
cd $(MKLDNN_SUBMODDIR) && rm -rf external && cd scripts && ./prepare_mkl.sh && cd .. && cp -a external/*/* $(MKLDNNROOT)/. | ||
cmake $(MKLDNN_SUBMODDIR) -DCMAKE_INSTALL_PREFIX=$(MKLDNNROOT) -B$(MKLDNN_BUILDDIR) -DARCH_OPT_FLAGS="-mtune=generic" -DWITH_TEST=OFF -DWITH_EXAMPLE=OFF | ||
cmake $(MKLDNN_SUBMODDIR) -DCMAKE_INSTALL_PREFIX=$(MKLDNNROOT) -B$(MKLDNN_BUILDDIR) -DARCH_OPT_FLAGS="-mtune=generic" -DWITH_TEST=OFF -DWITH_EXAMPLE=OFF -DMKLDNN_LIBRARY_TYPE=$(MKLDNN_LIBRARY_TYPE) | ||
$(MAKE) -C $(MKLDNN_BUILDDIR) VERBOSE=1 | ||
$(MAKE) -C $(MKLDNN_BUILDDIR) install | ||
mkdir -p $(MXNET_LIBDIR) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
from mxnet import gluon | ||
from mxnet.gluon import nn | ||
from mxnet.test_utils import * | ||
import test_mkldnn_install as install | ||
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) | ||
sys.path.append(os.path.join(curr_path, '../unittest/')) | ||
from common import with_seed | ||
|
@@ -441,7 +440,4 @@ def backward(self, req, out_grad, in_data, out_data, in_grad, aux): | |
custom = mx.symbol.Custom(name='custom', data=conv, op_type='custom') | ||
exec1 = custom.bind(mx.cpu(), args={'data': mx.nd.ones([10,3,96,96]), 'conv_weight': mx.nd.ones([8,3,5,5])}) | ||
exec1.forward()[0].wait_to_read() | ||
|
||
|
||
if __name__ == '__main__': | ||
install.test_mkldnn_install() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need make sure about the purpose of a test case before removing it. If this case is just for verifying whether MKL-DNN so is correctly linked, I'm OK with removing it. Otherwise, need replace it with something else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test looks if mkldnn appears on the memory table of the process running mxnet.I have verified manually (by the second part of this just checks the response code (rc - probably to make sure the proc/{id}/maps file even exists). @pengzhao-intel is there another reason this test was added |
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a reason here, on why on Windows, it is dynamically linked for future maintenance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for adding comments. Also curious about how MKL BLAS is linked on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated comment in #13503.