From fbc47fe82c93562f46bda93585c7382ae1d42b22 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Wed, 10 Jan 2018 21:47:51 +0100 Subject: [PATCH 01/18] add static builds --- .travis.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43b9571..21ed207 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,10 @@ matrix: apt: packages: - libatlas-base-dev + - os: linux + env: + - BACKEND=Intel10_64lp_seq + - BUILD_STATIC=1 - os: linux env: - BACKEND=Intel10_64lp_seq @@ -37,6 +41,10 @@ matrix: - os: osx env: - BACKEND=Intel10_64lp_seq + - os: osx + env: + - BACKEND=Intel10_64lp_seq + - BUILD_STATIC=1 before_install: # Dependencies required by the CI are installed in ${TRAVIS_BUILD_DIR}/deps/ @@ -92,8 +100,13 @@ before_install: script: - cd ${TRAVIS_BUILD_DIR} - mkdir -p build && cd build - - echo "cmake .. -DBLAS_VENDOR=$BACKEND" - - cmake .. -DCMAKE_CXX_STANDARD=11 -DBLA_VENDOR=$BACKEND + - export CMAKE_OPTIONS="-DCMAKE_CXX_STANDARD=11 -DBLA_VENDOR=$BACKEND" + - | + if [[ "${BUILD_STATIC}" == "1" ]]; then + export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC" + fi + - echo "cmake .. ${CMAKE_OPTIONS}" + - cmake .. ${CMAKE_OPTIONS} - cmake --build . - | if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then From 508de729232ba3e92495fd160f92305b8123fcd7 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Wed, 10 Jan 2018 22:46:32 +0100 Subject: [PATCH 02/18] oups --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 21ed207..767d079 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,7 +103,7 @@ script: - export CMAKE_OPTIONS="-DCMAKE_CXX_STANDARD=11 -DBLA_VENDOR=$BACKEND" - | if [[ "${BUILD_STATIC}" == "1" ]]; then - export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC" + export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC=1" fi - echo "cmake .. ${CMAKE_OPTIONS}" - cmake .. ${CMAKE_OPTIONS} From 859b38fa2ec7dc9f649ce87b291863c3920f7565 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Thu, 11 Jan 2018 13:50:29 +0100 Subject: [PATCH 03/18] add fixed FindBLAS to fix mac static build --- CMakeLists.txt | 3 +- cmake/CMakePushCheckState.cmake | 86 +++ cmake/CheckFortranFunctionExists.cmake | 66 +++ cmake/CheckFunctionExists.cmake | 98 ++++ cmake/FindBLAS2.cmake | 717 +++++++++++++++++++++++++ 5 files changed, 969 insertions(+), 1 deletion(-) create mode 100644 cmake/CMakePushCheckState.cmake create mode 100644 cmake/CheckFortranFunctionExists.cmake create mode 100644 cmake/CheckFunctionExists.cmake create mode 100644 cmake/FindBLAS2.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 86f3017..a9ed3c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,8 @@ set (CMakeHelloWorld_VERSION_MAJOR 1) set (CMakeHelloWorld_VERSION_MINOR 0) # Find the BLAS stuff -find_package(BLAS REQUIRED) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) +find_package(BLAS2 REQUIRED) message(STATUS "BLAS Libraries: ${BLAS_LIBRARIES}") diff --git a/cmake/CMakePushCheckState.cmake b/cmake/CMakePushCheckState.cmake new file mode 100644 index 0000000..2a527d5 --- /dev/null +++ b/cmake/CMakePushCheckState.cmake @@ -0,0 +1,86 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CMakePushCheckState +# ------------------- +# +# +# +# This module defines three macros: CMAKE_PUSH_CHECK_STATE() +# CMAKE_POP_CHECK_STATE() and CMAKE_RESET_CHECK_STATE() These macros can +# be used to save, restore and reset (i.e., clear contents) the state of +# the variables CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, +# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_INCLUDES and CMAKE_EXTRA_INCLUDE_FILES +# used by the various Check-files coming with CMake, like e.g. +# check_function_exists() etc. The variable contents are pushed on a +# stack, pushing multiple times is supported. This is useful e.g. when +# executing such tests in a Find-module, where they have to be set, but +# after the Find-module has been executed they should have the same +# value as they had before. +# +# CMAKE_PUSH_CHECK_STATE() macro receives optional argument RESET. +# Whether it's specified, CMAKE_PUSH_CHECK_STATE() will set all +# CMAKE_REQUIRED_* variables to empty values, same as +# CMAKE_RESET_CHECK_STATE() call will do. +# +# Usage: +# +# :: +# +# cmake_push_check_state(RESET) +# set(CMAKE_REQUIRED_DEFINITIONS -DSOME_MORE_DEF) +# check_function_exists(...) +# cmake_reset_check_state() +# set(CMAKE_REQUIRED_DEFINITIONS -DANOTHER_DEF) +# check_function_exists(...) +# cmake_pop_check_state() + +macro(CMAKE_RESET_CHECK_STATE) + + set(CMAKE_EXTRA_INCLUDE_FILES) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_DEFINITIONS) + set(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_QUIET) + +endmacro() + +macro(CMAKE_PUSH_CHECK_STATE) + + if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) + set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) + endif() + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") + + set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES}) + set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) + set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) + set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) + set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) + set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) + + if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET") + cmake_reset_check_state() + endif() + +endmacro() + +macro(CMAKE_POP_CHECK_STATE) + +# don't pop more than we pushed + if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") + + set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") + endif() + +endmacro() diff --git a/cmake/CheckFortranFunctionExists.cmake b/cmake/CheckFortranFunctionExists.cmake new file mode 100644 index 0000000..5fc740a --- /dev/null +++ b/cmake/CheckFortranFunctionExists.cmake @@ -0,0 +1,66 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CheckFortranFunctionExists +# -------------------------- +# +# macro which checks if the Fortran function exists +# +# CHECK_FORTRAN_FUNCTION_EXISTS(FUNCTION VARIABLE) +# +# :: +# +# FUNCTION - the name of the Fortran function +# VARIABLE - variable to store the result +# Will be created as an internal cache variable. +# +# +# +# The following variables may be set before calling this macro to modify +# the way the check is run: +# +# :: +# +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) + if(NOT DEFINED ${VARIABLE}) + message(STATUS "Looking for Fortran ${FUNCTION}") + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + endif() + file(WRITE + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + " + program TESTFortran + external ${FUNCTION} + call ${FUNCTION}() + end program TESTFortran + " + ) + try_compile(${VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} + OUTPUT_VARIABLE OUTPUT + ) +# message(STATUS "${OUTPUT}") + if(${VARIABLE}) + set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") + message(STATUS "Looking for Fortran ${FUNCTION} - found") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n") + else() + message(STATUS "Looking for Fortran ${FUNCTION} - not found") + set(${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + endif() + endif() +endmacro() diff --git a/cmake/CheckFunctionExists.cmake b/cmake/CheckFunctionExists.cmake new file mode 100644 index 0000000..ef08062 --- /dev/null +++ b/cmake/CheckFunctionExists.cmake @@ -0,0 +1,98 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CheckFunctionExists +# ------------------- +# +# Check if a C function can be linked:: +# +# check_function_exists( ) +# +# Check that the ```` is provided by libraries on the system and store +# the result in a ````. ```` will be created as an internal +# cache variable. +# +# The following variables may be set before calling this macro to modify the +# way the check is run: +# +# :: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages +# +# .. note:: +# +# Prefer using :Module:`CheckSymbolExists` instead of this module, +# for the following reasons: +# +# * ``check_function_exists()`` can't detect functions that are inlined +# in headers or specified as a macro. +# +# * ``check_function_exists()`` can't detect anything in the 32-bit +# versions of the Win32 API, because of a mismatch in calling conventions. +# +# * ``check_function_exists()`` only verifies linking, it does not verify +# that the function is declared in system headers. + +macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) + if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}") + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION}") + endif() + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_FUNCTION_EXISTS_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_FUNCTION_EXISTS_ADD_INCLUDES) + endif() + + if(CMAKE_C_COMPILER_LOADED) + set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + elseif(CMAKE_CXX_COMPILER_LOADED) + set(_cfe_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists/CheckFunctionExists.cxx) + configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cfe_source}" COPYONLY) + else() + message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") + endif() + + try_compile(${VARIABLE} + ${CMAKE_BINARY_DIR} + ${_cfe_source} + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + unset(_cfe_source) + + if(${VARIABLE}) + set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} - found") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the function ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n") + else() + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} - not found") + endif() + set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the function ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + endif() + endif() +endmacro() diff --git a/cmake/FindBLAS2.cmake b/cmake/FindBLAS2.cmake new file mode 100644 index 0000000..b8f6686 --- /dev/null +++ b/cmake/FindBLAS2.cmake @@ -0,0 +1,717 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindBLAS +# -------- +# +# Find BLAS library +# +# This module finds an installed fortran library that implements the +# BLAS linear-algebra interface (see http://www.netlib.org/blas/). The +# list of libraries searched for is taken from the autoconf macro file, +# acx_blas.m4 (distributed at +# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). +# +# This module sets the following variables: +# +# :: +# +# BLAS_FOUND - set to true if a library implementing the BLAS interface +# is found +# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l +# and -L). +# BLAS_LIBRARIES - uncached list of libraries (using full path name) to +# link against to use BLAS +# BLAS95_LIBRARIES - uncached list of libraries (using full path name) +# to link against to use BLAS95 interface +# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface +# is found +# BLA_STATIC if set on this determines what kind of linkage we do (static) +# BLA_VENDOR if set checks only the specified vendor, if not set checks +# all the possibilities +# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK +# +# List of vendors (BLA_VENDOR) valid in this module: +# +# * Goto +# * OpenBLAS +# * ATLAS +# * PhiPACK +# * CXML +# * DXML +# * SunPerf +# * SCSL +# * SGIMATH +# * IBMESSL +# * Intel10_32 (intel mkl v10 32 bit) +# * Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model) +# * Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model) +# * Intel (older versions of mkl 32 and 64 bit) +# * ACML +# * ACML_MP +# * ACML_GPU +# * Apple +# * NAS +# * Generic +# +# .. note:: +# +# C/CXX should be enabled to use Intel mkl +# + +include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) + +set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + +# Check the language being used +if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED) ) + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") + else() + message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)") + return() + endif() +endif() + +macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) +# This macro checks for the existence of the combination of fortran libraries +# given by _list. If the combination is found, this macro checks (using the +# Check_Fortran_Function_Exists macro) whether can link against that library +# combination using the name of a routine given by _name using the linker +# flags given by _flags. If the combination of libraries is found and passes +# the link test, LIBRARIES is set to the list of complete library paths that +# have been found. Otherwise, LIBRARIES is set to FALSE. + +# N.B. _prefix is the prefix applied to the names of all cached variables that +# are generated internally and marked advanced by this macro. + +set(_libdir ${ARGN}) + +set(_libraries_work TRUE) +set(${LIBRARIES}) +set(_combined_name) +if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir ENV DYLD_LIBRARY_PATH) + else () + set(_libdir ENV LD_LIBRARY_PATH) + endif () +endif () + +foreach(_library ${_list}) + set(_combined_name ${_combined_name}_${_library}) + + if(_libraries_work) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif () + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else () + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif () + else () + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () + endif () + message(${CMAKE_FIND_LIBRARY_SUFFIXES}) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + HINTS ${_libdir} + ) + message("LIBDIR : ${_libdir}") + message(${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif() +endforeach() +if(_libraries_work) + # Test this combination of libraries. + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread}) + # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + if (CMAKE_Fortran_COMPILER_LOADED) + check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) + else() + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + endif() + set(CMAKE_REQUIRED_LIBRARIES) + mark_as_advanced(${_prefix}${_combined_name}_WORKS) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) +endif() +if(NOT _libraries_work) + set(${LIBRARIES} FALSE) +endif() +# message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") +endmacro() + +set(BLAS_LINKER_FLAGS) +set(BLAS_LIBRARIES) +set(BLAS95_LIBRARIES) +if (NOT $ENV{BLA_VENDOR} STREQUAL "") + set(BLA_VENDOR $ENV{BLA_VENDOR}) +else () + if(NOT BLA_VENDOR) + set(BLA_VENDOR "All") + endif() +endif () + +if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "goto2" + "" + ) + endif() +endif () + +if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + # OpenBLAS (http://www.openblas.net) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "openblas" + "" + ) + endif() +endif () + +if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "f77blas;atlas" + "" + ) + endif() +endif () + +# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) +if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "sgemm;dgemm;blas" + "" + ) + endif() +endif () + +# BLAS in Alpha CXML library? +if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "cxml" + "" + ) + endif() +endif () + +# BLAS in Alpha DXML library? (now called CXML, see above) +if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "dxml" + "" + ) + endif() +endif () + +# BLAS in Sun Performance library? +if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "-xlic_lib=sunperf" + "sunperf;sunmath" + "" + ) + if(BLAS_LIBRARIES) + set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") + endif() + endif() +endif () + +# BLAS in SCSL library? (SGI/Cray Scientific Library) +if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "scsl" + "" + ) + endif() +endif () + +# BLAS in SGIMATH library? +if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "complib.sgimath" + "" + ) + endif() +endif () + +# BLAS in IBM ESSL library? (requires generic BLAS lib, too) +if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "essl;blas" + "" + ) + endif() +endif () + +#BLAS in acml library? +if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") + if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) + ) + # try to find acml in "standard" paths + if( WIN32 ) + file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) + else() + file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) + endif() + if( WIN32 ) + file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) + else() + file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) + endif() + list(GET _ACML_ROOT 0 _ACML_ROOT) + list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) + if( _ACML_ROOT ) + get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) + if( SIZEOF_INTEGER EQUAL 8 ) + set( _ACML_PATH_SUFFIX "_int64" ) + else() + set( _ACML_PATH_SUFFIX "" ) + endif() + if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) + set( _ACML_COMPILER32 "ifort32" ) + set( _ACML_COMPILER64 "ifort64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) + set( _ACML_COMPILER32 "sun32" ) + set( _ACML_COMPILER64 "sun64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) + set( _ACML_COMPILER32 "pgi32" ) + if( WIN32 ) + set( _ACML_COMPILER64 "win64" ) + else() + set( _ACML_COMPILER64 "pgi64" ) + endif() + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) + # 32 bit builds not supported on Open64 but for code simplicity + # We'll just use the same directory twice + set( _ACML_COMPILER32 "open64_64" ) + set( _ACML_COMPILER64 "open64_64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) + set( _ACML_COMPILER32 "nag32" ) + set( _ACML_COMPILER64 "nag64" ) + else() + set( _ACML_COMPILER32 "gfortran32" ) + set( _ACML_COMPILER64 "gfortran64" ) + endif() + + if( BLA_VENDOR STREQUAL "ACML_MP" ) + set(_ACML_MP_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) + else() + set(_ACML_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) + endif() + endif() + elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) + set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) + endif() + + if( BLA_VENDOR STREQUAL "ACML_MP" ) + foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) + foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + else() + foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + endif() + + # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv" + "" + ) + endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml_mp;acml_mv" + "" + ) + endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv;CALBLAS" + "" + ) + endif() +endif () # ACML + +# Apple BLAS library? +if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") +if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "Accelerate" + "" + ) + endif() +endif () + +if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if ( NOT BLAS_LIBRARIES ) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "vecLib" + "" + ) + endif () +endif () +# Generic BLAS library? +if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "blas" + "" + ) + endif() +endif () + +#BLAS in intel mkl 10 library? (em64t 64bit) +if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if (NOT WIN32) + set(LM "-lm") + endif () + if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + find_package(Threads) + else() + find_package(Threads REQUIRED) + endif() + + set(BLAS_SEARCH_LIBS "") + + if(BLA_F95) + set(BLAS_mkl_SEARCH_SYMBOL SGEMM) + set(_LIBRARIES BLAS95_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + + # Find the main file (32-bit or 64-bit) + set(BLAS_SEARCH_LIBS_WIN_MAIN "") + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + else () + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") + + # mkl >= 10.3 + if (CMAKE_C_COMPILER MATCHES ".+gcc") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + else () + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") + endif () + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_sequential mkl_core") + endif () + endif () + else () + set(BLAS_mkl_SEARCH_SYMBOL sgemm) + set(_LIBRARIES BLAS_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + + # Find the main file (32-bit or 64-bit) + set(BLAS_SEARCH_LIBS_WIN_MAIN "") + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + else () + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel mkl_intel_thread mkl_core guide") + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_intel_thread mkl_core guide") + + # mkl >= 10.3 + if (CMAKE_C_COMPILER MATCHES ".+gcc") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + else () + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") + endif () + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_sequential mkl_core") + endif () + + #older vesions of intel mkl libs + if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl") + list(APPEND BLAS_SEARCH_LIBS + "mkl_ia32") + list(APPEND BLAS_SEARCH_LIBS + "mkl_em64t") + endif () + endif () + endif () + + foreach (IT ${BLAS_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if (${_LIBRARIES}) + else () + check_fortran_libraries( + ${_LIBRARIES} + BLAS + ${BLAS_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + endif () + endforeach () + + endif () +endif () + + +if(BLA_F95) + if(BLAS95_LIBRARIES) + set(BLAS95_FOUND TRUE) + else() + set(BLAS95_FOUND FALSE) + endif() + + if(NOT BLAS_FIND_QUIETLY) + if(BLAS95_FOUND) + message(STATUS "A library with BLAS95 API found.") + else() + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with BLAS95 API not found. Please specify library location.") + else() + message(STATUS + "A library with BLAS95 API not found. Please specify library location.") + endif() + endif() + endif() + set(BLAS_FOUND TRUE) + set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") +else() + if(BLAS_LIBRARIES) + set(BLAS_FOUND TRUE) + else() + set(BLAS_FOUND FALSE) + endif() + + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_FOUND) + message(STATUS "A library with BLAS API found.") + else() + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with BLAS API not found. Please specify library location." + ) + else() + message(STATUS + "A library with BLAS API not found. Please specify library location." + ) + endif() + endif() + endif() +endif() + +cmake_pop_check_state() +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) From 4f3f93c7ddef6071be04406e6d0c84b4ef6ae182 Mon Sep 17 00:00:00 2001 From: Joan Massich Date: Fri, 12 Jan 2018 18:41:15 +0100 Subject: [PATCH 04/18] fix mkl static --- cmake/FindBLAS2.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindBLAS2.cmake b/cmake/FindBLAS2.cmake index b8f6686..85be5a3 100644 --- a/cmake/FindBLAS2.cmake +++ b/cmake/FindBLAS2.cmake @@ -490,7 +490,7 @@ endif () #BLAS in intel mkl 10 library? (em64t 64bit) if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT WIN32) - set(LM "-lm") + set(LM "-lm -ldl") endif () if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) From 310d66f329dad735b41b5544404c38681584f706 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Fri, 12 Jan 2018 20:55:49 +0100 Subject: [PATCH 05/18] fix linux mkl static + cleanup --- .travis.yml | 2 +- CMakeLists.txt | 14 +++----------- cmake/{FindBLAS2.cmake => FindBLAS.cmake} | 5 ++++- 3 files changed, 8 insertions(+), 13 deletions(-) rename cmake/{FindBLAS2.cmake => FindBLAS.cmake} (99%) diff --git a/.travis.yml b/.travis.yml index 767d079..22d1dcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,7 +103,7 @@ script: - export CMAKE_OPTIONS="-DCMAKE_CXX_STANDARD=11 -DBLA_VENDOR=$BACKEND" - | if [[ "${BUILD_STATIC}" == "1" ]]; then - export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC=1" + export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC=ON" fi - echo "cmake .. ${CMAKE_OPTIONS}" - cmake .. ${CMAKE_OPTIONS} diff --git a/CMakeLists.txt b/CMakeLists.txt index a9ed3c2..9b880dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,14 +7,10 @@ set (CMakeHelloWorld_VERSION_MINOR 0) # Find the BLAS stuff set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) -find_package(BLAS2 REQUIRED) +find_package(BLAS REQUIRED) message(STATUS "BLAS Libraries: ${BLAS_LIBRARIES}") -# find_path(BLAS_INCLUDE_DIRS NAMES cblas.h) -# message(STATUS "BLAS Include: ${BLAS_INCLUDE_DIRS}") -# include_directories(${BLAS_INCLUDE_DIRS}) - set(BLA_DEFINITIONS) if (BLA_VENDOR MATCHES Intel) if ("$ENV{MKLROOT}" STREQUAL "") @@ -30,14 +26,10 @@ elseif (BLA_VENDOR MATCHES ATLAS) set(BLAS_LIBRARIES "${BLAS_LIBRARIES};${CBLAS_LIB}") endif() -# include_directories(SYSTEM -# C:\\nuget_openblas\\OpenBLAS.0.2.14.1\\lib\\native\\include\\ -# C:\\OpenBLAS.0.2.14.1\\lib\\native\\include\\) - -#include the subdirectory containing our libs +# include the subdirectory containing our libs add_subdirectory(Hello) include_directories(Hello) -#indicate the entry point for the executable +# indicate the entry point for the executable add_executable(CMakeHelloWorld Hello HelloWorld.cpp) # Indicate which libraries to include during the link process. diff --git a/cmake/FindBLAS2.cmake b/cmake/FindBLAS.cmake similarity index 99% rename from cmake/FindBLAS2.cmake rename to cmake/FindBLAS.cmake index b8f6686..09f4d47 100644 --- a/cmake/FindBLAS2.cmake +++ b/cmake/FindBLAS.cmake @@ -489,8 +489,11 @@ endif () #BLAS in intel mkl 10 library? (em64t 64bit) if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (NOT WIN32) + if (UNIX) set(LM "-lm") + if (NOT APPLE) + set(LM "${LM} -ldl") + endif () endif () if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) From 0d9bff05a9f63760f4174b473f50c085de3d076b Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Fri, 12 Jan 2018 21:06:02 +0100 Subject: [PATCH 06/18] add non sequential mkl to travis --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.travis.yml b/.travis.yml index 22d1dcd..d1403c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,13 @@ matrix: - os: linux env: - BACKEND=Intel10_64lp_seq + - os: linux + env: + - BACKEND=Intel10_64lp + - BUILD_STATIC=1 + - os: linux + env: + - BACKEND=Intel10_64lp - os: osx env: - BACKEND=Apple @@ -45,6 +52,13 @@ matrix: env: - BACKEND=Intel10_64lp_seq - BUILD_STATIC=1 + - os: osx + env: + - BACKEND=Intel10_64lp + - os: osx + env: + - BACKEND=Intel10_64lp + - BUILD_STATIC=1 before_install: # Dependencies required by the CI are installed in ${TRAVIS_BUILD_DIR}/deps/ From f78cea54908787f9e18d273705017bb25b20b5fc Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Fri, 12 Jan 2018 21:40:36 +0100 Subject: [PATCH 07/18] oups --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d1403c4..64c708c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -88,7 +88,7 @@ before_install: # Install MKL ############################################################################ - | - if [[ "${BACKEND}" == "Intel10_64lp_seq" ]]; then + if [[ "${BACKEND}" == *"Intel"* ]]; then if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then export MKL_INSTALL_DIR=$(pwd)/intel wget http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/12070/l_mkl_2018.0.128.tgz From 87920c8716df2f577594a119ba36c47964f92b6e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Fri, 12 Jan 2018 21:45:09 +0100 Subject: [PATCH 08/18] add openblas on mac --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 64c708c..0ec4edf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,6 +59,9 @@ matrix: env: - BACKEND=Intel10_64lp - BUILD_STATIC=1 + - os: osx + env: + - BACKEND=OpenBLAS before_install: # Dependencies required by the CI are installed in ${TRAVIS_BUILD_DIR}/deps/ @@ -80,6 +83,10 @@ before_install: export PATH=${DEPS_DIR}/cmake/bin:${PATH} else brew install cmake || brew upgrade cmake + if [[ "${BACKEND}" == "OpenBLAS" ]]; then + brew tap homebrew/science + brew install openblas + fi fi - which cmake - cmake --version From 84f48a654a7342dd78511364d4a57bdd26c3f042 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sat, 13 Jan 2018 08:50:00 +0100 Subject: [PATCH 09/18] make verbose --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0ec4edf..6736c4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -128,7 +128,8 @@ script: fi - echo "cmake .. ${CMAKE_OPTIONS}" - cmake .. ${CMAKE_OPTIONS} - - cmake --build . + - make VERBOSE=1 + # - cmake --build . - | if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then ldd ./CMakeHelloWorld From 9bd0989cec836d71462a81737806dcb23a8f1260 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 09:29:50 +0100 Subject: [PATCH 10/18] breww misc --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6736c4c..69c4331 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,7 +84,6 @@ before_install: else brew install cmake || brew upgrade cmake if [[ "${BACKEND}" == "OpenBLAS" ]]; then - brew tap homebrew/science brew install openblas fi fi From 8567987f8a900edf5a887fa9d5336d8658594d7c Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 14:09:47 +0100 Subject: [PATCH 11/18] install omp for parallel backend --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 69c4331..ba8338c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,9 +39,21 @@ matrix: env: - BACKEND=Intel10_64lp - BUILD_STATIC=1 + addons: + sources: + - ubuntu-toolchain-r-test + apt: + packages: + - libomp-dev - os: linux env: - BACKEND=Intel10_64lp + addons: + sources: + - ubuntu-toolchain-r-test + apt: + packages: + - libomp-dev - os: osx env: - BACKEND=Apple From 6787708503268b6b91eb76616b03e9caacc87407 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 14:22:09 +0100 Subject: [PATCH 12/18] debug --- .travis.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba8338c..25886eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,21 +39,9 @@ matrix: env: - BACKEND=Intel10_64lp - BUILD_STATIC=1 - addons: - sources: - - ubuntu-toolchain-r-test - apt: - packages: - - libomp-dev - os: linux env: - BACKEND=Intel10_64lp - addons: - sources: - - ubuntu-toolchain-r-test - apt: - packages: - - libomp-dev - os: osx env: - BACKEND=Apple @@ -137,6 +125,7 @@ script: if [[ "${BUILD_STATIC}" == "1" ]]; then export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC=ON" fi + - echo "LIBRARY_PATH: $LD_LIBRARY_PATH $DYLD_LIBRARY_PATH" - echo "cmake .. ${CMAKE_OPTIONS}" - cmake .. ${CMAKE_OPTIONS} - make VERBOSE=1 From 267342dc6f3f59e4837dac2a5b03f339344ffc8c Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 14:28:48 +0100 Subject: [PATCH 13/18] debug --- cmake/FindBLAS.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/FindBLAS.cmake b/cmake/FindBLAS.cmake index 09f4d47..403e2cb 100644 --- a/cmake/FindBLAS.cmake +++ b/cmake/FindBLAS.cmake @@ -560,7 +560,8 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # mkl >= 10.3 if (CMAKE_C_COMPILER MATCHES ".+gcc") list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core iomp5") + # "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") else () list(APPEND BLAS_SEARCH_LIBS "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") From 40c3d24294edc47ee610dca0f1aa39cd08ffbe68 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 14:35:02 +0100 Subject: [PATCH 14/18] debug --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 25886eb..7eb4a32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -125,7 +125,8 @@ script: if [[ "${BUILD_STATIC}" == "1" ]]; then export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC=ON" fi - - echo "LIBRARY_PATH: $LD_LIBRARY_PATH $DYLD_LIBRARY_PATH" + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then echo "LIBRARY_PATH: $LD_LIBRARY_PATH"; fi + - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then echo "LIBRARY_PATH: $DYLD_LIBRARY_PATH"; fi - echo "cmake .. ${CMAKE_OPTIONS}" - cmake .. ${CMAKE_OPTIONS} - make VERBOSE=1 From 6b72dcce9639553cddcf1191c52065bd0330c424 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 14:49:35 +0100 Subject: [PATCH 15/18] debug --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7eb4a32..b142f83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -125,8 +125,8 @@ script: if [[ "${BUILD_STATIC}" == "1" ]]; then export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBLA_STATIC=ON" fi - - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then echo "LIBRARY_PATH: $LD_LIBRARY_PATH"; fi - - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then echo "LIBRARY_PATH: $DYLD_LIBRARY_PATH"; fi + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then echo $LD_LIBRARY_PATH; fi + - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then echo $DYLD_LIBRARY_PATH; fi - echo "cmake .. ${CMAKE_OPTIONS}" - cmake .. ${CMAKE_OPTIONS} - make VERBOSE=1 From b88bc6cda7ef3f527f0727e58b75192fb66f1a9e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 15:55:38 +0100 Subject: [PATCH 16/18] use intel thread + iomp even with GCC --- cmake/FindBLAS.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/FindBLAS.cmake b/cmake/FindBLAS.cmake index 403e2cb..c0434b7 100644 --- a/cmake/FindBLAS.cmake +++ b/cmake/FindBLAS.cmake @@ -615,7 +615,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") endforeach() endforeach() - else () + else () # UNIX if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS "mkl_intel mkl_intel_thread mkl_core guide") @@ -629,7 +629,8 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # mkl >= 10.3 if (CMAKE_C_COMPILER MATCHES ".+gcc") list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + # "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") else () list(APPEND BLAS_SEARCH_LIBS "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") From 7500b6e6e26239c97e5ee6452edd32354baec8ce Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 16:06:37 +0100 Subject: [PATCH 17/18] debug --- cmake/CheckFunctionExists.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CheckFunctionExists.cmake b/cmake/CheckFunctionExists.cmake index ef08062..6739b24 100644 --- a/cmake/CheckFunctionExists.cmake +++ b/cmake/CheckFunctionExists.cmake @@ -75,6 +75,7 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) + message(${OUTPUT}) unset(_cfe_source) if(${VARIABLE}) From 5495daffb93439c2a0815875fef0a5be7a7290d5 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 14 Jan 2018 21:53:00 +0100 Subject: [PATCH 18/18] remove broken builds --- .travis.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index b142f83..e228c93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,17 +28,9 @@ matrix: apt: packages: - libatlas-base-dev - - os: linux - env: - - BACKEND=Intel10_64lp_seq - - BUILD_STATIC=1 - os: linux env: - BACKEND=Intel10_64lp_seq - - os: linux - env: - - BACKEND=Intel10_64lp - - BUILD_STATIC=1 - os: linux env: - BACKEND=Intel10_64lp @@ -59,9 +51,6 @@ matrix: env: - BACKEND=Intel10_64lp - BUILD_STATIC=1 - - os: osx - env: - - BACKEND=OpenBLAS before_install: # Dependencies required by the CI are installed in ${TRAVIS_BUILD_DIR}/deps/