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

Commit

Permalink
[WIP] [RFC] Improve MxNet framework building
Browse files Browse the repository at this point in the history
Ubuntu 20.04:
  - use FindBLAS cmake function to look for the intel-mkl;
  - remove FindMKL.cmake as it becomes unnecessary on this OS version;
  - add support for intel-mkl distribution version;
  - cmake upgrade to 3.17 (due to mkl single dynamic library support).
  • Loading branch information
akarbown committed Jan 19, 2021
1 parent ed2eee6 commit f737c59
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 175 deletions.
6 changes: 2 additions & 4 deletions ci/docker/Dockerfile.build.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ WORKDIR /work/deps
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y wget software-properties-common && \
wget -qO - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB | apt-key add - && \
apt-add-repository "deb https://apt.repos.intel.com/mkl all main" && \
apt-get update && \
apt-get install -y \
## Utilities
Expand All @@ -58,7 +56,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
g++ \
g++-7 \
g++-8 \
intel-mkl-2020.0-088 \
intel-mkl \
libomp-dev \
## Dependencies
libgomp1 \
Expand Down Expand Up @@ -127,7 +125,7 @@ RUN cd /usr/local/src && \
# Python & cmake
COPY install/requirements /work/
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install cmake==3.16.6 && \
python3 -m pip install cmake==3.17 && \
python3 -m pip install -r /work/requirements

ARG USER_ID=0
Expand Down
32 changes: 25 additions & 7 deletions cmake/ChooseBlas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
set(BLAS "Open" CACHE STRING "Selected BLAS library")
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")

# ---[ MKL Options
if(UNIX)
# Single dynamic library interface leads to conflicts between intel omp and llvm omp
# https://github.com/apache/incubator-mxnet/issues/17641
option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" OFF)
else()
option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON)
endif()


if(DEFINED USE_BLAS)
set(BLAS "${USE_BLAS}")
else()
Expand Down Expand Up @@ -121,17 +131,25 @@ set(FORTRAN_DIR \\\"\$\{CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES\}\\\")
endif()
endif()
elseif(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl")
if (USE_INT64_TENSOR_SIZE)
set(MKL_USE_ILP64 ON CACHE BOOL "enable using ILP64 in MKL" FORCE)
cmake_dependent_option(BLA_STATIC "Use static libraries" ON "NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY" OFF)
if(MKL_USE_SINGLE_DYNAMIC_LIBRARY)
set(BLA_VENDOR Intel10_64_dyn)
add_definitions(-DMKL_USE_SINGLE_DYNAMIC_LIBRARY=1)
else()
if(MKL_USE_ILP64)
message(FATAL_ERROR "MKL_USE_ILP64 cannot be set without USE_INT64_TENSOR_SIZE; "
"Please set USE_INT64_TENSOR_SIZE instead of MKL_USE_ILP64.")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BLA_VENDOR Intel10_32)
else()
if(USE_INT64_TENSOR_SIZE)
set(BLA_VENDOR Intel10_64ilp)
else()
set(BLA_VENDOR Intel10_64lp)
endif()
endif()
endif()
find_package(MKL REQUIRED)
find_package(BLAS)
find_path(MKL_INCLUDE_DIR mkl.h PATHS ENV MKLROOT PATH_SUFFIXES include mkl REQUIRED)
include_directories(SYSTEM ${MKL_INCLUDE_DIR})
list(APPEND mshadow_LINKER_LIBS ${MKL_LIBRARIES})
list(APPEND mshadow_LINKER_LIBS ${BLAS_LIBRARIES})
add_definitions(-DMSHADOW_USE_CBLAS=0)
add_definitions(-DMSHADOW_USE_MKL=1)
add_definitions(-DMXNET_USE_BLAS_MKL=1)
Expand Down
164 changes: 0 additions & 164 deletions cmake/Modules/FindMKL.cmake

This file was deleted.

0 comments on commit f737c59

Please sign in to comment.