From 11d5f6dcfae146e74aa3514a7166b1f85dfdfc41 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 17 Aug 2021 00:23:33 -0700 Subject: [PATCH 01/14] [blas] Re-add port blas --- ports/blas/CMakeLists.txt | 4 --- ports/blas/CONTROL | 4 --- ports/blas/copyright | 5 ++++ ports/blas/portfile.cmake | 51 ++++++++++++++++++++++++++++++++++++--- ports/blas/vcpkg.json | 26 ++++++++++++++++++++ 5 files changed, 78 insertions(+), 12 deletions(-) delete mode 100644 ports/blas/CMakeLists.txt delete mode 100644 ports/blas/CONTROL create mode 100644 ports/blas/copyright create mode 100644 ports/blas/vcpkg.json diff --git a/ports/blas/CMakeLists.txt b/ports/blas/CMakeLists.txt deleted file mode 100644 index 790f79e8baa70e..00000000000000 --- a/ports/blas/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -project(Find_BLAS_external) -find_package(BLAS REQUIRED) diff --git a/ports/blas/CONTROL b/ports/blas/CONTROL deleted file mode 100644 index 6f660d228e5580..00000000000000 --- a/ports/blas/CONTROL +++ /dev/null @@ -1,4 +0,0 @@ -Source: blas -Version: 1 -Description: Metapackage for packages which provide BLAS -Build-Depends: openblas diff --git a/ports/blas/copyright b/ports/blas/copyright new file mode 100644 index 00000000000000..c91214fbc2b149 --- /dev/null +++ b/ports/blas/copyright @@ -0,0 +1,5 @@ +The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. + +Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. \ No newline at end of file diff --git a/ports/blas/portfile.cmake b/ports/blas/portfile.cmake index f70aa46eabd3fb..e5388d07e905dc 100644 --- a/ports/blas/portfile.cmake +++ b/ports/blas/portfile.cmake @@ -1,5 +1,48 @@ -SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) +SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) -# Make sure BLAS can be found -vcpkg_configure_cmake(SOURCE_PATH ${CURRENT_PORT_DIR} - OPTIONS -DCMAKE_PREFIX_PATH="${CURRENT_PACKAGES_DIR}") +vcpkg_download_distfile(ARCHIVE + URLS "http://www.netlib.org/blas/blas-3.10.0.tgz" + FILENAME "blas-3.10.0.tgz" + SHA512 1f243ce4f7e0974e62c03c49da2741509662e20e82d0ebb73e10a940cff6458739b9dc238125d5e1ae7c179eaba06155bb502327bd58eaf246c29a16e554eeb0 +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES +) + + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + single BUILD_SINGLE + double BUILD_DOUBLE + complex BUILD_COMPLEX + complex16 BUILD_COMPLEX16 +) + +if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(BUILD_X64 ON) +else() + set(BUILD_X64 OFF) +endif() + +include(vcpkg_find_fortran) +vcpkg_find_fortran(FORTRAN_CMAKE) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + ${FEATURE_OPTIONS} + ${FORTRAN_CMAKE} + -DBUILD_INDEX64=${BUILD_X64} + -DBUILD_TESTING=OFF +) + +vcpkg_install_cmake() +vcpkg_copy_pdbs() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/blas/vcpkg.json b/ports/blas/vcpkg.json new file mode 100644 index 00000000000000..97e21b23cd0089 --- /dev/null +++ b/ports/blas/vcpkg.json @@ -0,0 +1,26 @@ +{ + "name": "blas", + "version-semver": "3.10.0", + "description": "Metapackage for packages which provide BLAS", + "homepage": "http://www.netlib.org/blas/", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + } + ], + "features": { + "complex": { + "description": "Build single precision complex" + }, + "complex16": { + "description": "Build double precision complex" + }, + "double": { + "description": "Build double precision real" + }, + "single": { + "description": "Build single precision real" + } + } +} From 5594726cf565530a24de9ade8132bef1ffbea519 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 17 Aug 2021 00:29:08 -0700 Subject: [PATCH 02/14] Add patch --- ports/blas/fix-install.patch | 13 +++++++++++++ ports/blas/portfile.cmake | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 ports/blas/fix-install.patch diff --git a/ports/blas/fix-install.patch b/ports/blas/fix-install.patch new file mode 100644 index 00000000000000..90cc83ea066d49 --- /dev/null +++ b/ports/blas/fix-install.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e8d1c1b..d1f320e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -62,7 +62,7 @@ macro(blas_install_library lib) + EXPORT ${BLAS_INSTALL_EXPORT_NAME} + ARCHIVE DESTINATION lib COMPONENT Development + LIBRARY DESTINATION lib COMPONENT RuntimeLibraries +- RUNTIME DESTINATION lib COMPONENT RuntimeLibraries ++ RUNTIME DESTINATION bin COMPONENT RuntimeLibraries + ) + endmacro() + diff --git a/ports/blas/portfile.cmake b/ports/blas/portfile.cmake index e5388d07e905dc..1d6a589333a900 100644 --- a/ports/blas/portfile.cmake +++ b/ports/blas/portfile.cmake @@ -1,15 +1,15 @@ SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) vcpkg_download_distfile(ARCHIVE - URLS "http://www.netlib.org/blas/blas-3.10.0.tgz" - FILENAME "blas-3.10.0.tgz" - SHA512 1f243ce4f7e0974e62c03c49da2741509662e20e82d0ebb73e10a940cff6458739b9dc238125d5e1ae7c179eaba06155bb502327bd58eaf246c29a16e554eeb0 + URLS "http://www.netlib.org/blas/blas-3.10.0.tgz" + FILENAME "blas-3.10.0.tgz" + SHA512 1f243ce4f7e0974e62c03c49da2741509662e20e82d0ebb73e10a940cff6458739b9dc238125d5e1ae7c179eaba06155bb502327bd58eaf246c29a16e554eeb0 ) vcpkg_extract_source_archive_ex( - OUT_SOURCE_PATH SOURCE_PATH - ARCHIVE ${ARCHIVE} - PATCHES + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES fix-install.patch ) @@ -31,13 +31,13 @@ include(vcpkg_find_fortran) vcpkg_find_fortran(FORTRAN_CMAKE) vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS - ${FEATURE_OPTIONS} - ${FORTRAN_CMAKE} - -DBUILD_INDEX64=${BUILD_X64} - -DBUILD_TESTING=OFF + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + ${FEATURE_OPTIONS} + ${FORTRAN_CMAKE} + -DBUILD_INDEX64=${BUILD_X64} + -DBUILD_TESTING=OFF ) vcpkg_install_cmake() From 1e19f464f2cc5ffc14a8afb26eedf9a971aa030a Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 17 Aug 2021 00:33:08 -0700 Subject: [PATCH 03/14] Add cmake usage --- ports/blas/portfile.cmake | 1 + ports/blas/usage | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 ports/blas/usage diff --git a/ports/blas/portfile.cmake b/ports/blas/portfile.cmake index 1d6a589333a900..be2e4ce3cd7e3c 100644 --- a/ports/blas/portfile.cmake +++ b/ports/blas/portfile.cmake @@ -45,4 +45,5 @@ vcpkg_copy_pdbs() vcpkg_fixup_pkgconfig() +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/blas/usage b/ports/blas/usage new file mode 100644 index 00000000000000..5ad5bd068f9787 --- /dev/null +++ b/ports/blas/usage @@ -0,0 +1,5 @@ +Use this package via the module FindBLAS that comes with CMake. To use in your CMakeLists.txt: + + find_package(BLAS REQUIRED) + target_compile_options(main PRIVATE ${BLAS_LINKER_FLAGS}) + target_link_libraries(main PRIVATE ${BLAS_LIBRARIES}) From 6db9e1122ed3d2bf32eab4342f4552348ee686f5 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 17 Aug 2021 00:38:08 -0700 Subject: [PATCH 04/14] Use modern cmake related functions, set default features --- ports/blas/portfile.cmake | 5 ++--- ports/blas/vcpkg.json | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/blas/portfile.cmake b/ports/blas/portfile.cmake index be2e4ce3cd7e3c..eba74f354e8f0d 100644 --- a/ports/blas/portfile.cmake +++ b/ports/blas/portfile.cmake @@ -30,9 +30,8 @@ endif() include(vcpkg_find_fortran) vcpkg_find_fortran(FORTRAN_CMAKE) -vcpkg_configure_cmake( +vcpkg_cmake_configure( SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA OPTIONS ${FEATURE_OPTIONS} ${FORTRAN_CMAKE} @@ -40,7 +39,7 @@ vcpkg_configure_cmake( -DBUILD_TESTING=OFF ) -vcpkg_install_cmake() +vcpkg_cmake_install() vcpkg_copy_pdbs() vcpkg_fixup_pkgconfig() diff --git a/ports/blas/vcpkg.json b/ports/blas/vcpkg.json index 97e21b23cd0089..8d499c543130b4 100644 --- a/ports/blas/vcpkg.json +++ b/ports/blas/vcpkg.json @@ -9,6 +9,10 @@ "host": true } ], + "default-features": [ + "complex", + "single" + ], "features": { "complex": { "description": "Build single precision complex" From 735f4c524c1d010590e02329105b2c86ad291802 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 17 Aug 2021 00:59:50 -0700 Subject: [PATCH 05/14] Add dependency vcpkg-gfortran on Windows --- ports/blas/vcpkg.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/blas/vcpkg.json b/ports/blas/vcpkg.json index 8d499c543130b4..caeabde6abb0db 100644 --- a/ports/blas/vcpkg.json +++ b/ports/blas/vcpkg.json @@ -7,6 +7,10 @@ { "name": "vcpkg-cmake", "host": true + }, + { + "name": "vcpkg-gfortran", + "platform": "windows" } ], "default-features": [ From 385a2b24fbf04769db22bccb60fb675bb729e640 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 30 Aug 2021 20:13:25 -0700 Subject: [PATCH 06/14] Revert changes and add new port blas-reference --- ports/blas-reference/FindBLAS.cmake | 1191 +++++++++++++++++ ports/{blas => blas-reference}/copyright | 0 .../fix-install.patch | 0 ports/blas-reference/portfile.cmake | 50 + ports/{blas => blas-reference}/usage | 0 .../blas-reference/vcpkg-cmake-wrapper.cmake | 12 + ports/{blas => blas-reference}/vcpkg.json | 4 +- ports/blas/CMakeLists.txt | 4 + ports/blas/CONTROL | 4 + ports/blas/portfile.cmake | 51 +- 10 files changed, 1268 insertions(+), 48 deletions(-) create mode 100644 ports/blas-reference/FindBLAS.cmake rename ports/{blas => blas-reference}/copyright (100%) rename ports/{blas => blas-reference}/fix-install.patch (100%) create mode 100644 ports/blas-reference/portfile.cmake rename ports/{blas => blas-reference}/usage (100%) create mode 100644 ports/blas-reference/vcpkg-cmake-wrapper.cmake rename ports/{blas => blas-reference}/vcpkg.json (92%) create mode 100644 ports/blas/CMakeLists.txt create mode 100644 ports/blas/CONTROL diff --git a/ports/blas-reference/FindBLAS.cmake b/ports/blas-reference/FindBLAS.cmake new file mode 100644 index 00000000000000..2e7bdda69644c3 --- /dev/null +++ b/ports/blas-reference/FindBLAS.cmake @@ -0,0 +1,1191 @@ + +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindBLAS +-------- + +Find Basic Linear Algebra Subprograms (BLAS) library + +This module finds an installed Fortran library that implements the +`BLAS linear-algebra interface`_. + +At least one of the ``C``, ``CXX``, or ``Fortran`` languages must be enabled. + +.. _`BLAS linear-algebra interface`: http://www.netlib.org/blas/ + +Input Variables +^^^^^^^^^^^^^^^ + +The following variables may be set to influence this module's behavior: + +``BLA_STATIC`` + if ``ON`` use static linkage + +``BLA_VENDOR`` + Set to one of the :ref:`BLAS/LAPACK Vendors` to search for BLAS only + from the specified vendor. If not set, all vendors are considered. + +``BLA_F95`` + if ``ON`` tries to find the BLAS95 interfaces + +``BLA_PREFER_PKGCONFIG`` + .. versionadded:: 3.11 + + if set ``pkg-config`` will be used to search for a BLAS library first + and if one is found that is preferred + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``BLAS::BLAS`` + .. versionadded:: 3.18 + + The libraries to use for BLAS, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``BLAS_FOUND`` + 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 (may be empty if compiler implicitly links BLAS) +``BLAS95_LIBRARIES`` + uncached list of libraries (using full path name) to link against + to use BLAS95 interface +``BLAS95_FOUND`` + library implementing the BLAS95 interface is found + +.. _`BLAS/LAPACK Vendors`: + +BLAS/LAPACK Vendors +^^^^^^^^^^^^^^^^^^^ + +``Generic`` + Generic reference implementation + +``ACML``, ``ACML_MP``, ``ACML_GPU`` + AMD Core Math Library + +``Apple``, ``NAS`` + Apple BLAS (Accelerate), and Apple NAS (vecLib) + +``Arm``, ``Arm_mp``, ``Arm_ilp64``, ``Arm_ilp64_mp`` + .. versionadded:: 3.18 + + Arm Performance Libraries + +``ATLAS`` + Automatically Tuned Linear Algebra Software + +``CXML``, ``DXML`` + Compaq/Digital Extended Math Library + +``EML``, ``EML_mt`` + .. versionadded:: 3.20 + + Elbrus Math Library + +``FLAME`` + .. versionadded:: 3.11 + + BLIS Framework + +``FlexiBLAS`` + .. versionadded:: 3.19 + +``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP`` + .. versionadded:: 3.20 + + Fujitsu SSL2 serial and parallel blas/lapack + +``Goto`` + GotoBLAS + +``IBMESSL`` + IBM Engineering and Scientific Subroutine Library + +``Intel`` + Intel MKL 32 bit and 64 bit obsolete versions + +``Intel10_32`` + Intel MKL v10 32 bit, threaded code + +``Intel10_64lp`` + Intel MKL v10+ 64 bit, threaded code, lp64 model + +``Intel10_64lp_seq`` + Intel MKL v10+ 64 bit, sequential code, lp64 model + +``Intel10_64ilp`` + .. versionadded:: 3.13 + + Intel MKL v10+ 64 bit, threaded code, ilp64 model + +``Intel10_64ilp_seq`` + .. versionadded:: 3.13 + + Intel MKL v10+ 64 bit, sequential code, ilp64 model + +``Intel10_64_dyn`` + .. versionadded:: 3.17 + + Intel MKL v10+ 64 bit, single dynamic library + +``NVHPC`` + .. versionadded:: 3.21 + + NVIDIA HPC SDK + +``OpenBLAS`` + .. versionadded:: 3.6 + +``PhiPACK`` + Portable High Performance ANSI C (PHiPAC) + +``SCSL``, ``SCSL_mp`` + Scientific Computing Software Library + +``SGIMATH`` + SGI Scientific Mathematical Library + +``SunPerf`` + Sun Performance Library + +.. _`Intel MKL`: + +Intel MKL +^^^^^^^^^ + +To use the Intel MKL implementation of BLAS, a project must enable at least +one of the ``C`` or ``CXX`` languages. Set ``BLA_VENDOR`` to an Intel MKL +variant either on the command-line as ``-DBLA_VENDOR=Intel10_64lp`` or in +project code: + +.. code-block:: cmake + + set(BLA_VENDOR Intel10_64lp) + find_package(BLAS) + +In order to build a project using Intel MKL, and end user must first +establish an Intel MKL environment: + +Intel oneAPI + Source the full Intel environment script: + + .. code-block:: shell + + . /opt/intel/oneapi/setvars.sh + + Or, source the MKL component environment script: + + .. code-block:: shell + + . /opt/intel/oneapi/mkl/latest/env/vars.sh + +Intel Classic + Source the full Intel environment script: + + .. code-block:: shell + + . /opt/intel/bin/compilervars.sh intel64 + + Or, source the MKL component environment script: + + .. code-block:: shell + + . /opt/intel/mkl/bin/mklvars.sh intel64 + +The above environment scripts set the ``MKLROOT`` environment variable +to the top of the MKL installation. They also add the location of the +runtime libraries to the dynamic library loader environment variable for +your platform (e.g. ``LD_LIBRARY_PATH``). This is necessary for programs +linked against MKL to run. + +.. note:: + + As of Intel oneAPI 2021.2, loading only the MKL component does not + make all of its dependencies available. In particular, the ``iomp5`` + library must be available separately, or provided by also loading + the compiler component environment: + + .. code-block:: shell + + . /opt/intel/oneapi/compiler/latest/env/vars.sh + +#]=======================================================================] + +# The approach follows that of the ``autoconf`` macro file, ``acx_blas.m4`` +# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). + +# 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() + +function(_add_blas_target) + if(BLAS_FOUND AND NOT TARGET BLAS::BLAS) + add_library(BLAS::BLAS INTERFACE IMPORTED) + if(BLAS_LIBRARIES) + set_target_properties(BLAS::BLAS PROPERTIES + INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}" + ) + endif() + if(BLAS_LINKER_FLAGS) + set_target_properties(BLAS::BLAS PROPERTIES + INTERFACE_LINK_OPTIONS "${BLAS_LINKER_FLAGS}" + ) + endif() + endif() +endfunction() + +if(CMAKE_Fortran_COMPILER_LOADED) + include(${CMAKE_ROOT}/Modules/CheckFortranFunctionExists.cmake) +else() + include(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +endif() +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +if(BLA_PREFER_PKGCONFIG) + find_package(PkgConfig) + pkg_check_modules(PKGC_BLAS blas) + if(PKGC_BLAS_FOUND) + set(BLAS_FOUND ${PKGC_BLAS_FOUND}) + set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}") + _add_blas_target() + return() + endif() +endif() + +# TODO: move this stuff to a separate module + +function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) + # This function checks for the existence of the combination of libraries + # given by _list. If the combination is found, this checks 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. + + set(_libraries_work TRUE) + set(_libraries) + set(_combined_name) + + if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${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() + + set(_extaddlibdir "${_addlibdir}") + if(WIN32) + list(APPEND _extaddlibdir ENV LIB) + elseif(APPLE) + list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH) + else() + list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH) + endif() + list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + + foreach(_library ${_list}) + if(_library MATCHES "^-") + # Respect linker flags as-is (required by MKL) + list(APPEND _libraries "${_library}") + else() + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) + if(NOT "${_deps}" STREQUAL "") + set(_combined_name ${_combined_name}_deps) + endif() + if(_libraries_work) + find_library(${_prefix}_${_lib_var}_LIBRARY + NAMES ${_library} + NAMES_PER_DIR + PATHS ${_extaddlibdir} + PATH_SUFFIXES ${_subdirs} + ) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) + endif() + endif() + endforeach() + + foreach(_flag ${_flags}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") + set(_combined_name ${_combined_name}_${_flag_var}) + endforeach() + if(_libraries_work) + # Test this combination of libraries. + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_deps}) + set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) + 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) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) + endif() + + if(_libraries_work) + if("${_list}" STREQUAL "") + set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + else() + list(APPEND _libraries ${_deps}) + endif() + else() + set(_libraries FALSE) + endif() + set(${LIBRARIES} "${_libraries}" PARENT_SCOPE) +endfunction() + +set(BLAS_LINKER_FLAGS) +set(BLAS_LIBRARIES) +set(BLAS95_LIBRARIES) +set(_blas_fphsa_req_var BLAS_LIBRARIES) +if(NOT $ENV{BLA_VENDOR} STREQUAL "") + set(BLA_VENDOR $ENV{BLA_VENDOR}) +else() + if(NOT BLA_VENDOR) + set(BLA_VENDOR "All") + endif() +endif() + +# Implicitly linked BLAS libraries? +if(BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "" + "" + "" + "" + ) + endif() + if(BLAS_WORKS) + # Give a more helpful "found" message + set(BLAS_WORKS "implicitly linked") + set(_blas_fphsa_req_var BLAS_WORKS) + endif() +endif() + +# BLAS in the Intel MKL 10+ library? +if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + # System-specific settings + if(WIN32) + if(BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + else() + if(BLA_STATIC) + set(BLAS_mkl_START_GROUP "-Wl,--start-group") + set(BLAS_mkl_END_GROUP "-Wl,--end-group") + else() + set(BLAS_mkl_START_GROUP "") + set(BLAS_mkl_END_GROUP "") + endif() + # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it) + if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) + set(BLAS_mkl_INTFACE "gf") + set(BLAS_mkl_THREADING "gnu") + set(BLAS_mkl_OMP "gomp") + else() + set(BLAS_mkl_INTFACE "intel") + set(BLAS_mkl_THREADING "intel") + set(BLAS_mkl_OMP "iomp5") + endif() + set(BLAS_mkl_LM "-lm") + set(BLAS_mkl_LDL "-ldl") + endif() + + if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + find_package(Threads) + else() + find_package(Threads REQUIRED) + endif() + + if(BLA_VENDOR MATCHES "_64ilp") + set(BLAS_mkl_ILP_MODE "ilp64") + else() + set(BLAS_mkl_ILP_MODE "lp64") + endif() + + set(BLAS_SEARCH_LIBS "") + + if(BLA_F95) + set(BLAS_mkl_SEARCH_SYMBOL "sgemm_f95") + set(_BLAS_LIBRARIES BLAS95_LIBRARIES) + if(WIN32) + # 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_64i?lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" 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 "^Intel10_64i?lp_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") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") + + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS + "${BLAS_mkl_START_GROUP} mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") + + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS + "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") + endif() + endif() + else() + set(BLAS_mkl_SEARCH_SYMBOL sgemm) + set(_BLAS_LIBRARIES BLAS_LIBRARIES) + if(WIN32) + # 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_64i?lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" 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 "^Intel10_64i?lp_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") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") + + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") + + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") + endif() + + #older versions 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() + + if(BLA_VENDOR MATCHES "^Intel10_64_dyn$" OR BLA_VENDOR STREQUAL "All") + # mkl >= 10.3 with single dynamic library + list(APPEND BLAS_SEARCH_LIBS + "mkl_rt") + endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(BLAS_mkl_ARCH_NAME "ia32") + else() + set(BLAS_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(BLAS_mkl_OS_NAME "win") + elseif(APPLE) + set(BLAS_mkl_OS_NAME "mac") + else() + set(BLAS_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + file(TO_CMAKE_PATH "$ENV{MKLROOT}" BLAS_mkl_MKLROOT) + # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead + # so we can better detect other relevant libraries in 'compiler' or 'tbb': + get_filename_component(BLAS_mkl_MKLROOT_LAST_DIR "${BLAS_mkl_MKLROOT}" NAME) + if(BLAS_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") + get_filename_component(BLAS_mkl_MKLROOT "${BLAS_mkl_MKLROOT}" DIRECTORY) + endif() + endif() + set(BLAS_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "compiler/lib/${BLAS_mkl_ARCH_NAME}" + "mkl/lib" "mkl/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "mkl/lib/${BLAS_mkl_ARCH_NAME}" + "lib" "lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "lib/${BLAS_mkl_ARCH_NAME}" + ) + + foreach(_search ${BLAS_SEARCH_LIBS}) + string(REPLACE " " ";" _search ${_search}) + if(NOT ${_BLAS_LIBRARIES}) + check_blas_libraries( + ${_BLAS_LIBRARIES} + BLAS + ${BLAS_mkl_SEARCH_SYMBOL} + "" + "${_search}" + "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}" + "${BLAS_mkl_MKLROOT}" + "${BLAS_mkl_LIB_PATH_SUFFIXES}" + ) + endif() + endforeach() + + unset(_search) + unset(BLAS_mkl_ILP_MODE) + unset(BLAS_mkl_INTFACE) + unset(BLAS_mkl_THREADING) + unset(BLAS_mkl_OMP) + unset(BLAS_mkl_DLL_SUFFIX) + unset(BLAS_mkl_LM) + unset(BLAS_mkl_LDL) + unset(BLAS_mkl_MKLROOT) + unset(BLAS_mkl_MKLROOT_LAST_DIR) + unset(BLAS_mkl_ARCH_NAME) + unset(BLAS_mkl_OS_NAME) + unset(BLAS_mkl_LIB_PATH_SUFFIXES) + endif() + endif() +endif() + +if(BLA_F95) + find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES) + set(BLAS95_FOUND ${BLAS_FOUND}) + if(BLAS_FOUND) + set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") + endif() +endif() + +# gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) +if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "goto2" + "" + "" + "" + ) + endif() +endif() + +# FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/) +if(BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "flexiblas" + "" + "" + "" + ) + endif() +endif() + +# OpenBLAS? (http://www.openblas.net) +if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "openblas" + "" + "" + "" + ) + endif() + if(NOT BLAS_LIBRARIES AND (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(_threadlibs "${CMAKE_THREAD_LIBS_INIT}") + if(BLA_STATIC) + if (CMAKE_C_COMPILER_LOADED) + find_package(OpenMP COMPONENTS C) + list(PREPEND _threadlibs "${OpenMP_C_LIBRARIES}") + elseif(CMAKE_CXX_COMPILER_LOADED) + find_package(OpenMP COMPONENTS CXX) + list(PREPEND _threadlibs "${OpenMP_CXX_LIBRARIES}") + endif() + endif() + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "openblas" + "${_threadlibs}" + "" + "" + ) + unset(_threadlibs) + endif() +endif() + +# ArmPL blas library? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) +if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") + + # Check for 64bit Integer support + if(BLA_VENDOR MATCHES "_ilp64") + set(_blas_armpl_lib "armpl_ilp64") + else() + set(_blas_armpl_lib "armpl_lp64") + endif() + + # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp + if(BLA_VENDOR MATCHES "_mp") + set(_blas_armpl_lib "${_blas_armpl_lib}_mp") + endif() + + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${_blas_armpl_lib}" + "" + "" + "" + ) + endif() + unset(_blas_armpl_lib) +endif() + +# FLAME's blis library? (https://github.com/flame/blis) +if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "blis" + "" + "" + "" + ) + endif() +endif() + +# BLAS in the ATLAS library? (http://math-atlas.sourceforge.net/) +if(BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "blas;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_blas_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_blas_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_blas_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_blas_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 MATCHES "SCSL" OR BLA_VENDOR STREQUAL "All") + set(_blas_scsl_lib "scs") + + if(BLA_VENDOR MATCHES "_mp") + set(_blas_scsl_lib "${_blas_scsl_lib}_mp") + endif() + + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${_blas_scsl_lib}" + "" + "" + "" + ) + endif() + + unset(_blas_scsl_lib) +endif() + +# BLAS in SGIMATH library? +if(BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_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_blas_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 "IntelLLVM") + # 32-bit not supported + set(_ACML_COMPILER64 "ifx") + 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_blas_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_blas_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_blas_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_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv" + "" + "" + "" + ) +endif() +if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml_mp;acml_mv" + "" + "" + "" + ) +endif() +if(NOT BLAS_LIBRARIES) + check_blas_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_blas_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "Accelerate" + "" + "" + "" + ) + endif() +endif() + +# Apple NAS (vecLib) library? +if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "vecLib" + "" + "" + "" + ) + endif() +endif() + +# Elbrus Math Library? +if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All") + + set(_blas_eml_lib "eml") + + # Check for OpenMP support, VIA BLA_VENDOR of eml_mt + if(BLA_VENDOR MATCHES "_mt") + set(_blas_eml_lib "${_blas_eml_lib}_mt") + endif() + + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${_blas_eml_lib}" + "" + "" + "" + ) + endif() + unset(_blas_eml_lib) +endif() + +# Fujitsu SSL2 Library? +if(NOT BLAS_LIBRARIES + AND (BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All")) + if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP") + set(_ssl2_suffix BLAMP) + else() + set(_ssl2_suffix) + endif() + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "-SSL2${_ssl2_suffix}" + "" + "" + "" + "" + ) + if(BLAS_LIBRARIES) + set(BLAS_LINKER_FLAGS "-SSL2${_ssl2_suffix}") + set(_blas_fphsa_req_var BLAS_LINKER_FLAGS) + endif() + unset(_ssl2_suffix) +endif() + +# Generic BLAS library? +if(BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "NVHPC" OR + BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "blas" + "" + "" + "" + ) + endif() + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "blas64" + "" + "" + "" + ) + endif() +endif() + +# On compilers that implicitly link BLAS (i.e. CrayPrgEnv) we used a +# placeholder for empty BLAS_LIBRARIES to get through our logic above. +if(BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(BLAS_LIBRARIES "") +endif() + +if(NOT BLA_F95) + find_package_handle_standard_args(BLAS REQUIRED_VARS ${_blas_fphsa_req_var}) +endif() + +_add_blas_target() +unset(_blas_fphsa_req_var) +unset(_BLAS_LIBRARIES) \ No newline at end of file diff --git a/ports/blas/copyright b/ports/blas-reference/copyright similarity index 100% rename from ports/blas/copyright rename to ports/blas-reference/copyright diff --git a/ports/blas/fix-install.patch b/ports/blas-reference/fix-install.patch similarity index 100% rename from ports/blas/fix-install.patch rename to ports/blas-reference/fix-install.patch diff --git a/ports/blas-reference/portfile.cmake b/ports/blas-reference/portfile.cmake new file mode 100644 index 00000000000000..ea39e1a92ac663 --- /dev/null +++ b/ports/blas-reference/portfile.cmake @@ -0,0 +1,50 @@ +SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) + +vcpkg_download_distfile(ARCHIVE + URLS "http://www.netlib.org/blas/blas-3.10.0.tgz" + FILENAME "blas-3.10.0.tgz" + SHA512 1f243ce4f7e0974e62c03c49da2741509662e20e82d0ebb73e10a940cff6458739b9dc238125d5e1ae7c179eaba06155bb502327bd58eaf246c29a16e554eeb0 +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES fix-install.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + single BUILD_SINGLE + double BUILD_DOUBLE + complex BUILD_COMPLEX + complex16 BUILD_COMPLEX16 +) + +if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(BUILD_X64 ON) +else() + set(BUILD_X64 OFF) +endif() + +include(vcpkg_find_fortran) +vcpkg_find_fortran(FORTRAN_CMAKE) + +vcpkg_cmake_configure( + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + ${FEATURE_OPTIONS} + ${FORTRAN_CMAKE} + -DBUILD_INDEX64=${BUILD_X64} + -DBUILD_TESTING=OFF +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/FindBLAS.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/blas") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/blas") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/blas/usage b/ports/blas-reference/usage similarity index 100% rename from ports/blas/usage rename to ports/blas-reference/usage diff --git a/ports/blas-reference/vcpkg-cmake-wrapper.cmake b/ports/blas-reference/vcpkg-cmake-wrapper.cmake new file mode 100644 index 00000000000000..0c2ed67544fc80 --- /dev/null +++ b/ports/blas-reference/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,12 @@ +message(STATUS "Using VCPKG FindLAPACK from package 'blas-reference'") +set(LAPACK_PREV_MODULE_PATH ${CMAKE_MODULE_PATH}) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +list(REMOVE_ITEM ARGS "NO_MODULE") +list(REMOVE_ITEM ARGS "CONFIG") +list(REMOVE_ITEM ARGS "MODULE") + +set(BLA_VENDOR "Generic") +_find_package(${ARGS}) + +set(CMAKE_MODULE_PATH ${LAPACK_PREV_MODULE_PATH}) diff --git a/ports/blas/vcpkg.json b/ports/blas-reference/vcpkg.json similarity index 92% rename from ports/blas/vcpkg.json rename to ports/blas-reference/vcpkg.json index caeabde6abb0db..63425ce66031b9 100644 --- a/ports/blas/vcpkg.json +++ b/ports/blas-reference/vcpkg.json @@ -1,5 +1,5 @@ { - "name": "blas", + "name": "blas-reference", "version-semver": "3.10.0", "description": "Metapackage for packages which provide BLAS", "homepage": "http://www.netlib.org/blas/", @@ -15,6 +15,8 @@ ], "default-features": [ "complex", + "complex16", + "double", "single" ], "features": { diff --git a/ports/blas/CMakeLists.txt b/ports/blas/CMakeLists.txt new file mode 100644 index 00000000000000..790f79e8baa70e --- /dev/null +++ b/ports/blas/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.17) + +project(Find_BLAS_external) +find_package(BLAS REQUIRED) diff --git a/ports/blas/CONTROL b/ports/blas/CONTROL new file mode 100644 index 00000000000000..6f660d228e5580 --- /dev/null +++ b/ports/blas/CONTROL @@ -0,0 +1,4 @@ +Source: blas +Version: 1 +Description: Metapackage for packages which provide BLAS +Build-Depends: openblas diff --git a/ports/blas/portfile.cmake b/ports/blas/portfile.cmake index eba74f354e8f0d..f70aa46eabd3fb 100644 --- a/ports/blas/portfile.cmake +++ b/ports/blas/portfile.cmake @@ -1,48 +1,5 @@ -SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) -vcpkg_download_distfile(ARCHIVE - URLS "http://www.netlib.org/blas/blas-3.10.0.tgz" - FILENAME "blas-3.10.0.tgz" - SHA512 1f243ce4f7e0974e62c03c49da2741509662e20e82d0ebb73e10a940cff6458739b9dc238125d5e1ae7c179eaba06155bb502327bd58eaf246c29a16e554eeb0 -) - -vcpkg_extract_source_archive_ex( - OUT_SOURCE_PATH SOURCE_PATH - ARCHIVE ${ARCHIVE} - PATCHES fix-install.patch -) - - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - single BUILD_SINGLE - double BUILD_DOUBLE - complex BUILD_COMPLEX - complex16 BUILD_COMPLEX16 -) - -if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(BUILD_X64 ON) -else() - set(BUILD_X64 OFF) -endif() - -include(vcpkg_find_fortran) -vcpkg_find_fortran(FORTRAN_CMAKE) - -vcpkg_cmake_configure( - SOURCE_PATH ${SOURCE_PATH} - OPTIONS - ${FEATURE_OPTIONS} - ${FORTRAN_CMAKE} - -DBUILD_INDEX64=${BUILD_X64} - -DBUILD_TESTING=OFF -) - -vcpkg_cmake_install() -vcpkg_copy_pdbs() - -vcpkg_fixup_pkgconfig() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +# Make sure BLAS can be found +vcpkg_configure_cmake(SOURCE_PATH ${CURRENT_PORT_DIR} + OPTIONS -DCMAKE_PREFIX_PATH="${CURRENT_PACKAGES_DIR}") From 396507cfe7beea0394747de2f427d916fbca911d Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 30 Aug 2021 23:31:26 -0700 Subject: [PATCH 07/14] Fix FindBLAS.cmake to suitable for windows --- ports/blas-reference/FindBLAS.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/blas-reference/FindBLAS.cmake b/ports/blas-reference/FindBLAS.cmake index 2e7bdda69644c3..8ea050380902e4 100644 --- a/ports/blas-reference/FindBLAS.cmake +++ b/ports/blas-reference/FindBLAS.cmake @@ -319,7 +319,7 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib endif() if(_libraries_work) find_library(${_prefix}_${_lib_var}_LIBRARY - NAMES ${_library} + NAMES ${_library} lib${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} From ba0ba96865f4d335311341d720939d4e4bae74d3 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 31 Aug 2021 00:14:25 -0700 Subject: [PATCH 08/14] Fix find dependency blas-reference --- ports/lapack-reference/CONTROL | 17 ----- .../fix-dependency-blas.patch | 13 ++++ ports/lapack-reference/portfile.cmake | 68 +++++++------------ ports/lapack-reference/vcpkg.json | 48 +++++++++++++ 4 files changed, 87 insertions(+), 59 deletions(-) delete mode 100644 ports/lapack-reference/CONTROL create mode 100644 ports/lapack-reference/fix-dependency-blas.patch create mode 100644 ports/lapack-reference/vcpkg.json diff --git a/ports/lapack-reference/CONTROL b/ports/lapack-reference/CONTROL deleted file mode 100644 index 3e18ebd2b3db1c..00000000000000 --- a/ports/lapack-reference/CONTROL +++ /dev/null @@ -1,17 +0,0 @@ -Source: lapack-reference -Version: 3.8.0 -Port-Version: 5 -Description: LAPACK — Linear Algebra PACKage http://www.netlib.org/lapack/ -Default-Features: blas-select -Build-Depends: vcpkg-gfortran (windows) - -Feature: cblas -Description: Builds CBLAS - -Feature: noblas -Build-Depends: blas -Description: Use external optimized BLAS - -Feature: blas-select -Build-Depends: lapack-reference[core, noblas](!windows|!static) -Description: Use external optimized BLAS diff --git a/ports/lapack-reference/fix-dependency-blas.patch b/ports/lapack-reference/fix-dependency-blas.patch new file mode 100644 index 00000000000000..8fe55fd74eba16 --- /dev/null +++ b/ports/lapack-reference/fix-dependency-blas.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index caa0e71..9319694 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -196,7 +196,7 @@ if(BLAS_LIBRARIES) + endif() + + # User did not provide a BLAS Library but specified to search for one +-elseif(USE_OPTIMIZED_BLAS) ++elseif (USE_OPTIMIZED_BLAS OR USE_EXTERNAL_BLAS) + find_package(BLAS) + endif() + diff --git a/ports/lapack-reference/portfile.cmake b/ports/lapack-reference/portfile.cmake index 70e6059fff383b..563000ca53dfe9 100644 --- a/ports/lapack-reference/portfile.cmake +++ b/ports/lapack-reference/portfile.cmake @@ -19,6 +19,7 @@ vcpkg_from_github( REF "v${lapack_ver}" SHA512 17786cb7306fccdc9b4a242de7f64fc261ebe6a10b6ec55f519deb4cb673cb137e8742aa5698fd2dc52f1cd56d3bd116af3f593a01dcf6770c4dcc86c50b2a7f HEAD_REF master + PATCHES fix-dependency-blas.patch ) if(NOT VCPKG_TARGET_IS_WINDOWS) @@ -36,22 +37,16 @@ endif() set(USE_OPTIMIZED_BLAS OFF) if("noblas" IN_LIST FEATURES) set(USE_OPTIMIZED_BLAS ON) - set(pcfile "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/openblas.pc") - if(EXISTS "${pcfile}") - file(CREATE_LINK "${pcfile}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc" COPY_ON_ERROR) - endif() - set(pcfile "${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig/openblas.pc") - if(EXISTS "${pcfile}") - file(CREATE_LINK "${pcfile}" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc" COPY_ON_ERROR) - endif() endif() +set(USE_EXTERNAL_BLAS OFF) set(VCPKG_CRT_LINKAGE_BACKUP ${VCPKG_CRT_LINKAGE}) vcpkg_find_fortran(FORTRAN_CMAKE) if(VCPKG_USE_INTERNAL_Fortran) if(VCPKG_CRT_LINKAGE_BACKUP STREQUAL static) # If openblas has been built with static crt linkage we cannot use it with gfortran! - set(USE_OPTIMIZED_BLAS OFF) + set(USE_OPTIMIZED_BLAS OFF) + set(USE_EXTERNAL_BLAS ON) #Cannot use openblas from vcpkg if we are building with gfortran here. if("noblas" IN_LIST FEATURES) message(FATAL_ERROR "Feature 'noblas' cannot be used without supplying an external fortran compiler") @@ -60,43 +55,38 @@ if(VCPKG_USE_INTERNAL_Fortran) else() set(USE_OPTIMIZED_BLAS ON) endif() + vcpkg_configure_cmake( - PREFER_NINJA - SOURCE_PATH ${SOURCE_PATH} - OPTIONS - "-DUSE_OPTIMIZED_BLAS=${USE_OPTIMIZED_BLAS}" - "-DCBLAS=${CBLAS}" - ${FORTRAN_CMAKE} - ) + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + "-DUSE_OPTIMIZED_BLAS=${USE_OPTIMIZED_BLAS}" + "-DUSE_EXTERNAL_BLAS=${USE_EXTERNAL_BLAS}" + "-DCBLAS=${CBLAS}" + ${FORTRAN_CMAKE} +) vcpkg_install_cmake() -vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/lapack-${lapack_ver}) #Should the target path be lapack and not lapack-reference? + +vcpkg_cmake_config_fixup(PACKAGE_NAME lapack-${lapack_ver} CONFIG_PATH lib/cmake/lapack-${lapack_ver}) #Should the target path be lapack and not lapack-reference? set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc") if(EXISTS "${pcfile}") file(READ "${pcfile}" _contents) set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") + if (USE_EXTERNAL_BLAS) + string(REPLACE "blas" "blas64" _contents "${_contents}") + endif() file(WRITE "${pcfile}" "${_contents}") endif() set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc") if(EXISTS "${pcfile}") file(READ "${pcfile}" _contents) set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") -endif() -if(NOT USE_OPTIMIZED_BLAS) - set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc") - if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") - endif() - set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc") - if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") + if (USE_EXTERNAL_BLAS) + string(REPLACE "blas" "blas64" _contents "${_contents}") endif() + file(WRITE "${pcfile}" "${_contents}") endif() if("cblas" IN_LIST FEATURES) set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/cblas.pc") @@ -114,9 +104,6 @@ if("cblas" IN_LIST FEATURES) endif() vcpkg_fixup_pkgconfig() -# Handle copyright -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) - # remove debug includes file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) @@ -127,15 +114,12 @@ if(VCPKG_TARGET_IS_WINDOWS) if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/liblapack.lib") file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/liblapack.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/lapack.lib") endif() - if(NOT USE_OPTIMIZED_BLAS) - if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/libblas.lib") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/libblas.lib" "${CURRENT_PACKAGES_DIR}/lib/blas.lib") - endif() - if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/libblas.lib") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libblas.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/blas.lib") - endif() - endif() endif() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/lapack) file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindLAPACK.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/lapack) + +# Handle copyright +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/lapack-reference/vcpkg.json b/ports/lapack-reference/vcpkg.json new file mode 100644 index 00000000000000..1055635473fed9 --- /dev/null +++ b/ports/lapack-reference/vcpkg.json @@ -0,0 +1,48 @@ +{ + "name": "lapack-reference", + "version-semver": "3.8.0", + "port-version": 6, + "description": "LAPACK — Linear Algebra PACKage", + "homepage": "http://www.netlib.org/lapack/", + "dependencies": [ + { + "name": "vcpkg-cmake-config", + "host": true + }, + { + "name": "vcpkg-gfortran", + "platform": "windows" + } + ], + "default-features": [ + "blas-select" + ], + "features": { + "blas-select": { + "description": "Use external optimized BLAS", + "dependencies": [ + { + "name": "lapack-reference", + "default-features": false, + "features": [ + "noblas" + ], + "platform": "!windows | !static" + }, + { + "name": "blas-reference", + "platform": "windows & static" + } + ] + }, + "cblas": { + "description": "Builds CBLAS" + }, + "noblas": { + "description": "Use external optimized BLAS", + "dependencies": [ + "blas" + ] + } + } +} From 80a1121344b231778efc9dbef76b772a99583025 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 31 Aug 2021 01:07:49 -0700 Subject: [PATCH 09/14] Format and version --- ports/lapack-reference/vcpkg.json | 10 +++++----- versions/b-/blas-reference.json | 9 +++++++++ versions/baseline.json | 6 +++++- versions/l-/lapack-reference.json | 5 +++++ 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 versions/b-/blas-reference.json diff --git a/ports/lapack-reference/vcpkg.json b/ports/lapack-reference/vcpkg.json index 1055635473fed9..05eda9f5b972f9 100644 --- a/ports/lapack-reference/vcpkg.json +++ b/ports/lapack-reference/vcpkg.json @@ -1,7 +1,7 @@ { "name": "lapack-reference", "version-semver": "3.8.0", - "port-version": 6, + "port-version": 7, "description": "LAPACK — Linear Algebra PACKage", "homepage": "http://www.netlib.org/lapack/", "dependencies": [ @@ -21,6 +21,10 @@ "blas-select": { "description": "Use external optimized BLAS", "dependencies": [ + { + "name": "blas-reference", + "platform": "windows & static" + }, { "name": "lapack-reference", "default-features": false, @@ -28,10 +32,6 @@ "noblas" ], "platform": "!windows | !static" - }, - { - "name": "blas-reference", - "platform": "windows & static" } ] }, diff --git a/versions/b-/blas-reference.json b/versions/b-/blas-reference.json new file mode 100644 index 00000000000000..326752a3407a52 --- /dev/null +++ b/versions/b-/blas-reference.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "ebbc048418b7f2f92a4c7ee9086542505ea88350", + "version-semver": "3.10.0", + "port-version": 0 + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 39630f5d526a31..34e04306b23f4a 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -428,6 +428,10 @@ "baseline": "1", "port-version": 0 }, + "blas-reference": { + "baseline": "3.10.0", + "port-version": 0 + }, "blaze": { "baseline": "3.8", "port-version": 1 @@ -3022,7 +3026,7 @@ }, "lapack-reference": { "baseline": "3.8.0", - "port-version": 6 + "port-version": 7 }, "lastools": { "baseline": "2020-05-09", diff --git a/versions/l-/lapack-reference.json b/versions/l-/lapack-reference.json index 99d6f8a7cf3d92..f76a195e180a58 100644 --- a/versions/l-/lapack-reference.json +++ b/versions/l-/lapack-reference.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "cd99d7c45d9e1706bf6a2209b5eac9eb4a54d69c", + "version-semver": "3.8.0", + "port-version": 7 + }, { "git-tree": "10799c7ec42f8369179ba7a8e927235596cb8bb7", "version-semver": "3.8.0", From cde14871ee6772451e5a4ed2be61b8cadd8cb99e Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 31 Aug 2021 02:16:51 -0700 Subject: [PATCH 10/14] Fix pkgconfig --- ports/lapack-reference/portfile.cmake | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ports/lapack-reference/portfile.cmake b/ports/lapack-reference/portfile.cmake index 563000ca53dfe9..c79039fe5e9fe6 100644 --- a/ports/lapack-reference/portfile.cmake +++ b/ports/lapack-reference/portfile.cmake @@ -56,6 +56,16 @@ else() set(USE_OPTIMIZED_BLAS ON) endif() +if (USE_EXTERNAL_BLAS) + if (EXISTS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/blas64.pkg") + set(USED_BLAS_NAME "blas64") + else() + set(USED_BLAS_NAME "blas") + endif() +else() + set(USED_BLAS_NAME "openblas") +endif() + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA @@ -74,18 +84,14 @@ set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc") if(EXISTS "${pcfile}") file(READ "${pcfile}" _contents) set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") - if (USE_EXTERNAL_BLAS) - string(REPLACE "blas" "blas64" _contents "${_contents}") - endif() + string(REPLACE "blas" "${USED_BLAS_NAME}" _contents "${_contents}") file(WRITE "${pcfile}" "${_contents}") endif() set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc") if(EXISTS "${pcfile}") file(READ "${pcfile}" _contents) set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") - if (USE_EXTERNAL_BLAS) - string(REPLACE "blas" "blas64" _contents "${_contents}") - endif() + string(REPLACE "blas" "${USED_BLAS_NAME}" _contents "${_contents}") file(WRITE "${pcfile}" "${_contents}") endif() if("cblas" IN_LIST FEATURES) From f2950fd985096f133ccedb960c03ef47d8d0ba84 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 31 Aug 2021 19:15:58 -0700 Subject: [PATCH 11/14] Fix determine the pc file --- ports/lapack-reference/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/lapack-reference/portfile.cmake b/ports/lapack-reference/portfile.cmake index c79039fe5e9fe6..af430b9c937c70 100644 --- a/ports/lapack-reference/portfile.cmake +++ b/ports/lapack-reference/portfile.cmake @@ -57,7 +57,7 @@ else() endif() if (USE_EXTERNAL_BLAS) - if (EXISTS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/blas64.pkg") + if (EXISTS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/blas64.pc") set(USED_BLAS_NAME "blas64") else() set(USED_BLAS_NAME "blas") From d365472ef88f5847411bea9eec6da95a5991b1d8 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 31 Aug 2021 22:38:44 -0700 Subject: [PATCH 12/14] Use `vcpkg_configure_cmake` to avoid uwp issue --- ports/blas-reference/portfile.cmake | 5 +++-- ports/blas-reference/vcpkg.json | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ports/blas-reference/portfile.cmake b/ports/blas-reference/portfile.cmake index ea39e1a92ac663..0452e8cd0c3c9a 100644 --- a/ports/blas-reference/portfile.cmake +++ b/ports/blas-reference/portfile.cmake @@ -29,8 +29,9 @@ endif() include(vcpkg_find_fortran) vcpkg_find_fortran(FORTRAN_CMAKE) -vcpkg_cmake_configure( +vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA OPTIONS ${FEATURE_OPTIONS} ${FORTRAN_CMAKE} @@ -38,7 +39,7 @@ vcpkg_cmake_configure( -DBUILD_TESTING=OFF ) -vcpkg_cmake_install() +vcpkg_install_cmake() vcpkg_copy_pdbs() vcpkg_fixup_pkgconfig() diff --git a/ports/blas-reference/vcpkg.json b/ports/blas-reference/vcpkg.json index 63425ce66031b9..6a89d54cadf495 100644 --- a/ports/blas-reference/vcpkg.json +++ b/ports/blas-reference/vcpkg.json @@ -4,10 +4,6 @@ "description": "Metapackage for packages which provide BLAS", "homepage": "http://www.netlib.org/blas/", "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, { "name": "vcpkg-gfortran", "platform": "windows" From efa3c38b5c4e040ea8144a68ef089305cd2ead2f Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 31 Aug 2021 22:39:22 -0700 Subject: [PATCH 13/14] version --- versions/b-/blas-reference.json | 2 +- versions/l-/lapack-reference.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions/b-/blas-reference.json b/versions/b-/blas-reference.json index 326752a3407a52..b91bc336588977 100644 --- a/versions/b-/blas-reference.json +++ b/versions/b-/blas-reference.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "ebbc048418b7f2f92a4c7ee9086542505ea88350", + "git-tree": "9eb91f67594d14b2950aa1c2aaeab3f2760f8fa2", "version-semver": "3.10.0", "port-version": 0 } diff --git a/versions/l-/lapack-reference.json b/versions/l-/lapack-reference.json index f76a195e180a58..9418cc40a9d1bd 100644 --- a/versions/l-/lapack-reference.json +++ b/versions/l-/lapack-reference.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "cd99d7c45d9e1706bf6a2209b5eac9eb4a54d69c", + "git-tree": "7f3a5af692431a311e0523036809e3ef1ae9aa77", "version-semver": "3.8.0", "port-version": 7 }, From 38697c70b749bcdee0f0f8fb939456e7a48217cd Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 13 Sep 2021 14:33:53 -0700 Subject: [PATCH 14/14] Remove colmap from ci.baseline.txt. --- scripts/ci.baseline.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index f3ee0b4f5f2b4a..a6021a367c8b6c 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -147,7 +147,6 @@ cmcstl2:x86-windows = skip coin:arm64-windows=fail coin:arm-uwp=fail coin:x64-uwp=fail -colmap:x64-windows-static=fail concurrencpp:x64-linux=fail concurrencpp:x64-osx=fail constexpr-contracts:x64-linux=fail