Skip to content

Commit ca3ab0c

Browse files
committed
gate QBLAS subproject on disable_quadblas option
The new compiled QBLAS uses GCC-only flags (-march, -mavx2), POSIX-only APIs (clock_gettime, sysconf, _SC_LEVEL2_CACHE_SIZE), and GCC built-ins for CPUID detection - none of which build under MSVC. The legacy header-only QBLAS happened to compile on Windows because the wrap was five lines and produced no objects. Add a disable_quadblas meson option (default false; auto-enabled on Windows) that: - skips dependency('qblas', fallback: ...) entirely - declares an empty qblas_dep so the rest of the build proceeds - adds -DDISABLE_QUADBLAS to project args so quadblas_interface.cpp and umath/matmul.cpp take the naive-kernel branches that already exist behind that guard This removes the CFLAGS=/DDISABLE_QUADBLAS hack from the Windows CI since meson now sets the preprocessor flag itself (and translates -D to /D for MSVC). Verified on Linux: -Ddisable_quadblas=true builds without pulling the QBLAS subproject; default still builds it.
1 parent af809f3 commit ca3ab0c

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

.github/workflows/build_wheels.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ jobs:
114114
path: ./wheelhouse/*.whl
115115
name: wheels-${{ matrix.os }}
116116

117-
# disabling QBLAS optimization for windows due to incompatibility with MSVC
117+
# QBLAS is auto-disabled on Windows by meson.build (it uses GCC/POSIX-only
118+
# constructs that MSVC does not support); the wheel falls back to the
119+
# naive matmul kernel. No CFLAGS hack needed.
118120
build_wheels_windows:
119121
name: Build wheels on Windows
120122
runs-on: windows-latest
@@ -153,9 +155,6 @@ jobs:
153155
CIBW_BUILD_VERBOSITY: "3"
154156
DISTUTILS_USE_SDK: "1"
155157
MSSdk: "1"
156-
CIBW_ENVIRONMENT: >
157-
CFLAGS="/DDISABLE_QUADBLAS $CFLAGS"
158-
CXXFLAGS="/DDISABLE_QUADBLAS $CXXFLAGS"
159158
CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin'
160159
CIBW_TEST_COMMAND_WINDOWS: pip install numpy && pip install --no-deps {wheel} && pip install pytest pytest-run-parallel && pytest -s {project}/tests
161160
CIBW_TEST_EXTRAS: test

meson.build

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,22 @@ if is_windows
1515
add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp'])
1616
endif
1717

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

2035
# Try to find SLEEF system-wide first, fall back to subproject if not found
2136
# Required SLEEF version (must match sleef.wrap revision)

meson.options

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
option('disable_fma', type: 'boolean', value: false,
22
description: 'Disable FMA (Fused Multiply-Add) code paths' +
3-
'Set to true when building for older CPUs like Sandy Bridge that lack FMA support.')
3+
'Set to true when building for older CPUs like Sandy Bridge that lack FMA support.')
4+
5+
option('disable_quadblas', type: 'boolean', value: false,
6+
description: 'Skip the QBLAS subproject and fall back to naive ' +
7+
'matmul kernels. Auto-enabled on Windows because ' +
8+
'QBLAS uses GCC/POSIX-only constructs that do not ' +
9+
'build under MSVC.')

0 commit comments

Comments
 (0)