lebeg commented on a change in pull request #11148: [MXNET-679] Refactor handling BLAS libraries with cmake URL: https://github.com/apache/incubator-mxnet/pull/11148#discussion_r209654913
########## File path: CMakeLists.txt ########## @@ -38,7 +48,117 @@ mxnet_option(BUILD_CPP_EXAMPLES "Build cpp examples" ON) mxnet_option(INSTALL_EXAMPLES "Install the example source files." OFF) mxnet_option(USE_SIGNAL_HANDLER "Print stack traces on segfaults." OFF) -message(STATUS "CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}") +# Choose BLAS (Basic Linear Algebra Subprograms) computation libraries + +# MXNet supports multiple mathematical backends for computations on the CPU: +# +# * Atlas +# * OpenBLAS +# * MKL (MKL, MKLML, MKLDNN) +# * Apple Accelerate +# +# The default order of choice for the libraries if found follows the path from the most +# (recommended) to less performant backends. The order is as follows: +# +# For desktop platforms (x86_64): +# +# 1. MKLDNN (requires and checks for MKL or MKLML) | USE_MKLDNN +# 2. MKL | USE_MKL_IF_AVAILABLE +# 3. MKLML (downloaded) | USE_MKLML +# 4. Apple Accelerate | USE_APPLE_ACCELERATE_IF_AVAILABLE | Mac only +# 5. OpenBLAS | BLAS (Atlas;Open;MKL;Apple) +# +# For embedded platforms (all other and if cross compiled): +# +# 1. OpenBLAS | BLAS (Atlas;Open) +# +# You can set the BLAS library explicitly by setting the BLAS variable to: +# +# * Atlas +# * Open +# * MKL +# * Apple +# +# See cmake/ChooseBLAS.cmake file for the options. +# +# Intel's MKL (Math Kernel Library) is one of the most powerful math libraries +# https://software.intel.com/en-us/mkl +# +# It has following flavours: +# +# * MKL is a full library, containing all the functionality. It is free under +# community support licensing (https://software.intel.com/en-us/articles/free-mkl), +# but needs to be downloaded and installed manually. +# +# * MKLML is a subset of MKL. It contains smaller number of functions to reduce the +# size of the download and reduce the number of dynamic libraries user needs. This +# is the most effective option since it can be downloaded and installed automatically +# by the cmake script (see cmake/DownloadMKLML.cmake). +# +# * MKLDNN is a separate open-source library, but it requires MKL or MKLML. It is +# shipped as a subrepo with MXNet source code (see 3rdparty/mkldnn). +# +# Since the full MKL library is almost always faster than any other it's turned on by default, +# however it needs to be downloaded and installed manually before doing cmake configuration. +# Register and download here https://software.seek.intel.com/performance-libraries +# +# Note: MKL is supported only for desktop builds and the framework itself supports the following +# hardware: +# +# * Intel® Xeon Phi™ processor +# * Intel® Xeon® processor +# * Intel® Core™ processor family +# * Intel Atom® processor +# +# If you have a different processor you can still try to use MKL, but performance results are +# unpredictable. +mxnet_option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON) + +# If the full MKL library could not be found the thinner subset MKLML will be downloaded +# unless switched off explicitly. +# Note: The same limitation on hardware as for MKL applies for MKLML as well. +mxnet_option(USE_MKLML "Use MKLML subset of MKL instead of mkl, will be downloaded" ON) + +# If either MKL of MKLML is present MKLDNN can be utilised from the 3rdparty/mkldnn subrepo. +# See more information here: https://github.com/intel/mkl-dnn +# Note: The same limitation on hardware as for MKL and MKLDNN applies for MKLDNN as well. +mxnet_option(USE_MKLDNN "Use MKLDNN (requires MKLML or MKL)" ON) + +# Apple's mathematical framework, probably the best choice on a Mac if MKL/MKLML/MKLDNN +# are not available. +# https://developer.apple.com/documentation/accelerate +mxnet_option(USE_APPLE_ACCELERATE_IF_AVAILABLE "Use Apple Accelerate framework if found, \ + works if MKL not found or disabled" ON IF ${APPLE}) + +# Another important option of the math libraries is presence of additional set of +# mathematical functions gathered and named as the LAPACK (Linear Algebra Package). Some +# libraries don't include it, thus the cmake script will check the presence of an +# indicating function "cheev_" within the available choosen libraries and switch the +# functionality off if not found. +mxnet_option(USE_LAPACK "Build with lapack support" ON) + +if(NOT mxnet_LINKER_LIBS) + set(mxnet_LINKER_LIBS "") +endif(NOT mxnet_LINKER_LIBS) + +if(MSVC) + set(SYSTEM_ARCHITECTURE x86_64) +else() + execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE SYSTEM_ARCHITECTURE) Review comment: For cross compilation we use the CMAKE_CROSSCOMPILING flag to prevent a download ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services