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

remove MKL_EXPERIMENTAL and update make files for MKL-DNN#9810

Merged
marcoabreu merged 8 commits intoapache:masterfrom
ashokei:mklml_make
Feb 25, 2018
Merged

remove MKL_EXPERIMENTAL and update make files for MKL-DNN#9810
marcoabreu merged 8 commits intoapache:masterfrom
ashokei:mklml_make

Conversation

@ashokei
Copy link
Copy Markdown
Contributor

@ashokei ashokei commented Feb 16, 2018

Description

remove MKL_EXPERIMENTAL and update make files for MKL-DNN

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)

Changes

  • remove MKL_EXPERIMENTAL and update make files for MKL-DNN

@ashokei ashokei requested a review from szha as a code owner February 16, 2018 18:16
@ashokei
Copy link
Copy Markdown
Contributor Author

ashokei commented Feb 16, 2018

@zheng-da @piiswrong can you please review ... these are minor changes to remove old references to MKL_EXPERIMENTAL and minor updates to other make/doc changes. thanks!

Comment thread MKL_README.md

4. Navigate into the python directory

5. Run 'sudo python setup.py install'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to remove this part? We still need to link to MKL for BLAS, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, i added full MKL related instructions back.

Comment thread docs/faq/perf.md
both `USE_MKL2017 = 1` and `USE_MKL2017_EXPERIMENTAL = 1` in
`config.mk`. Check
[MKL_README.md](https://github.com/dmlc/mxnet/blob/master/MKL_README.md) for
details.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to measure the performance of MKLDNN.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, probably a separate PR, as there are other changes too (MXNet changes/op-refactor etc), not just MKL-DNN. We also have new AWS instance type, it would be nice to add AVX512 instance numbers.

Comment thread MKL_README.md

5. Run 'sudo python setup.py install'

# MKL2017 PLUGIN
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be new documentation about MKLDNN instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with new MKL-DNN integration, the installation has been tightly integrated (eg: mkl-dnn is a sub-module), no separate instructions are needed; the user just has to pass USE_MKLDNN=1 or modify config.mk or cmake (just as other options).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcoabreu @ashokei I'd like to create a new page (documentation) for MKL-DNN to introduce the installation, feature, performance, coverage, etc.
But we can make this page as-is now and I will back a new PR :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks @pengzhao-intel

# use openmp for parallelization
USE_OPENMP = 1

# MKL ML Library for Intel CPU/Xeon Phi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing MKL flags from any arm cross compilation configs should be ok. Thanks for updating.

@pengzhao-intel
Copy link
Copy Markdown
Contributor

@ashokei there's a test for MKLML installation, tests/python/cpu/test_mklml.py.
Is it possible to update this for MKL-DNN?

# use openmp for parallelization
USE_OPENMP = 1

# MKL ML Library for Intel CPU/Xeon Phi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing MKL flags from any arm cross compilation configs should be ok. Thanks for updating.

@rahul003 rahul003 mentioned this pull request Feb 20, 2018
6 tasks
@ashokei
Copy link
Copy Markdown
Contributor Author

ashokei commented Feb 20, 2018

@szha i addressed all the review comments, can you please take a look/approve if ok. thanks!

@rahul003
Copy link
Copy Markdown
Member

rahul003 commented Feb 20, 2018

Would it be possible to fix the CMake build with MKLDNN too? It says mkldnn.hpp not found.

/Users/huilgolr/mxnet/include/mxnet/./ndarray.h:41:10: fatal error: 'mkldnn.hpp' file not found
#include <mkldnn.hpp>

ifeq ($(USE_MKL2017), 0)
USE_STATIC_MKL = NONE
ifeq ($(USE_BLAS), mkl)
USE_STATIC_MKL = 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why we use static link when use MKL as blas? Is there any mkl related function could not be supported by mklml library (I remembered we used dynamic link to mklml library instead of static link to mkl library before for MKL2017, any change so we need to use static link)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full MKL supports static lib option, the above flag enables that option. mklml only support dynamic; i believe both support all blas API.

Copy link
Copy Markdown
Contributor

@jinhuang415 jinhuang415 Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification, so do you mean USE_BLAS=mkl is used for using full MKL as blas library (and using static link)? If we want to use mklml as blas library (it is more light weighted if it support all blas API), how should we set the compile option?

I also notice there is some potential conflict here, if set USE_MKLDNN=1 and USE_BLAS=mkl, looks the generated libmxnet.so will both static link to mkl library and dynamic link to mklml library:
Static link to mkl library:
mshadow.mk line 63
MSHADOW_LDFLAGS += -L${MKLROOT}/../compiler/lib/intel64 -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -liomp5 -ldl -lpthread -lm

Dynamic link to mklml library:
mshadow.mk line 78:
MSHADOW_LDFLAGS += -Wl,--as-needed -lmklml_intel -lmklml_gnu

Is there any potential conflict here or indicate some issue need to fix? If both MKL and MKLML library could provide the blas API, which library it will use?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please respond to this que

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jinhuang415 @marcoabreu
MSHADOW can use MKLML (which is automatically selected when users build with MKLDNN); USE_BLAS=mkl is specifically for full mkl (not related to MKLML or MKLDNN). So there is no conflict here; Either of those options support full BLAS compatible API;

mshadow handles both of these cases already; This PR or MKL-DNN integration PR , do not change this behavior. It is the same as before.

As @zheng-da mentioned, we can modify mshadow to directly use MKL-DNN build flag in another PR. It wasnt done before, as we did not have MKL-DNN integration (we do now).

This PR scope is limited to removing MKL_EXPERIMENTAL and cleaning up minor make file left overs.

@@ -45,14 +45,14 @@ def test_mklml_install():

pid = os.getpid()
rc = os.system("cat /proc/" + str(pid) + \
"/maps | grep libmklml_ > /dev/null")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if we still linked to libmklml_* library even for mkldnn case? If so we also need to add the check for libmklml_* library?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically MKL-DNN can be used without mklml, though we recommend users use both together for best performance.

@zheng-da
Copy link
Copy Markdown
Contributor

@rahul003 cmake should work with mkldnn. mkldnn is a submodule in 3rdparty. did you update update mkldnn with git submodule update?

Copy link
Copy Markdown
Contributor

@marcoabreu marcoabreu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a Jenkins compile job (doesn't have to be run by unittests) that uses CMake with MKLDNN? Just take https://github.com/apache/incubator-mxnet/blob/master/Jenkinsfile#L263, copy it and enable the MKL flags.

@ashokei
Copy link
Copy Markdown
Contributor Author

ashokei commented Feb 23, 2018

@marcoabreu can you please review requested Jenkins file changes; This PR is primarily targeting at removing MKL_EXPERIMENTAL and minor changes to regular makefiles; we may do a separate PR for cmake mkldnn build as required. thanks!

Comment thread Jenkinsfile Outdated
mx_lib = 'lib/libmxnet.so, lib/libmxnet.a, dmlc-core/libdmlc.a, nnvm/lib/libnnvm.a'
// mxnet cmake libraries, in cmake builds we do not produce a libnvvm static library by default.
mx_cmake_lib = 'build/libmxnet.so, build/libmxnet.a, build/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so'
mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, /usr/local/lib/libiomp5.so, /usr/local/lib/libmklml_gnu.so, build/3rdparty/mkldnn/install/lib/libmkldnn.so, build/3rdparty/mkldnn/install/lib/libmkldnn.so.0, /usr/local/lib/libmklml_intel.so'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we are generating files outside the source directory. This could cause issues because I would not assume that a compile process writes files to /usr/local or any other place outside of the source directory. Since I don't have much experience with cmake, I'd like to ask @larroy and @cjolivier01 for assistance here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjolivier01 /usr/local/lib/libiomp5.so /usr/local/lib/libmklml_gnu.so /usr/local/lib/libmklml_intel.so

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beats me — ask the Intel guys

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. But is this an industry standard or would you expect all artefacts to be written into the source dir?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjolivier01
Copy link
Copy Markdown
Member

cjolivier01 commented Feb 23, 2018 via email

@ashokei
Copy link
Copy Markdown
Contributor Author

ashokei commented Feb 23, 2018

@marcoabreu jenkins issue is fixed, it passes the build.

@ashokei
Copy link
Copy Markdown
Contributor Author

ashokei commented Feb 24, 2018

@marcoabreu i made suggested changes...can you please review/merge if ok.

Copy link
Copy Markdown
Contributor

@marcoabreu marcoabreu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. Please address the open questions

rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* replace MKL2017 references with MKL-DNN

* remove MKLML_ROOT

* MKL_README.md for Full MKL

* update test_mkldnn

* update Jenkinsfile

* update jenkins

* trigger Jenkins with new changes

* trigger Jenkins with new changes
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* replace MKL2017 references with MKL-DNN

* remove MKLML_ROOT

* MKL_README.md for Full MKL

* update test_mkldnn

* update Jenkinsfile

* update jenkins

* trigger Jenkins with new changes

* trigger Jenkins with new changes
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants