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

Commit

Permalink
Cleanup and fix path environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
lebeg committed Jul 20, 2018
1 parent b32e92c commit a909551
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ try {
call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\x86_amd64\\vcvarsx86_amd64.bat"
cd build_%BUILD_NAME%
copy ${env.WORKSPACE}\\3rdparty\\mkldnn\\config_template.vcxproj.user ${env.WORKSPACE}\\config_template.vcxproj.user /y
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=Manual -DCUDA_ARCH_BIN=52 -DCUDA_ARCH_PTX=52 -DUSE_MKLDNN=1 -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release ${env.WORKSPACE}"""
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=Manual -DCUDA_ARCH_BIN=52 -DCUDA_ARCH_PTX=52 -DUSE_MKL_IF_AVAILABLE=ON -DUSE_MKLDNN=ON -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release ${env.WORKSPACE}"""
bat '''
call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\x86_amd64\\vcvarsx86_amd64.bat"
cd build_%BUILD_NAME%
Expand Down
18 changes: 9 additions & 9 deletions cmake/ChooseBlas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function(try_mkldnn)
message(STATUS "Adding MKLDNN to the build due to USE_MKLDNN=${USE_MKLDNN} and MKL_FOUND=${MKL_FOUND}")

# CPU architecture (e.g., C5) can't run on another architecture (e.g., g3).
if(NOT MSVC)
if(NOT ${MSVC})
set(ARCH_OPT_FLAGS ${ARCH_OPT_FLAGS} "-mtune=generic" PARENT_SCOPE)
endif()

Expand Down Expand Up @@ -136,11 +136,11 @@ function(try_mklml)
endfunction()

function(try_accelerate)
if(NOT APPLE)
if(NOT ${APPLE})
return()
endif()

if(BLAS MATCHES "[Mm][Kk][Ll]")
if(${BLAS} MATCHES "[Mm][Kk][Ll]")
return()
endif()

Expand All @@ -167,7 +167,7 @@ endif()
try_accelerate()

# cmake regexp does not support case insensitive match (?i) or //i
if(BLAS MATCHES "[Aa][Tt][Ll][Aa][Ss]")
if(${BLAS} MATCHES "[Aa][Tt][Ll][Aa][Ss]")
message(STATUS "Using Atlas for BLAS")

set(Atlas_NEED_LAPACK ${USE_LAPACK})
Expand All @@ -188,7 +188,7 @@ if(BLAS MATCHES "[Aa][Tt][Ll][Aa][Ss]")
return()
endif()

if(BLAS MATCHES "[Oo][Pp][Ee][Nn]")
if(${BLAS} MATCHES "[Oo][Pp][Ee][Nn]")
message(STATUS "Using OpenBLAS for BLAS")

set(OpenBLAS_NEED_LAPACK ${USE_LAPACK})
Expand All @@ -210,7 +210,7 @@ if(BLAS MATCHES "[Oo][Pp][Ee][Nn]")
return()
endif()

if(BLAS MATCHES "[Mm][Kk][Ll]")
if(${BLAS} MATCHES "[Mm][Kk][Ll]")
message(STATUS "Using MKL for BLAS")

if(NOT ${MKL_FOUND})
Expand All @@ -220,7 +220,7 @@ if(BLAS MATCHES "[Mm][Kk][Ll]")
add_definitions(-DMSHADOW_USE_CBLAS=0)
add_definitions(-DMSHADOW_USE_MKL=1)

if(USE_LAPACK)
if(${USE_LAPACK})
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${MKL_LIBRARIES})
check_function_exists("cgees_" LAPACK_FOUND)
Expand All @@ -235,8 +235,8 @@ if(BLAS MATCHES "[Mm][Kk][Ll]")
endif()
endif()

if(BLAS MATCHES "([Aa][Pp][Pp][Ll][Ee]|[Aa][Cc][Cc][Ee][Ll][Ee][Rr][Aa][Tt][Ee])")
if(NOT APPLE)
if(${BLAS} MATCHES "([Aa][Pp][Pp][Ll][Ee]|[Aa][Cc][Cc][Ee][Ll][Ee][Rr][Aa][Tt][Ee])")
if(NOT ${APPLE})
message(FATAL_ERROR "Apple Accelerate framework's BLAS feature is available only on macOS")
return()
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/DownloadMKLML.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

message(STATUS "Downloading MKLML...")

if(MSVC)
if(${MSVC})
set(MKL_NAME "mklml_win_2018.0.3.20180406")

file(DOWNLOAD "/~https://github.com/intel/mkl-dnn/releases/download/v0.14/${MKL_NAME}.zip" "${CMAKE_CURRENT_BINARY_DIR}/mklml/${MKL_NAME}.zip" EXPECTED_MD5 "8DD73E7D3F19F004551809824C4E8970" SHOW_PROGRESS)
Expand All @@ -36,7 +36,7 @@ if(MSVC)
file(COPY ${MKLROOT}/lib/mklml.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${MKLROOT}/lib/mklml.lib DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/3rdparty/mkldnn/config_template.vcxproj.user DESTINATION ${CMAKE_SOURCE_DIR})
elseif(APPLE)
elseif(${APPLE})
set(MKL_NAME "mklml_mac_2018.0.3.20180406")

file(DOWNLOAD "/~https://github.com/intel/mkl-dnn/releases/download/v0.14/${MKL_NAME}.tgz" "${CMAKE_CURRENT_BINARY_DIR}/mklml/${MKL_NAME}.tgz" EXPECTED_MD5 "23a6f7fd04fb1fa6de0d52a2ec5a2a14" SHOW_PROGRESS)
Expand Down
13 changes: 8 additions & 5 deletions cmake/Modules/FindAccelerate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
# Accelerate_INCLUDE_DIR
# Accelerate_LIBRARIES

file(TO_CMAKE_PATH "$ENV{Accelerate_HOME}" Accelerate_HOME)
if($ENV{Accelerate_HOME})
file(TO_CMAKE_PATH "$ENV{Accelerate_HOME}" Accelerate_HOME)
endif()

set(Accelerate_INCLUDE_SEARCH_PATHS
/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current
Expand All @@ -39,9 +41,9 @@ set(LOOKED_FOR
Accelerate_CBLAS_INCLUDE_DIR
)

set(Accelerate_LAPACK_FOUND False)
set(Accelerate_LAPACK_FOUND)

if(Accelerate_NEED_LAPACK)
if(${Accelerate_NEED_LAPACK})
message(STATUS "Looking for LAPACK support...")

# Apple's vecLib should contain LAPACK functionalities included in the Accelerate
Expand All @@ -51,7 +53,7 @@ if(Accelerate_NEED_LAPACK)
set(CMAKE_REQUIRED_LIBRARIES "-framework Accelerate")
check_function_exists("cgees_" LAPACK_FOUND)

if(LAPACK_FOUND)
if(${LAPACK_FOUND})
set(Accelerate_LAPACK_FOUND True)
message(STATUS "LAPACK found")
else()
Expand All @@ -64,9 +66,10 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Accelerate DEFAULT_MSG ${LOOKED_FOR})

if(Accelerate_FOUND)
if(${Accelerate_FOUND})
set(Accelerate_INCLUDE_DIR ${Accelerate_CBLAS_INCLUDE_DIR})
set(Accelerate_LIBRARIES "-framework Accelerate")

mark_as_advanced(${LOOKED_FOR})

message(STATUS "Found Apple Accelerate (include: ${Accelerate_CBLAS_INCLUDE_DIR}, library: ${Accelerate_LIBRARIES})")
Expand Down
40 changes: 22 additions & 18 deletions cmake/Modules/FindAtlas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,33 @@
# Atlas_INCLUDE_DIRS
# Atlas_LIBRARIES

file(TO_CMAKE_PATH "$ENV{CROSS_ROOT}" CROSS_ROOT)
if($ENV{Atlas_ROOT_DIR})
file(TO_CMAKE_PATH "$ENV{Atlas_ROOT_DIR}" CROSS_ROOT)
endif()

if($ENV{CROSS_ROOT})
file(TO_CMAKE_PATH "$ENV{CROSS_ROOT}" CROSS_ROOT)
endif()

if(CMAKE_CROSSCOMPILING)
if(${CMAKE_CROSSCOMPILING})
set(Atlas_INCLUDE_SEARCH_PATHS
${CROSS_ROOT}
${CROSS_ROOT}/include
)
endif()

set(Atlas_INCLUDE_SEARCH_PATHS
$ENV{Atlas_INCLUDE_SEARCH_PATHS}
${Atlas_INCLUDE_SEARCH_PATHS}

$ENV{Atlas_ROOT_DIR}
$ENV{Atlas_ROOT_DIR}/include
$ENV{Atlas_ROOT_DIR}/include/atlas
${Atlas_ROOT_DIR}
${Atlas_ROOT_DIR}/include
${Atlas_ROOT_DIR}/include/atlas

/usr/include/atlas
/usr/include/atlas-base
)

if(CMAKE_CROSSCOMPILING)
if(${CMAKE_CROSSCOMPILING})
set(Atlas_LIB_SEARCH_PATHS
${CROSS_ROOT}
${CROSS_ROOT}/lib
Expand All @@ -58,10 +64,10 @@ if(CMAKE_CROSSCOMPILING)
endif()

set(Atlas_LIB_SEARCH_PATHS
$ENV{Atlas_LIB_SEARCH_PATHS}
${Atlas_LIB_SEARCH_PATHS}

$ENV{Atlas_ROOT_DIR}
$ENV{Atlas_ROOT_DIR}/lib
${Atlas_ROOT_DIR}
${Atlas_ROOT_DIR}/lib

/usr/lib/atlas
/usr/lib/atlas-base
Expand All @@ -85,11 +91,11 @@ set(LOOKED_FOR
Atlas_BLAS_LIBRARY
)

set(Atlas_LAPACK_FOUND False)
set(Atlas_CLAPACK_INCLUDE_DIR "")
set(Atlas_LAPACK_LIBRARY "")
set(Atlas_LAPACK_FOUND)
set(Atlas_CLAPACK_INCLUDE_DIR)
set(Atlas_LAPACK_LIBRARY)

if(Atlas_NEED_LAPACK)
if(${Atlas_NEED_LAPACK})
message(STATUS "Looking for LAPACK support...")

# we need another variables (starting with __) because cmake will not overwrite it if already set
Expand All @@ -104,7 +110,7 @@ if(Atlas_NEED_LAPACK)
include(CheckFunctionExists)
check_function_exists("cgees_" LAPACK_FOUND)

if(LAPACK_FOUND)
if(${LAPACK_FOUND})
set(Atlas_LAPACK_FOUND True)
set(Atlas_CLAPACK_INCLUDE_DIR ${__Atlas_CLAPACK_INCLUDE_DIR})
set(Atlas_LAPACK_LIBRARY ${__Atlas_LAPACK_LIBRARY})
Expand All @@ -124,13 +130,11 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Atlas DEFAULT_MSG ${LOOKED_FOR})

if(Atlas_FOUND)
if(${Atlas_FOUND})
set(Atlas_INCLUDE_DIRS ${Atlas_CBLAS_INCLUDE_DIR} ${Atlas_CLAPACK_INCLUDE_DIR})
set(Atlas_LIBRARIES ${Atlas_LAPACK_LIBRARY} ${Atlas_CBLAS_LIBRARY} ${Atlas_BLAS_LIBRARY})

mark_as_advanced(${LOOKED_FOR})

message(STATUS "Found Atlas (include: ${Atlas_INCLUDE_DIRS}, libraries: ${Atlas_LIBRARIES})")
else()
message(FATAL "Atlas not found, looked for ${LOOKED_FOR}")
endif()
38 changes: 20 additions & 18 deletions cmake/Modules/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@
# MKL_LIBRARIES : the libraries to link against.
#

file(TO_CMAKE_PATH "$ENV{MKLROOT}" MKLROOT)
if($ENV{MKLROOT})
file(TO_CMAKE_PATH "$ENV{MKLROOT}" MKLROOT)
endif()

# ---[ Root folders
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs")

# ---[ Options
mxnet_option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON)
mxnet_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
mxnet_option(MKL_MULTI_THREADED "Use multi-threading" ON IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
mxnet_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF IF NOT ${MKL_USE_SINGLE_DYNAMIC_LIBRARY})
mxnet_option(MKL_MULTI_THREADED "Use multi-threading" ON IF NOT ${MKL_USE_SINGLE_DYNAMIC_LIBRARY})
mxnet_option(MKL_USE_ILP64 "Use ilp64 data model" OFF)
mxnet_option(MKL_USE_CLUSTER "Use cluster functions" OFF IF CMAKE_SIZEOF_VOID_P EQUAL 4)
mxnet_option(MKL_USE_CLUSTER "Use cluster functions" OFF IF ${CMAKE_SIZEOF_VOID_P} EQUAL 4)

set(MKL_INCLUDE_SEARCH_PATHS
${MKL_INCLUDE_SEARCH_PATHS}
Expand All @@ -58,52 +60,52 @@ find_path(MKL_INCLUDE_DIR mkl.h
PATHS ${MKL_INCLUDE_SEARCH_PATHS}
PATH_SUFFIXES include)

if(NOT MKLROOT)
if(NOT ${MKLROOT})
get_filename_component(MKLROOT ${MKL_INCLUDE_DIR} DIRECTORY)
endif()

set(__looked_for MKL_INCLUDE_DIR)

# ---[ Find libraries
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set(__path_suffixes lib lib/ia32)
else()
set(__path_suffixes lib lib/intel64)
endif()

set(__mkl_libs "")
if(MKL_USE_SINGLE_DYNAMIC_LIBRARY)
if(${MKL_USE_SINGLE_DYNAMIC_LIBRARY})
list(APPEND __mkl_libs rt)
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
if(${WIN32})
list(APPEND __mkl_libs intel_c)
else()
list(APPEND __mkl_libs intel)
if(CMAKE_COMPILER_IS_GNUFORTRAN)
if(${CMAKE_COMPILER_IS_GNUFORTRAN})
list(APPEND __mkl_libs gf)
endif()
endif()
else()
set(__mkl_lib64_suffix "lp64")
if(MKL_USE_ILP64)
if(${MKL_USE_ILP64})
set(__mkl_lib64_suffix "ilp64")
add_definitions(-DMKL_ILP64)
endif()
list(APPEND __mkl_libs "intel_${__mkl_lib64_suffix}")
if(CMAKE_COMPILER_IS_GNUFORTRAN)
if(${CMAKE_COMPILER_IS_GNUFORTRAN})
list(APPEND __mkl_libs "gf_${__mkl_lib64_suffix}")
endif()
endif()

if(MKL_MULTI_THREADED)
if(${MKL_MULTI_THREADED})
list(APPEND __mkl_libs intel_thread)
else()
list(APPEND __mkl_libs sequential)
endif()

list(APPEND __mkl_libs core)
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND MKL_USE_CLUSTER)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8 AND ${MKL_USE_CLUSTER})
list(APPEND __mkl_libs cdft_core)
endif()
endif()
Expand All @@ -113,7 +115,7 @@ foreach(__lib ${__mkl_libs})
set(__mkl_lib "mkl_${__lib}")
string(TOUPPER ${__mkl_lib} __mkl_lib_upper)

if(MKL_USE_STATIC_LIBS)
if(${MKL_USE_STATIC_LIBS})
set(__mkl_lib "lib${__mkl_lib}.a")
endif()

Expand All @@ -129,14 +131,14 @@ foreach(__lib ${__mkl_libs})
endforeach()


if(NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
if(NOT ${MKL_USE_SINGLE_DYNAMIC_LIBRARY})
if(MKL_USE_STATIC_LIBS)
set(__iomp5_libs iomp5 libiomp5mt.lib)
else()
set(__iomp5_libs iomp5 libiomp5md.lib)
endif()

if(WIN32)
if(${WIN32})
find_path(INTEL_INCLUDE_DIR omp.h PATHS ${INTEL_ROOT} PATH_SUFFIXES include)
list(APPEND __looked_for INTEL_INCLUDE_DIR)
endif()
Expand All @@ -153,7 +155,7 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKL DEFAULT_MSG ${__looked_for})

if(MKL_FOUND)
if(${MKL_FOUND})
message(STATUS "Found MKL (include: ${MKL_INCLUDE_DIR}, lib: ${MKL_LIBRARIES}")
endif()

Expand Down
6 changes: 3 additions & 3 deletions cmake/Modules/FindMKLML.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set(MKLML_INCLUDE_SEARCH_PATHS
)

# ---[ Find libraries
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set(PATH_SUFFIXES lib lib/ia32)
else()
set(PATH_SUFFIXES lib lib/intel64)
Expand All @@ -65,7 +65,7 @@ set(LOOKED_FOR

set(MKLML_LIBS iomp5)

if(WIN32)
if(${WIN32})
list(APPEND MKLML_LIBS mklml)
elseif(APPLE)
list(APPEND MKLML_LIBS mklml)
Expand Down Expand Up @@ -94,7 +94,7 @@ endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKLML DEFAULT_MSG ${LOOKED_FOR})

if(MKLML_FOUND)
if(${MKLML_FOUND})
set(MKLML_INCLUDE_DIRS ${MKLML_INCLUDE_DIR})

mark_as_advanced(${LOOKED_FOR})
Expand Down
Loading

0 comments on commit a909551

Please sign in to comment.