Skip to content
Snippets Groups Projects
Unverified Commit d39e9914 authored by Tim Kaune's avatar Tim Kaune
Browse files

Merge pull request #3 from lepus2589/2-include-lapack-v3110-with-macos-15-sequoia

Include BLAS/LAPACK v3.11.0 with MacOS 15 Sequoia
parents 66f23d38 4cb9e0f7
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,11 @@ SOFTWARE. ...@@ -25,11 +25,11 @@ SOFTWARE.
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
set(CMAKE_MAXIMUM_SUPPORTED_VERSION 3.29) set(CMAKE_MAXIMUM_SUPPORTED_VERSION 3.30)
include("./cmake/HandlePolicies.cmake" NO_POLICY_SCOPE) include("./cmake/HandlePolicies.cmake" NO_POLICY_SCOPE)
project(AccelerateLAPACKE VERSION 1.0.0 LANGUAGES C) project(AccelerateLAPACKE VERSION 1.1.0 LANGUAGES C)
include(FetchContent) include(FetchContent)
...@@ -40,13 +40,68 @@ if (NOT IS_TOP_LEVEL) ...@@ -40,13 +40,68 @@ if (NOT IS_TOP_LEVEL)
endif () endif ()
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
# Mac OS X 13.3 Ventura # The available binary Accelerate version is determined by the MacOS system
if (CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 22.4) message(STATUS "The Darwin kernel version is: ${CMAKE_HOST_SYSTEM_VERSION}")
if (CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 24.0)
# Mac OS X 15.0 Sequoia or later
message(STATUS "The MacOS version is: >=15.0")
set(MINIMUM_MACOS_SDK_VERSION 15.0)
set(ACCELERATE_NEW_LAPACK_VERSION 3.11.0)
elseif (CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 22.4)
# Mac OS X 13.3 Ventura or later
message(STATUS "The MacOS version is: >=13.3,<15.0")
set(MINIMUM_MACOS_SDK_VERSION 13.3)
set(VALID_MACOS_SDK_VERSIONS 14.5 14.4 14.2 14.0 13.3)
set(ACCELERATE_NEW_LAPACK_VERSION 3.9.1) set(ACCELERATE_NEW_LAPACK_VERSION 3.9.1)
else () else ()
message(FATAL_ERROR "You need at least Mac OS X 13.3 Ventura for Accelerate with BLAS/LAPACK v3.9.1!") message(FATAL_ERROR "You need at least MacOS 13.3 Ventura for Accelerate with BLAS/LAPACK v3.9.1!")
endif ()
message(STATUS "The BLAS/LAPACK version provided by the Accelerate framework is: ${ACCELERATE_NEW_LAPACK_VERSION}")
endif () endif ()
string(REGEX MATCH [=[SDKs/MacOSX(.*)\.sdk$]=] _REGEX_DUMMY "${CMAKE_OSX_SYSROOT}")
set(DEFAULT_MACOS_SDK_VERSION "${CMAKE_MATCH_1}")
# The text-based .dylib stubs describing the Accelerate framework are provided
# by the MacOS SDK, which has to match the MacOS system. Otherwise, there might
# be newer symbols in the text-based .dylib stubs that are not provided by the
# Accelerate binary, leading to linking errors.
if (NOT DEFINED VALID_MACOS_SDK_VERSIONS)
# MacOS system supports the latest iteration of the new Accelerate
# BLAS/LAPACK. Use the default SDK, if it's recent enough.
if (DEFAULT_MACOS_SDK_VERSION VERSION_LESS MINIMUM_MACOS_SDK_VERSION)
message(STATUS "The MacOS SDK is: ${CMAKE_OSX_SYSROOT}")
message(STATUS "The minimum compatible MacOS SDK version is: ${MINIMUM_MACOS_SDK_VERSION}")
message(FATAL_ERROR "Please install a more recent XCode for a compatible MacOS SDK.")
endif ()
elseif (NOT DEFAULT_MACOS_SDK_VERSION IN_LIST VALID_MACOS_SDK_VERSIONS)
# MacOS system supports one of the past iterations of the new Accelerate
# BLAS/LAPACK. If the latest possible XCode is installed is installed on
# this older system, there might be a mismatch between the SDK and the
# system binary. Find a matching SDK from the Command Line Tools instead.
foreach (_MACOS_SDK_VERSION IN LISTS VALID_MACOS_SDK_VERSIONS)
find_path(VALID_MACOS_SDK NAMES "MacOSX${_MACOS_SDK_VERSION}.sdk" HINTS "/Library/Developer/CommandLineTools/SDKs" NO_CACHE)
if (VALID_MACOS_SDK)
set(VALID_MACOS_SDK "${VALID_MACOS_SDK}/MacOSX${_MACOS_SDK_VERSION}.sdk")
break ()
endif () endif ()
endforeach ()
if (VALID_MACOS_SDK)
set(CMAKE_OSX_SYSROOT "${VALID_MACOS_SDK}" CACHE PATH "" FORCE)
else ()
message(STATUS "The MacOS SDK is: ${CMAKE_OSX_SYSROOT}")
message(STATUS "The compatible MacOS SDK versions are: ${VALID_MACOS_SDK_VERSIONS}")
message(FATAL_ERROR "Couldn't find a compatible MacOS SDK. Please install compatible XCode Command Line Tools.")
endif ()
endif ()
message(STATUS "The MacOS SDK is: ${CMAKE_OSX_SYSROOT}")
set(ENV{CMAKE_FRAMEWORK_PATH} "${CMAKE_OSX_SYSROOT}/System/Library/Frameworks")
set(BLA_VENDOR "Apple") set(BLA_VENDOR "Apple")
find_package(LAPACK MODULE) find_package(LAPACK MODULE)
......
...@@ -25,16 +25,24 @@ SOFTWARE. ...@@ -25,16 +25,24 @@ SOFTWARE.
# Accelerate LAPACKE # # Accelerate LAPACKE #
Since Mac OS X 13.3 Ventura, Apple's Accelerate framework comes with a new Since MacOS 13.3 Ventura, Apple's Accelerate framework comes with a new
[BLAS/LAPACK [BLAS/LAPACK
interface](https://developer.apple.com/documentation/accelerate/blas) compatible interface](https://developer.apple.com/documentation/accelerate/blas) compatible
with [Reference LAPACK with [Reference LAPACK
v3.9.1](https://github.com/Reference-LAPACK/lapack/tree/v3.9.1). It also v3.9.1](https://github.com/Reference-LAPACK/lapack/releases/tag/v3.9.1). It also
provides an ILP64 interface. On Apple Silicon M-processors, it utilises the provides an ILP64 interface. On Apple Silicon M-processors, it utilises the
[proprietary AMX co-processor](https://github.com/corsix/amx), which makes it [proprietary AMX co-processor](https://github.com/corsix/amx), which makes it
especially interesting. Unfortunately, it comes without the LAPACKE C-interface especially interesting. Unfortunately, it comes without the LAPACKE C-interface
library. library.
**Update**: With the release of MacOS 15.0 Sequoia, Apple updated the Accelerate
framework to be compatible with [Reference LAPACK
v3.11.0](https://github.com/Reference-LAPACK/lapack/releases/tag/v3.11.0).
Unfortunately, there is no mention of it in the [MacOS 15.0 Sequoia Release
Notes](), but the note in the [Accelerate BLAS
docs](https://developer.apple.com/documentation/accelerate/blas) has been
updated accordingly.
These new interfaces are hidden behind the preprocessor defines These new interfaces are hidden behind the preprocessor defines
`ACCELERATE_NEW_LAPACK` and `ACCELERATE_LAPACK_ILP64` and they only work, if you `ACCELERATE_NEW_LAPACK` and `ACCELERATE_LAPACK_ILP64` and they only work, if you
include the Accelerate C/C++ headers. include the Accelerate C/C++ headers.
......
...@@ -72,14 +72,14 @@ set(CBLAS OFF CACHE BOOL "") ...@@ -72,14 +72,14 @@ set(CBLAS OFF CACHE BOOL "")
set(LAPACKE ON CACHE BOOL "") set(LAPACKE ON CACHE BOOL "")
# Add the $NEWLAPACK symbols to the linker flags used in try_compile() # Add the $NEWLAPACK symbols to the linker flags used in try_compile()
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-alias_list,${CMAKE_CURRENT_BINARY_DIR}/new-lapack.alias") set(CMAKE_EXE_LINKER_FLAGS "-framework Accelerate -Wl,-alias_list,${CMAKE_CURRENT_BINARY_DIR}/new-lapack.alias")
if (BUILD_INDEX64) if (BUILD_INDEX64)
# Add the $NEWLAPACK$ILP64 symbols to the linker flags used for shared libraries # Add the $NEWLAPACK$ILP64 symbols to the linker flags used for shared libraries
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-alias_list,${CMAKE_CURRENT_BINARY_DIR}/new-lapack-ilp64.alias") set(CMAKE_SHARED_LINKER_FLAGS "-framework Accelerate -Wl,-alias_list,${CMAKE_CURRENT_BINARY_DIR}/new-lapack-ilp64.alias")
else () else ()
# Add the $NEWLAPACK symbols to the linker flags used for shared libraries # Add the $NEWLAPACK symbols to the linker flags used for shared libraries
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-alias_list,${CMAKE_CURRENT_BINARY_DIR}/new-lapack.alias") set(CMAKE_SHARED_LINKER_FLAGS "-framework Accelerate -Wl,-alias_list,${CMAKE_CURRENT_BINARY_DIR}/new-lapack.alias")
endif () endif ()
FetchContent_Declare( FetchContent_Declare(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment