Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
03c1a30
initial
Sep 17, 2020
9c64889
fix
Sep 17, 2020
771aa74
fix
Sep 17, 2020
e99e855
tweak
Zha0q1 Sep 17, 2020
aeb71d6
fix sanity
Zha0q1 Sep 17, 2020
23869f8
add build option
Sep 18, 2020
1145945
tweak
Sep 18, 2020
a6fa8f6
updae
Zha0q1 Sep 18, 2020
f367563
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
Nov 10, 2020
d185936
Update FindOpenBLAS.cmake
Zha0q1 Nov 12, 2020
edc3232
Update CMakeLists.txt
Zha0q1 Nov 12, 2020
29ef5a5
Update CMakeLists.txt
Zha0q1 Nov 12, 2020
1f91ef3
Update CMakeLists.txt
Zha0q1 Nov 12, 2020
ba07234
Update CMakeLists.txt
Zha0q1 Nov 12, 2020
7536a22
Update CMakeLists.txt
Zha0q1 Nov 12, 2020
2c21ad8
Update CMakeLists.txt
Zha0q1 Nov 12, 2020
0334da5
Update CMakeLists.txt
Zha0q1 Nov 13, 2020
8352de1
Update CMakeLists.txt
Zha0q1 Nov 13, 2020
8deee80
Update Dockerfile.build.centos7
Zha0q1 Nov 13, 2020
4e4db41
Update runtime_functions.sh
Zha0q1 Nov 13, 2020
4adb0f0
Merge branch 'master' of github.com:apache/incubator-mxnet into openb…
Zha0q1 Nov 13, 2020
7c32fac
ubuntu
Zha0q1 Nov 13, 2020
24917be
fix
Zha0q1 Nov 13, 2020
5c36610
Update CMakeLists.txt
Zha0q1 Nov 13, 2020
3f0f283
Update runtime_functions.sh
Zha0q1 Nov 13, 2020
3f6598e
Update Dockerfile.build.centos7
Zha0q1 Nov 13, 2020
060d393
Update Dockerfile.build.centos7
Zha0q1 Nov 13, 2020
b45fb19
Merge branch 'master' into openblas_use_lapacke_api
Zha0q1 Nov 16, 2020
a9bd8da
Merge branch 'master' into openblas_use_lapacke_api
Zha0q1 Nov 17, 2020
e68f283
Merge branch 'master' of github.com:apache/incubator-mxnet into openb…
Nov 18, 2020
0363264
rebase to mkl pr
Nov 18, 2020
6b060e2
fix
Nov 18, 2020
5fee7be
Turn on ilp64 lapacke for all ubuntu build funcs
Zha0q1 Nov 19, 2020
5f6e3f2
Update runtime_functions.sh
Zha0q1 Nov 19, 2020
5fbb42e
build openblas without openmp on ubuntu
Nov 19, 2020
ac83cf2
static build
Nov 19, 2020
5667e12
fix static build
Zha0q1 Nov 19, 2020
ebd9401
fix cd dynamic build
Zha0q1 Nov 19, 2020
a7a4688
add link_lapack option
Zha0q1 Nov 19, 2020
6251c61
fix mac os static build
Nov 19, 2020
ff6ad99
remove extra openblas flags
Nov 19, 2020
3edc2ce
Merge branch 'openblas_use_lapacke_api' of github.com:Zha0q1/incubato…
Nov 19, 2020
3634c7d
CheckCSourceCompiles solution
Zha0q1 Nov 20, 2020
365c8a0
nm solution
Zha0q1 Nov 20, 2020
9c29e7e
automate lp/ilp64 lapacke flag
Zha0q1 Nov 21, 2020
87b02e9
Merge branch 'master' into openblas_use_lapacke_api
Zha0q1 Nov 21, 2020
3f9182a
move conditions from ChooseBlas to CMakeLists
Zha0q1 Nov 23, 2020
c750d38
gfortran4.8
Nov 23, 2020
8ba4542
omp c++
Zha0q1 Nov 23, 2020
8bd5fd1
fix ubuntu docker command
Zha0q1 Nov 23, 2020
6209fd4
add gfortran check
Zha0q1 Nov 24, 2020
91eeb40
fix scope
Zha0q1 Nov 24, 2020
11cc1db
enable_language(Fortran) method but probably would fail due to low cm…
Zha0q1 Nov 24, 2020
319446b
bump up cmake ninja version
Nov 24, 2020
903e7f8
remove package manager install ninja
Nov 24, 2020
7145cb4
use FindFortran.cmake
Zha0q1 Nov 24, 2020
632e63f
fix
Zha0q1 Nov 24, 2020
954fdcc
add license
Zha0q1 Nov 24, 2020
4918459
whitelist findfortran.cmake
Zha0q1 Nov 24, 2020
bfb230f
try bumping up cmake version
Zha0q1 Nov 25, 2020
aa45882
try generate cmake
Zha0q1 Nov 25, 2020
4338440
try custom findfortran
Zha0q1 Nov 25, 2020
cc5aa78
Merge branch 'master' of github.com:apache/incubator-mxnet into openb…
Zha0q1 Nov 25, 2020
95e1d46
add gomp fallback
Zha0q1 Nov 25, 2020
22ea5a2
fix
Zha0q1 Nov 25, 2020
6ecaf65
install libomp-dev on ubuntu
Zha0q1 Nov 26, 2020
e0b864b
try build openblas with clang
Nov 30, 2020
4f4fbd6
build clang, gcc openblas separatly
Dec 1, 2020
9a8cf5e
revert removal of six
Zha0q1 Dec 1, 2020
fa19b83
Update requirements
Zha0q1 Dec 1, 2020
f022c8a
tweak
Zha0q1 Dec 1, 2020
cd42232
Merge branch 'master' of github.com:apache/incubator-mxnet into openb…
Zha0q1 Dec 2, 2020
7d8c26a
Update ChooseBlas.cmake
Zha0q1 Dec 3, 2020
48bc8ea
remove extra lapacke flags
Zha0q1 Dec 4, 2020
e3b277d
Merge branch 'openblas_use_lapacke_api' of github.com:Zha0q1/incubato…
Zha0q1 Dec 4, 2020
bcd3818
more meaningful installation dir for clang openblas
Zha0q1 Dec 4, 2020
bc7c1d5
Update ChooseBlas.cmake
Zha0q1 Dec 4, 2020
96686a9
remove repetitive flag
Zha0q1 Dec 4, 2020
d3e793b
Merge branch 'master' of github.com:apache/incubator-mxnet into openb…
Zha0q1 Dec 4, 2020
de78106
remove repetitive flag check
Zha0q1 Dec 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3rdparty/mshadow/mshadow/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ const float kPi = 3.1415926f;
typedef index_t openmp_index_t;
#endif

#if MSHADOW_USE_MKL && MXNET_USE_LAPACK

#if (MSHADOW_USE_MKL && MXNET_USE_LAPACK) || MXNET_USE_ILP64_LAPACKE
// lapack_index_t could be replaced by index_t and removed when all blas library support large tensor
typedef index_t lapack_index_t;
#else
Expand Down
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ if(USE_ASAN)
endif()

list(APPEND mxnet_LINKER_LIBS ${mshadow_LINKER_LIBS})
message("After choosing blas, linking to ${mxnet_LINKER_LIBS}")

foreach(var ${C_CXX_INCLUDE_DIRECTORIES})
include_directories(${var})
Expand Down Expand Up @@ -443,19 +444,19 @@ elseif(UNIX)
list(APPEND mxnet_LINKER_LIBS Threads::Threads)
endif()


# ---[ LAPack
if(USE_LAPACK)
message("USE_LAPACK is ON")
add_definitions(-DMXNET_USE_LAPACK=1)
# In the CMAKE_BUILD_TYPE="Distribution" case, we link against Blas libraries
# that already provide lapack symbols. Thus -llapack would be wrong.
if (NOT MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Distribution")
list(APPEND mxnet_LINKER_LIBS lapack)
if(NOT USE_LAPACKE_INTERFACE)
# BLAS=open case is handled in ChooseBlas.cmake
if(NOT MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Distribution"
AND NOT BLAS STREQUAL "Open" AND NOT BLAS STREQUAL "open")
list(APPEND mxnet_LINKER_LIBS lapack)
endif()
endif()
endif()


# ---[ jemalloc
if(USE_JEMALLOC)
find_package(JeMalloc)
Expand Down
18 changes: 15 additions & 3 deletions ci/docker/Dockerfile.build.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,29 @@ RUN yum -y check-update || true && \
# Libraries
# Provide clbas headerfiles
atlas-devel \
openblas-devel \
lapack-devel \
opencv-devel \
openssl-devel \
zeromq-devel \
# Build-dependencies for ccache 3.7.9
gperf \
libb2-devel \
libzstd-devel && \
libzstd-devel \
# Required by openblas build
gcc-gfortran && \
yum clean all

# Build OpenBLAS from source
RUN mkdir ~/openblas && \
cd ~/openblas && \
OPENBLAS_VERSION=0.3.10 && \
wget \
https://github.com/xianyi/OpenBLAS/archive/v${OPENBLAS_VERSION}.zip \
-O openblas.zip && \
unzip -q openblas.zip -d . && \
cd OpenBLAS-${OPENBLAS_VERSION} && \
CXX="g++ -fPIC" CC="gcc -fPIC" make -j DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 && \
make PREFIX=/usr/local install

# Make Python 3.6 and Maven 3.3 Software Collections available by default during
# the following build steps in this Dockerfile
SHELL [ "/usr/bin/scl", "enable", "devtoolset-7", "rh-python36", "rh-maven35" ]
Expand Down
27 changes: 24 additions & 3 deletions ci/docker/Dockerfile.build.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
g++ \
g++-8 \
intel-mkl-2020.0-088 \
libomp-dev \
## Dependencies
libgomp1 \
libturbojpeg0-dev \
libopenblas-dev \
libcurl4-openssl-dev \
libatlas-base-dev \
libzmq3-dev \
liblapack-dev \
libopencv-dev \
libxml2-dev \
# BytePS
Expand All @@ -82,9 +81,31 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
autoconf \
gperf \
libb2-dev \
libzstd-dev && \
libzstd-dev \
gfortran && \
rm -rf /var/lib/apt/lists/*

# Build OpenBLAS from source
RUN export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/gcc/x86_64-linux-gnu/7/ && \
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 the library path needed for clang?

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.

Yeah other wise it would not find gfortran

mkdir ~/openblas && \
cd ~/openblas && \
OPENBLAS_VERSION=0.3.10 && \
wget \
https://github.com/xianyi/OpenBLAS/archive/v${OPENBLAS_VERSION}.zip \
-O openblas.zip && \
unzip -q openblas.zip -d . && \
cd OpenBLAS-${OPENBLAS_VERSION} && \
CXX="clang++-6.0 -fPIC" CC="clang-6.0 -fPIC" make -j DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 \
USE_OPENMP=0 INTERFACE64=1 BINARY=64 && \
make PREFIX=/usr/local/openblas-clang install && \
cd .. && \
rm -rf OpenBLAS-${OPENBLAS_VERSION} && \
unzip -q openblas.zip -d . && \
cd OpenBLAS-${OPENBLAS_VERSION} && \
CXX="g++ -fPIC" CC="gcc -fPIC" make -j DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 \
USE_OPENMP=1 INTERFACE64=1 BINARY=64 && \
make PREFIX=/usr/local install

# ccache 3.7.9 has fixes for caching nvcc outputs
RUN cd /usr/local/src && \
git clone --recursive https://github.com/ccache/ccache.git && \
Expand Down
5 changes: 5 additions & 0 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ build_ubuntu_gpu_clang10_werror() {
build_ubuntu_cpu_clang6() {
set -ex
cd /work/build
export OpenBLAS_HOME=/usr/local/openblas-clang/
CXX=clang++-6.0 CC=clang-6.0 cmake \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_MKLDNN=OFF \
Expand All @@ -452,6 +453,7 @@ build_ubuntu_cpu_clang6() {
build_ubuntu_cpu_clang100() {
set -ex
cd /work/build
export OpenBLAS_HOME=/usr/local/openblas-clang/
CXX=clang++-10 CC=clang-10 cmake \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_MKLDNN=OFF \
Expand All @@ -465,6 +467,7 @@ build_ubuntu_cpu_clang100() {
build_ubuntu_cpu_clang_tidy() {
set -ex
cd /work/build
export OpenBLAS_HOME=/usr/local/openblas-clang/
# TODO(leezu) USE_OPENMP=OFF 3rdparty/dmlc-core/CMakeLists.txt:79 broken?
CXX=clang++-10 CC=clang-10 cmake \
-DUSE_MKL_IF_AVAILABLE=OFF \
Expand All @@ -481,6 +484,7 @@ build_ubuntu_cpu_clang_tidy() {
build_ubuntu_cpu_clang6_mkldnn() {
set -ex
cd /work/build
export OpenBLAS_HOME=/usr/local/openblas-clang/
CXX=clang++-6.0 CC=clang-6.0 cmake \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_MKLDNN=ON \
Expand All @@ -493,6 +497,7 @@ build_ubuntu_cpu_clang6_mkldnn() {
build_ubuntu_cpu_clang100_mkldnn() {
set -ex
cd /work/build
export OpenBLAS_HOME=/usr/local/openblas-clang/
CXX=clang++-10 CC=clang-10 cmake \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_MKLDNN=ON \
Expand Down
75 changes: 75 additions & 0 deletions cmake/ChooseBlas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,81 @@ elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open")
add_definitions(-DMSHADOW_USE_CBLAS=1)
add_definitions(-DMSHADOW_USE_MKL=0)
add_definitions(-DMXNET_USE_BLAS_OPEN=1)
if(NOT MSVC)
# check if we need to link to omp
execute_process(COMMAND ${CMAKE_NM} -g ${OpenBLAS_LIB}
COMMAND grep omp_get_num_threads
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE OPENBLAS_USES_OMP_OUT
RESULT_VARIABLE OPENBLAS_USES_OMP_RET)
if(NOT OPENBLAS_USES_OMP_OUT STREQUAL "" AND NOT OPENBLAS_USES_OMP_RET AND NOT USE_OPENMP)
message("Openblas uses OMP, automatically linking to it")
find_package(OpenMP REQUIRED)
message("OpenMP_CXX_LIBRARIES is ${OpenMP_CXX_LIBRARIES}")
list(APPEND mshadow_LINKER_LIBS "${OpenMP_CXX_LIBRARIES}")
endif()
# check if we need to link to gfortran
execute_process(COMMAND ${CMAKE_NM} -g ${OpenBLAS_LIB}
COMMAND grep gfortran
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE OPENBLAS_USES_GFORTRAN_OUT
RESULT_VARIABLE OPENBLAS_USES_GFORTRAN_RET)
if(NOT OPENBLAS_USES_GFORTRAN_OUT STREQUAL "" AND NOT OPENBLAS_USES_GFORTRAN_RET)
message("Openblas uses GFortran, automatically linking to it")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/temp/CMakeLists.txt"
"cmake_minimum_required(VERSION ${CMAKE_VERSION})
project(CheckFortran Fortran)
set(CMAKE_Fortran_COMPILER gfortran)
file(WRITE \"${CMAKE_CURRENT_BINARY_DIR}/temp/FortranDir.cmake\"
\"
set(FORTRAN_DIR \\\"\$\{CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES\}\\\")
\")
")
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp/
COMMAND ${CMAKE_COMMAND} .
)
set(FORTRAN_DIR "")
include(build/temp/FortranDir.cmake)
find_library(FORTRAN_LIB NAMES gfortran HINTS ${FORTRAN_DIR})
message("FORTRAN_DIR is ${FORTRAN_DIR}")
message("FORTRAN_LIB is ${FORTRAN_LIB}")
list(APPEND mshadow_LINKER_LIBS ${FORTRAN_LIB})
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/temp/")
endif()
# check the lapack flavor of openblas
include(CheckSymbolExists)
check_symbol_exists(OPENBLAS_USE64BITINT "${OpenBLAS_INCLUDE_DIR}/openblas_config.h" OPENBLAS_ILP64)
if(OPENBLAS_ILP64)
message("Using ILP64 OpenBLAS")
if(NOT USE_INT64_TENSOR_SIZE)
message(FATAL_ERROR "Must set USE_INT64_TENSOR_SIZE=1 when using ILP64 OpenBLAS")
endif()
else()
message("Using LP64 OpenBLAS")
endif()
if(USE_LAPACK)
if(EXISTS "${OpenBLAS_INCLUDE_DIR}/lapacke.h")
message("Detected lapacke.h, automatically using the LAPACKE interface")
add_definitions(-DMXNET_USE_LAPACKE_INTERFACE=1)
set(USE_LAPACKE_INTERFACE 1)
if(OPENBLAS_ILP64)
message("Detected ILP64 LAPACKE")
add_definitions(-DMXNET_USE_ILP64_LAPACKE=1)
endif()
else()
execute_process(COMMAND ${CMAKE_NM} -g ${OpenBLAS_LIB}
COMMAND grep sgetri_
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE OPENBLAS_CONTAINS_C_LAPACK_OUT
RESULT_VARIABLE OPENBLAS_CONTAINS_C_LAPACK_RET)
if(OPENBLAS_CONTAINS_C_LAPACK_OUT STREQUAL ""
AND NOT OPENBLAS_CONTAINS_C_LAPACK_RET)
list(APPEND mshadow_LINKER_LIBS lapack)
endif()
endif()
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)
Expand Down
12 changes: 6 additions & 6 deletions cmake/Modules/FindOpenBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ file(TO_CMAKE_PATH "$ENV{OpenBLAS_HOME}" OpenBLAS_HOME)
file(TO_CMAKE_PATH "$ENV{OpenBLAS}" OpenBLAS_DIR)

SET(Open_BLAS_INCLUDE_SEARCH_PATHS
${OpenBLAS_HOME}
${OpenBLAS_HOME}/include
/usr/include
/usr/include/openblas
/usr/include/openblas-base
Expand All @@ -29,11 +31,11 @@ SET(Open_BLAS_INCLUDE_SEARCH_PATHS
/usr/local/opt/openblas/include
${PROJECT_SOURCE_DIR}/3rdparty/OpenBLAS/include
${PROJECT_SOURCE_DIR}/thirdparty/OpenBLAS/include
${OpenBLAS_HOME}
${OpenBLAS_HOME}/include
)

SET(Open_BLAS_LIB_SEARCH_PATHS
${OpenBLAS_HOME}
${OpenBLAS_HOME}/lib
/lib/
/lib/openblas-base
/lib64/
Expand All @@ -48,12 +50,10 @@ SET(Open_BLAS_LIB_SEARCH_PATHS
${PROJECT_SOURCE_DIR}/thirdparty/OpenBLAS/lib
${OpenBLAS_DIR}
${OpenBLAS_DIR}/lib
${OpenBLAS_HOME}
${OpenBLAS_HOME}/lib
)

FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS})
FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h HINTS ${Open_BLAS_INCLUDE_SEARCH_PATHS})
FIND_LIBRARY(OpenBLAS_LIB NAMES libopenblas.a HINTS ${Open_BLAS_LIB_SEARCH_PATHS})
IF(NOT OpenBLAS_LIB)
FIND_FILE(OpenBLAS_LIB NAMES libopenblas.dll.a PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
ENDIF()
Expand Down
1 change: 0 additions & 1 deletion config/distribution/linux_cu100.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ set(USE_SSE ON CACHE BOOL "Build with x86 SSE instruction support")
set(USE_F16C OFF CACHE BOOL "Build with x86 F16C instruction support")
set(USE_LIBJPEG_TURBO ON CACHE BOOL "Build with libjpeg-turbo")
set(USE_DIST_KVSTORE ON CACHE BOOL "Build with DIST_KVSTORE support")

set(CUDACXX "/usr/local/cuda-10.0/bin/nvcc" CACHE STRING "Cuda compiler")
set(MXNET_CUDA_ARCH "3.0;5.0;6.0;7.0" CACHE STRING "Cuda architectures")
1 change: 0 additions & 1 deletion config/distribution/linux_cu101.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ set(USE_SSE ON CACHE BOOL "Build with x86 SSE instruction support")
set(USE_F16C OFF CACHE BOOL "Build with x86 F16C instruction support")
set(USE_LIBJPEG_TURBO ON CACHE BOOL "Build with libjpeg-turbo")
set(USE_DIST_KVSTORE ON CACHE BOOL "Build with DIST_KVSTORE support")

set(CUDACXX "/usr/local/cuda-10.1/bin/nvcc" CACHE STRING "Cuda compiler")
set(MXNET_CUDA_ARCH "3.0;5.0;6.0;7.0" CACHE STRING "Cuda architectures")
1 change: 0 additions & 1 deletion config/distribution/linux_cu102.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ set(USE_SSE ON CACHE BOOL "Build with x86 SSE instruction support")
set(USE_F16C OFF CACHE BOOL "Build with x86 F16C instruction support")
set(USE_LIBJPEG_TURBO ON CACHE BOOL "Build with libjpeg-turbo")
set(USE_DIST_KVSTORE ON CACHE BOOL "Build with DIST_KVSTORE support")

set(CUDACXX "/usr/local/cuda-10.2/bin/nvcc" CACHE STRING "Cuda compiler")
set(MXNET_CUDA_ARCH "3.0;5.0;6.0;7.0" CACHE STRING "Cuda architectures")
1 change: 0 additions & 1 deletion config/distribution/linux_cu110.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ set(USE_SSE ON CACHE BOOL "Build with x86 SSE instruction support")
set(USE_F16C OFF CACHE BOOL "Build with x86 F16C instruction support")
set(USE_LIBJPEG_TURBO ON CACHE BOOL "Build with libjpeg-turbo")
set(USE_DIST_KVSTORE ON CACHE BOOL "Build with DIST_KVSTORE support")

set(CUDACXX "/usr/local/cuda-11.0/bin/nvcc" CACHE STRING "Cuda compiler")
set(MXNET_CUDA_ARCH "5.0;6.0;7.0;8.0" CACHE STRING "Cuda architectures")
1 change: 0 additions & 1 deletion config/distribution/linux_cu92.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ set(USE_TVM_OP OFF CACHE BOOL "Enable use of TVM operator build system.")
set(USE_SSE ON CACHE BOOL "Build with x86 SSE instruction support")
set(USE_F16C OFF CACHE BOOL "Build with x86 F16C instruction support")
set(USE_LIBJPEG_TURBO ON CACHE BOOL "Build with libjpeg-turbo")

set(CUDACXX "/usr/local/cuda-9.2/bin/nvcc" CACHE STRING "Cuda compiler")
set(MXNET_CUDA_ARCH "3.0;5.0;6.0;7.0" CACHE STRING "Cuda architectures")
2 changes: 1 addition & 1 deletion src/operator/c_lapack_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "c_lapack_api.h"

#if (MSHADOW_USE_MKL && MXNET_USE_LAPACK)
#if (MXNET_USE_LAPACK && (MSHADOW_USE_MKL || MXNET_USE_LAPACKE_INTERFACE))
#elif MXNET_USE_LAPACK
#else
// use pragma message instead of warning
Expand Down
21 changes: 14 additions & 7 deletions src/operator/c_lapack_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@

using namespace mshadow;

// Will cause clash with MKL fortran layer headers
#if MSHADOW_USE_MKL == 0
// Will cause clash with MKL/OpenBLAS fortran layer headers
#if MSHADOW_USE_MKL == 0 && MXNET_USE_LAPACKE_INTERFACE == 0

extern "C" {

Expand Down Expand Up @@ -243,11 +243,18 @@ inline void flip(int m, int n, DType *b, int ldb, DType *a, int lda) {
}


#if (MSHADOW_USE_MKL && MXNET_USE_LAPACK)

// We interface with the C-interface of MKL
// as this is the preferred way.
#include <mkl_lapacke.h>
#if (MXNET_USE_LAPACK && (MSHADOW_USE_MKL || MXNET_USE_LAPACKE_INTERFACE))
#if MSHADOW_USE_MKL
#include <mkl_lapacke.h>
#else
#if MXNET_USE_ILP64_LAPACKE
#define lapack_int int64_t
#endif
// prevent multiple inclusion of complex.h in lapacke.h
#define lapack_complex_float float _Complex
#define lapack_complex_double double _Complex
#include <lapacke.h>
#endif

#define MXNET_LAPACK_ROW_MAJOR LAPACK_ROW_MAJOR
#define MXNET_LAPACK_COL_MAJOR LAPACK_COL_MAJOR
Expand Down
3 changes: 2 additions & 1 deletion tools/dependencies/openblas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ if [[ (! -e $DEPS_PATH/lib/libopenblas.a) ]]; then
cd $DEPS_PATH/OpenBLAS-${OPENBLAS_VERSION}

# Adding NO_DYNAMIC=1 flag causes make install to fail
CFLAGS="-fPIC" CXXFLAGS="-fPIC" $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1
CFLAGS="-fPIC" CXXFLAGS="-fPIC" $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 \
INTERFACE64=1 BINARY=64
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.

Also past the output of ldd libmxnet.so to verify that it statically links to openblas

Copy link
Copy Markdown
Contributor

@access2rohit access2rohit Nov 19, 2020

Choose a reason for hiding this comment

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

Also Why is it different from here? https://github.com/apache/incubator-mxnet/pull/19174/files#diff-5ccf6e661bf0b669dd4900b71d988c969259810a3bef5c5376a212f4080186fbR98

    CXX="g++ -fPIC" CC="gcc -fPIC" make -j DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 \
        INTERFACE64=1 BINARY=64 NO_SHARED=0 NO_LAPACK=0 && \

Copy link
Copy Markdown
Contributor Author

@Zha0q1 Zha0q1 Nov 19, 2020

Choose a reason for hiding this comment

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

Also past the output of ldd libmxnet.so to verify that it statically links to openblas

Yeah I have confirmed the binaries with several builds. Here is one result: (ubuntu)

ubuntu@ip-172-31-38-169:~/fixstaticbuild/lib$ ldd libmxnet.so 
	linux-vdso.so.1 (0x00007ffd3b5a0000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007eff359f2000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007eff357ea000)
	libgfortran.so.4 => /home/ubuntu/fixstaticbuild/lib/./libgfortran.so.4 (0x00007eff3540b000)
	libcudnn.so.7 => /usr/local/cuda/lib64/libcudnn.so.7 (0x00007eff1fdec000)
	libnvidia-ml.so.1 => /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1 (0x00007eff1f758000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007eff1f539000)
	libcudart.so.10.0 => /usr/local/cuda/lib64/libcudart.so.10.0 (0x00007eff1f2bf000)
	libcufft.so.10.0 => /usr/local/cuda/lib64/libcufft.so.10.0 (0x00007eff18e0b000)
	libcublas.so.10.0 => /usr/local/cuda/lib64/libcublas.so.10.0 (0x00007eff14875000)
	libcusolver.so.10.0 => /usr/local/cuda/lib64/libcusolver.so.10.0 (0x00007eff0c18e000)
	libcurand.so.10.0 => /usr/local/cuda/lib64/libcurand.so.10.0 (0x00007eff08027000)
	libcuda.so.1 => /usr/lib/x86_64-linux-gnu/libcuda.so.1 (0x00007eff06b74000)
	libnvrtc.so.10.0 => /usr/local/cuda/lib64/libnvrtc.so.10.0 (0x00007eff05558000)
	libnvToolsExt.so.1 => /usr/local/cuda/lib64/libnvToolsExt.so.1 (0x00007eff0534f000)
	libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007eff05120000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007eff04d97000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007eff049f9000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007eff047e1000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007eff043f0000)
	/lib64/ld-linux-x86-64.so.2 (0x00007eff6a210000)
	libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007eff041b0000)

Also I used nm -D libmxnet.so | grep blas nm -D libmxnet.so | grep getrf to confirm that the symbols are hidden.

I am forcing link to libopenblas.a so there should be no problem wrt static linking

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.

Also Why is it different from here? https://github.com/apache/incubator-mxnet/pull/19174/files#diff-5ccf6e661bf0b669dd4900b71d988c969259810a3bef5c5376a212f4080186fbR98

    CXX="g++ -fPIC" CC="gcc -fPIC" make -j DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 \
        INTERFACE64=1 BINARY=64 NO_SHARED=0 NO_LAPACK=0 && \

NO_SHARED=0 NO_LAPACK=0 are default to 0 anyways. I have removed them to keep the openblas build commands consistent

patchelf --set-rpath '$ORIGIN' --force-rpath libopenblas.so

$MAKE PREFIX=$DEPS_PATH install
Expand Down
1 change: 0 additions & 1 deletion tools/staticbuild/build_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ cd -
rm -rf lib; mkdir lib;
if [[ $PLATFORM == 'linux' ]]; then
cp -L build/libmxnet.so lib/libmxnet.so
cp -L staticdeps/lib/libopenblas.so lib/libopenblas.so.0
cp -L $(ldd lib/libmxnet.so | grep libgfortran | awk '{print $3}') lib/
elif [[ $PLATFORM == 'darwin' ]]; then
cp -L build/libmxnet.dylib lib/libmxnet.dylib
Expand Down