Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build MKL-DNN against libmklml_gnu? #312

Closed
okapies opened this issue Sep 5, 2018 · 3 comments
Closed

How to build MKL-DNN against libmklml_gnu? #312

okapies opened this issue Sep 5, 2018 · 3 comments
Assignees
Labels
enhancement A feature or an optimization request

Comments

@okapies
Copy link
Contributor

okapies commented Sep 5, 2018

I tried to build MKL-DNN in manylinux, which is CentOS 5 based build environment for Python wheel, to maximize binary portability. But it requires GNU OpenMP instead of Intel OpenMP at build time because iomp5 has a reference to sched_getcpu@GLIBC_2.6 which is not supported in CentOS 5's glibc (version 2.5).

# export LD_LIBRARY_PATH=/usr/local/gcc-4.9.4/lib64:/usr/local/gcc-4.9.4/lib:/usr/local/lib64:/usr/local/lib
# cmake28 -DCMAKE_C_COMPILER=/usr/local/gcc-4.9.4/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/gcc-4.9.4/bin/g++ ..
# make
Linking CXX shared library libmkldnn.so
...
[ 45%] Built target mkldnn
Scanning dependencies of target simple-net-c
[ 45%] Building C object examples/CMakeFiles/simple-net-c.dir/simple_net.c.o
Linking C executable simple-net-c
../../external/mklml_lnx_2019.0.20180710/lib/libiomp5.so: undefined reference to `sched_getcpu@GLIBC_2.6'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/simple-net-c] Error 1
make[1]: *** [examples/CMakeFiles/simple-net-c.dir/all] Error 2
make: *** [all] Error 2

I'd like to:

  1. Use gomp when building MKL-DNN
  2. Use iomp5 at runtime

I digged into CMake files but I can't find an option to enable mklml_gnu and gomp at build time. Could you please tell me how to do it?

@vpirogov
Copy link
Member

vpirogov commented Sep 8, 2018

The build system does not have a knob to build Intel MKL-DNN with libmklml_gnu. Probably the only option as of now is patching the CMake files. I'll consider this to be a feature request. If you decide to go through the exercise of adding the knob yourself we would appreciate a pull request.

You should be able to use libiom5 at runtime with the standard build. The libiomp5 and libgomp are ABI compatible and can be used interchangeably as long as only one is initialized.

@okapies
Copy link
Contributor Author

okapies commented Sep 9, 2018

Thanks! I’ll try it.

@okapies
Copy link
Contributor Author

okapies commented Sep 9, 2018

I think here is another option to remove a tiny dependency to glibc 2.6 from iomp5. It makes easier to bundle MKL-DNN to Python wheel which standardized by PEP 513. What do you think?

mkl-dnn pushed a commit that referenced this issue Oct 12, 2018
Pass `-DMKLDNN_THREADING=OMP:COMP` to cmake for that.
This is one of the steps required to address #312 issue.

By chance, this fixes #313.
The reason: we used ?undocumented? cmake flag [1] to prevent linking
with compilers OMP RT. Apparently this flag stopped working for recent
cmake versions. The new workaround is: `-Wl,--as-needed` for GCC and
`/full/path/to/libiomp5.so` for clang. How tricky... :(

[1] CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS

f: build: allow using compiler's OpenMP RT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or an optimization request
Projects
None yet
Development

No branches or pull requests

3 participants