Skip to content

Commit

Permalink
CI: use accelerate macos-14 wheels [wheel build]
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed Jul 8, 2024
1 parent 0dadf77 commit 8d9bf7c
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 75 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ jobs:
# so easier to separate out here.
- [ubuntu-22.04, manylinux_x86_64, ""]
- [macos-13, macosx_x86_64, openblas]
- [macos-14, macosx_arm64, openblas]
- [macos-13, macosx_x86_64, accelerate]
- [macos-14, macosx_arm64, accelerate] # always use accelerate
- [windows-2019, win_amd64, ""]

# python: ["cp310", "cp311", "cp312", "cp13"]
Expand Down Expand Up @@ -165,13 +166,23 @@ jobs:
echo "FC=gfortran-13" >> "$GITHUB_ENV"
echo "F77=gfortran-13" >> "$GITHUB_ENV"
echo "F90=gfortran-13" >> "$GITHUB_ENV"
# macosx_x86_64 with OpenBLAS
# if INSTALL_OPENBLAS isn't specified then scipy-openblas is automatically installed
CIBW="RUNNER_OS=macOS"
PKG_CONFIG_PATH="$PWD/.openblas"
DYLD="$DYLD_LIBRARY_PATH:/$PWD/.openblas/lib"
echo "CIBW_ENVIRONMENT_MACOS=$CIBW PKG_CONFIG_PATH=$PKG_CONFIG_PATH DYLD_LIBRARY_PATH=$DYLD" >> "$GITHUB_ENV"
if [[ ${{ matrix.buildplat[2] }} == 'accelerate' ]]; then
# macosx_arm64 and macosx_x86_64 with accelerate
# only target Sonoma onwards
CIBW="MACOSX_DEPLOYMENT_TARGET=14.0 INSTALL_OPENBLAS=false RUNNER_OS=macOS"
echo "CIBW_ENVIRONMENT_MACOS=$CIBW" >> "$GITHUB_ENV"
# the macos-13 image that's used for building the x86_64 wheel can't test
# a wheel with deployment target >= 14 without further work
echo "CIBW_TEST_SKIP=*-macosx_x86_64" >> "$GITHUB_ENV"
else
# macosx_x86_64 with OpenBLAS
# if INSTALL_OPENBLAS isn't specified then scipy-openblas is automatically installed
CIBW="RUNNER_OS=macOS"
PKG_CONFIG_PATH="$PWD/.openblas"
DYLD="$DYLD_LIBRARY_PATH:/$PWD/.openblas/lib"
echo "CIBW_ENVIRONMENT_MACOS=$CIBW PKG_CONFIG_PATH=$PKG_CONFIG_PATH DYLD_LIBRARY_PATH=$DYLD" >> "$GITHUB_ENV"
fi
- name: Build wheels
uses: pypa/[email protected]
Expand Down
2 changes: 0 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ project(
'buildtype=debugoptimized',
'c_std=c99',
'fortran_std=legacy',
'blas=openblas',
'lapack=openblas',
'pkgconfig.relocatable=true',
],
)
Expand Down
16 changes: 10 additions & 6 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
option('blas', type: 'string', value: 'openblas',
description: 'option for BLAS library switching')
option('lapack', type: 'string', value: 'openblas',
description: 'option for LAPACK library switching')
option('blas-symbol-suffix', type: 'string', value: 'auto',
description: 'BLAS and LAPACK symbol suffix to use, if any')
option('blas', type: 'string', value: 'auto',
description: 'Option for BLAS library selection. By default, try to find any in the order given by `blas-order`')
option('lapack', type: 'string', value: 'auto',
description: 'Option for LAPACK library selection. By default, try to find any in the order given by `lapack-order`')
option('blas-order', type: 'array', value: ['auto'],
description: 'Order of BLAS libraries to search for. E.g.: mkl,openblas,blis,blas')
option('lapack-order', type: 'array', value: ['auto'],
description: 'Order of LAPACK libraries to search for. E.g.: mkl,openblas,lapack')
option('use-ilp64', type: 'boolean', value: false,
description: 'Use ILP64 (64-bit integer) BLAS and LAPACK interfaces')
option('blas-symbol-suffix', type: 'string', value: 'auto',
description: 'BLAS and LAPACK symbol suffix to use, if any')
option('use-g77-abi', type: 'boolean', value: false,
description: 'If set to true, forces using g77 compatibility wrappers ' +
'for LAPACK functions. The default is to use gfortran ' +
Expand Down
12 changes: 5 additions & 7 deletions skmisc/loess/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ loess_cython_gen = generator(
###

#### Fortran Loess into a static library
floess_sources = [
'src/loessf.f',
'src/linpack_lite.f'
]

floess_lib = static_library(
'floess',
floess_sources,
fortran_args: [fortran_ignore_warnings],
sources: [
'src/loessf.f',
'src/linpack_lite.f'
],
dependencies: [blas_dep, lapack_dep],
fortran_args: [fortran_ignore_warnings],
)
###

Expand Down
148 changes: 96 additions & 52 deletions skmisc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -120,82 +120,126 @@ if use_ilp64
else
blas_interface = ['interface: lp64']
endif
blas_order = ['scipy-openblas', 'openblas']

macOS13_3_or_later = false
if host_machine.system() == 'darwin'
r = run_command('xcrun', '-sdk', 'macosx', '--show-sdk-version', check: true)
sdkVersion = r.stdout().strip()

macOS13_3_or_later = sdkVersion.version_compare('>=13.3')
blas_order = get_option('blas-order')
if blas_order == ['auto']
blas_order = []
if host_machine.system() == 'darwin'
blas_order += 'accelerate'
endif
if host_machine.cpu_family() == 'x86_64'
blas_order += 'mkl'
endif
blas_order += ['openblas', 'flexiblas', 'blis', 'blas']
endif
lapack_order = get_option('lapack-order')
if lapack_order == ['auto']
lapack_order = []
if host_machine.system() == 'darwin'
lapack_order += 'accelerate'
endif
if host_machine.cpu_family() == 'x86_64'
lapack_order += 'mkl'
endif
lapack_order += ['openblas', 'flexiblas', 'lapack']
endif

_args_blas = []
_args_lapack = []

# MKL-specific options
mkl_version_req = '>=2023.0' # see gh-24824

# Note that we can only use a BLAS which provides a CBLAS interface. So disable
# BLAS completely if CBLAS is not found.

# First try scipy-openblas, and if found don't look for cblas or lapack, we
# know what's inside the scipy-openblas wheels already.
if blas_name == 'openblas' or blas_name == 'auto'
blas = dependency('scipy-openblas', method: 'pkg-config', modules: ['cblas'] + blas_interface, required: false)
blas = dependency('scipy-openblas', method: 'pkg-config', required: false)
if blas.found()
blas_name = 'scipy-openblas'
endif
endif

# pkg-config uses a lower-case name while CMake uses a capitalized name, so try
# that too to make the fallback detection with CMake work
if blas_name == 'openblas'
blas = dependency(blas_name, modules: ['cblas'] + blas_interface, required: false)
endif

_args_blas += ['-DOPENBLAS_ILP64_NAMING_SCHEME']
if use_ilp64
_args_blas += ['-DHAVE_BLAS_ILP64']
if 'openblas' in blas.name()
_args_blas += ['-DOPENBLAS_ILP64_NAMING_SCHEME']
endif
endif

if blas_symbol_suffix == 'auto'
if blas_name == 'scipy-openblas' and use_ilp64
blas_symbol_suffix = '64_'
if blas_name == 'auto'
foreach _name : blas_order
if _name == 'mkl'
blas = dependency('mkl',
modules: ['cblas'] + blas_interface + mkl_opts,
required: false, # may be required, but we need to emit a custom error message
version: mkl_version_req,
)
else
if _name == 'flexiblas' and use_ilp64
_name = 'flexiblas64'
endif
blas = dependency(_name, modules: ['cblas'] + blas_interface, required: false)
endif
if blas.found()
break
endif
endforeach
else
if blas_name == 'mkl'
blas = dependency('mkl',
modules: ['cblas'] + blas_interface + mkl_opts,
required: false,
version: mkl_version_req,
)
else
blas_symbol_suffix = blas.get_variable('symbol_suffix', default_value: '')
blas = dependency(blas_name, modules: ['cblas'] + blas_interface, required: false)
endif
message(f'BLAS symbol suffix: @blas_symbol_suffix@')
endif
if blas_symbol_suffix != ''
_args_blas += ['-DBLAS_SYMBOL_SUFFIX=' + blas_symbol_suffix]
endif

blas_dep = declare_dependency(
dependencies: [blas],
compile_args: _args_blas
)
if blas_name == 'blas'
# Netlib BLAS has a separate `libcblas.so` which we use directly in the g77
# ABI wrappers, so detect it and error out if we cannot find it.
# In the future, this should be done automatically for:
# `dependency('blas', modules: cblas)`
# see https://github.com/mesonbuild/meson/pull/10921.
cblas = dependency('cblas')
have_blas = blas.found()
if have_blas
_args_blas = ['-DHAVE_CBLAS'] # note: used for C and C++ via `blas_dep` below
if use_ilp64
_args_blas += ['-DHAVE_BLAS_ILP64']
if 'openblas' in blas.name()
_args_blas += ['-DOPENBLAS_ILP64_NAMING_SCHEME']
endif
endif
if blas_symbol_suffix == 'auto'
if blas_name == 'scipy-openblas' and use_ilp64
blas_symbol_suffix = '64_'
else
blas_symbol_suffix = blas.get_variable('symbol_suffix', default_value: '')
endif
message(f'BLAS symbol suffix: @blas_symbol_suffix@')
endif
if blas_symbol_suffix != ''
_args_blas += ['-DBLAS_SYMBOL_SUFFIX=' + blas_symbol_suffix]
endif
blas_dep = declare_dependency(
dependencies: [blas],
compile_args: _args_blas,
)
else
cblas = []
error('No BLAS library detected! Install one')
endif

if blas_name == 'scipy-openblas'
if 'mkl' in blas.name() or blas.name() == 'accelerate' or blas_name == 'scipy-openblas'
# For these libraries we know that they contain LAPACK, and it's desirable to
# use that - no need to run the full detection twice.
lapack = blas
else
lapack = dependency(lapack_name, modules: ['lapack'] + blas_interface, required: false)
if lapack_name == 'auto'
foreach _name : lapack_order
lapack = dependency(_name, modules: ['lapack'] + blas_interface, required: false)
if lapack.found()
break
endif
endforeach
else
lapack = dependency(lapack_name, modules: ['lapack'] + blas_interface, required: false)
endif
endif

lapack_dep = declare_dependency(
dependencies: [lapack, blas_dep],
compile_args: _args_lapack
)

have_lapack = lapack.found()
if have_lapack
lapack_dep = declare_dependency(dependencies: [lapack, blas_dep])
else
error('No LAPACK library detected! Install one')
endif
###

#### Dependencies Information
Expand Down

0 comments on commit 8d9bf7c

Please sign in to comment.