Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ jobs:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}

# disabling QBLAS optimization for windows due to incompatibility with MSVC
# QBLAS is auto-disabled on Windows by meson.build (it uses GCC/POSIX-only
# constructs that MSVC does not support); the wheel falls back to the
# naive matmul kernel. No CFLAGS hack needed.
build_wheels_windows:
name: Build wheels on Windows
runs-on: windows-latest
Expand Down Expand Up @@ -153,9 +155,6 @@ jobs:
CIBW_BUILD_VERBOSITY: "3"
DISTUTILS_USE_SDK: "1"
MSSdk: "1"
CIBW_ENVIRONMENT: >
CFLAGS="/DDISABLE_QUADBLAS $CFLAGS"
CXXFLAGS="/DDISABLE_QUADBLAS $CXXFLAGS"
CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin'
CIBW_TEST_COMMAND_WINDOWS: pip install numpy && pip install --no-deps {wheel} && pip install pytest pytest-run-parallel && pytest -s {project}/tests
CIBW_TEST_EXTRAS: test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ compile_commands.json

# docs
/docs/_build/
build_log.txt
37 changes: 27 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ if is_windows
add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp'])
endif

qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])

# Try to find SLEEF system-wide first, fall back to subproject if not found
# Required SLEEF version (must match sleef.wrap revision)
required_sleef_version = '3.9.0'
# Don't use fallback here - we need to call subproject() explicitly later with disable_fma option
sleef_dep = dependency('sleef', version: '>=' + required_sleef_version, required: false)
Expand All @@ -30,7 +27,7 @@ if sleef_dep.found() and sleef_dep.version().startswith(required_sleef_version)
# SLEEF found system-wide - verify quad-precision support
cpp = meson.get_compiler('cpp')
sleefquad_lib = cpp.find_library('sleefquad', required: false)

if sleefquad_lib.found()
sleefquad_test_code = '''
#include <sleefquad.h>
Expand All @@ -48,7 +45,7 @@ if sleef_dep.found() and sleef_dep.version().startswith(required_sleef_version)
dependencies: [sleef_dep, sleefquad_lib],
name: 'SLEEF quad-precision support'
)

if quad_works
sleefquad_dep = declare_dependency(
dependencies: [sleef_dep, sleefquad_lib]
Expand Down Expand Up @@ -80,6 +77,23 @@ else
message('Proceeding with vendored SLEEF subproject instead')
endif

# QBLAS does not build under MSVC (GCC-only flags, POSIX-only APIs, GCC
# built-ins for CPUID); force-disable it on Windows. Users on other
# platforms can opt out via -Ddisable_quadblas=true to fall back to the
# naive matmul kernel.
disable_quadblas = is_windows or get_option('disable_quadblas')
if disable_quadblas
if is_windows
message('QBLAS disabled (Windows / MSVC) - using naive matmul kernel')
else
message('QBLAS disabled by user option - using naive matmul kernel')
endif
add_project_arguments('-DDISABLE_QUADBLAS', language: ['c', 'cpp'])
qblas_dep = declare_dependency()
else
qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])
endif

incdir_numpy = run_command(py,
['-c', 'import numpy; print(numpy.get_include())'],
check : true
Expand All @@ -101,11 +115,14 @@ npymath_lib = c.find_library('npymath', dirs: npymath_path)

dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep, npymath_lib]

# Add OpenMP dependency (optional, for threading)
openmp_dep = dependency('openmp', required: false, static: false)
if openmp_dep.found()
dependencies += openmp_dep
endif
# OpenMP is not used directly by any source in this package (#pragma omp
# is absent); it only matters because qblas's static lib has OpenMP
# objects baked in. qblas_dep already propagates the OpenMP requirement
# transitively, so adding a second dependency('openmp') here would put
# OpenMP into the compile-args closure twice. On Apple's clang++ that
# duplication leaves an orphan '-Xpreprocessor' in $ARGS which then
# pairs with '-MD' from the dep-gen flags ('-Xpreprocessor -MD'), and
# the preprocessor rejects -MD as unknown - failing all C++ compiles.

# compiler flags for QBLAS compatibility
if not is_windows
Expand Down
8 changes: 7 additions & 1 deletion meson.options
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
option('disable_fma', type: 'boolean', value: false,
description: 'Disable FMA (Fused Multiply-Add) code paths' +
'Set to true when building for older CPUs like Sandy Bridge that lack FMA support.')
'Set to true when building for older CPUs like Sandy Bridge that lack FMA support.')

option('disable_quadblas', type: 'boolean', value: false,
description: 'Skip the QBLAS subproject and fall back to naive ' +
'matmul kernels. Auto-enabled on Windows because ' +
'QBLAS uses GCC/POSIX-only constructs that do not ' +
'build under MSVC.')
Loading
Loading