Skip to content

Commit a6885f7

Browse files
authored
Merge pull request #95 from SwayamInSync/qblas-rewrite-integration
Switch QBLAS dependency to 1.5.0
2 parents effb751 + 0d4e59f commit a6885f7

8 files changed

Lines changed: 109 additions & 168 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.
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

.github/workflows/test_old_cpu.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
name: Test on Older CPUs (x86_64-v2)
2-
3-
# This workflow tests numpy-quaddtype on older x86 CPUs using Intel SDE.
4-
# It ensures compatibility with x86_64-v2 baseline CPUs (e.g., Sandy Bridge)
5-
# that don't have AVX2/FMA support.
1+
name: Test Older CPUs + Build Options
62

73
on:
84
push:
@@ -16,14 +12,21 @@ permissions:
1612

1713
jobs:
1814
test_old_cpu:
19-
name: Test on ${{ matrix.cpu[1] }}
15+
name: Test ${{ matrix.config.name }}
2016
runs-on: ubuntu-24.04
2117
strategy:
2218
fail-fast: false
2319
matrix:
24-
cpu:
25-
- ['snb', 'Sandy Bridge (x86_64-v2)']
26-
- ['hsw', 'Haswell (x86_64-v3)']
20+
config:
21+
- name: "Sandy Bridge (x86_64-v2)"
22+
sde_cpu: "snb"
23+
meson_args: "-Csetup-args=-Ddisable_fma=true"
24+
- name: "Haswell (x86_64-v3)"
25+
sde_cpu: "hsw"
26+
meson_args: ""
27+
- name: "Haswell, no QBLAS"
28+
sde_cpu: "hsw"
29+
meson_args: "-Csetup-args=-Ddisable_quadblas=true"
2730
steps:
2831
- uses: actions/checkout@v6
2932
with:
@@ -54,27 +57,21 @@ jobs:
5457
env:
5558
LDFLAGS: "-fopenmp"
5659
run: |
57-
# For Sandy Bridge (x86-64-v2), we need to disable FMA code paths
58-
# since FMA instructions are not available on that microarchitecture
59-
if [ "${{ matrix.cpu[0] }}" = "snb" ]; then
60-
pip install .[test] --no-build-isolation -v -Csetup-args=-Ddisable_fma=true
61-
else
62-
pip install .[test] --no-build-isolation -v
63-
fi
60+
pip install .[test] --no-build-isolation -v ${{ matrix.config.meson_args }}
6461
65-
- name: Test import on ${{ matrix.cpu[1] }}
62+
- name: Test import on ${{ matrix.config.name }}
6663
run: |
67-
echo "Testing basic import on ${{ matrix.cpu[1] }}..."
68-
sde -${{ matrix.cpu[0] }} -- python -c "
64+
echo "Testing basic import on ${{ matrix.config.name }}..."
65+
sde -${{ matrix.config.sde_cpu }} -- python -c "
6966
import numpy as np
7067
print('NumPy version:', np.__version__)
7168
from numpy_quaddtype import QuadPrecDType
7269
print('QuadPrecDType imported successfully!')
7370
arr = np.zeros(3, dtype=QuadPrecDType())
7471
print('Created quad array:', arr)
75-
print('SUCCESS: Works on ${{ matrix.cpu[1] }}!')
72+
print('SUCCESS: Works on ${{ matrix.config.name }}!')
7673
"
7774
78-
- name: Run tests on ${{ matrix.cpu[1] }}
75+
- name: Run tests on ${{ matrix.config.name }}
7976
run: |
80-
sde -${{ matrix.cpu[0] }} -- python -m pytest tests/ -v --tb=short -v -s
77+
sde -${{ matrix.config.sde_cpu }} -- python -m pytest tests/ -v --tb=short -v -s

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,4 @@ compile_commands.json
146146

147147
# docs
148148
/docs/_build/
149+
build_log.txt

meson.build

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ 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'])
1918

20-
# Try to find SLEEF system-wide first, fall back to subproject if not found
21-
# Required SLEEF version (must match sleef.wrap revision)
2219
required_sleef_version = '3.9.0'
2320
# Don't use fallback here - we need to call subproject() explicitly later with disable_fma option
2421
sleef_dep = dependency('sleef', version: '>=' + required_sleef_version, required: false)
@@ -30,7 +27,7 @@ if sleef_dep.found() and sleef_dep.version().startswith(required_sleef_version)
3027
# SLEEF found system-wide - verify quad-precision support
3128
cpp = meson.get_compiler('cpp')
3229
sleefquad_lib = cpp.find_library('sleefquad', required: false)
33-
30+
3431
if sleefquad_lib.found()
3532
sleefquad_test_code = '''
3633
#include <sleefquad.h>
@@ -48,7 +45,7 @@ if sleef_dep.found() and sleef_dep.version().startswith(required_sleef_version)
4845
dependencies: [sleef_dep, sleefquad_lib],
4946
name: 'SLEEF quad-precision support'
5047
)
51-
48+
5249
if quad_works
5350
sleefquad_dep = declare_dependency(
5451
dependencies: [sleef_dep, sleefquad_lib]
@@ -80,6 +77,23 @@ else
8077
message('Proceeding with vendored SLEEF subproject instead')
8178
endif
8279

80+
# QBLAS does not build under MSVC (GCC-only flags, POSIX-only APIs, GCC
81+
# built-ins for CPUID); force-disable it on Windows. Users on other
82+
# platforms can opt out via -Ddisable_quadblas=true to fall back to the
83+
# naive matmul kernel.
84+
disable_quadblas = is_windows or get_option('disable_quadblas')
85+
if disable_quadblas
86+
if is_windows
87+
message('QBLAS disabled (Windows / MSVC) - using naive matmul kernel')
88+
else
89+
message('QBLAS disabled by user option - using naive matmul kernel')
90+
endif
91+
add_project_arguments('-DDISABLE_QUADBLAS', language: ['c', 'cpp'])
92+
qblas_dep = declare_dependency()
93+
else
94+
qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])
95+
endif
96+
8397
incdir_numpy = run_command(py,
8498
['-c', 'import numpy; print(numpy.get_include())'],
8599
check : true
@@ -101,12 +115,6 @@ npymath_lib = c.find_library('npymath', dirs: npymath_path)
101115

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

104-
# Add OpenMP dependency (optional, for threading)
105-
openmp_dep = dependency('openmp', required: false, static: false)
106-
if openmp_dep.found()
107-
dependencies += openmp_dep
108-
endif
109-
110118
# compiler flags for QBLAS compatibility
111119
if not is_windows
112120
# QBLAS requires extended numeric literals for Q suffix support

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)