Skip to content
Merged
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.
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
41 changes: 19 additions & 22 deletions .github/workflows/test_old_cpu.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
name: Test on Older CPUs (x86_64-v2)

# This workflow tests numpy-quaddtype on older x86 CPUs using Intel SDE.
# It ensures compatibility with x86_64-v2 baseline CPUs (e.g., Sandy Bridge)
# that don't have AVX2/FMA support.
name: Test Older CPUs + Build Options

on:
push:
Expand All @@ -13,14 +9,21 @@ on:

jobs:
test_old_cpu:
name: Test on ${{ matrix.cpu[1] }}
name: Test ${{ matrix.config.name }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
cpu:
- ['snb', 'Sandy Bridge (x86_64-v2)']
- ['hsw', 'Haswell (x86_64-v3)']
config:
- name: "Sandy Bridge (x86_64-v2)"
sde_cpu: "snb"
meson_args: "-Csetup-args=-Ddisable_fma=true"
- name: "Haswell (x86_64-v3)"
sde_cpu: "hsw"
meson_args: ""
- name: "Haswell, no QBLAS"
sde_cpu: "hsw"
meson_args: "-Csetup-args=-Ddisable_quadblas=true"
steps:
- uses: actions/checkout@v6
with:
Expand Down Expand Up @@ -51,27 +54,21 @@ jobs:
env:
LDFLAGS: "-fopenmp"
run: |
# For Sandy Bridge (x86-64-v2), we need to disable FMA code paths
# since FMA instructions are not available on that microarchitecture
if [ "${{ matrix.cpu[0] }}" = "snb" ]; then
pip install .[test] --no-build-isolation -v -Csetup-args=-Ddisable_fma=true
else
pip install .[test] --no-build-isolation -v
fi
pip install .[test] --no-build-isolation -v ${{ matrix.config.meson_args }}

- name: Test import on ${{ matrix.cpu[1] }}
- name: Test import on ${{ matrix.config.name }}
run: |
echo "Testing basic import on ${{ matrix.cpu[1] }}..."
sde -${{ matrix.cpu[0] }} -- python -c "
echo "Testing basic import on ${{ matrix.config.name }}..."
sde -${{ matrix.config.sde_cpu }} -- python -c "
import numpy as np
print('NumPy version:', np.__version__)
from numpy_quaddtype import QuadPrecDType
print('QuadPrecDType imported successfully!')
arr = np.zeros(3, dtype=QuadPrecDType())
print('Created quad array:', arr)
print('SUCCESS: Works on ${{ matrix.cpu[1] }}!')
print('SUCCESS: Works on ${{ matrix.config.name }}!')
"

- name: Run tests on ${{ matrix.cpu[1] }}
- name: Run tests on ${{ matrix.config.name }}
run: |
sde -${{ matrix.cpu[0] }} -- python -m pytest tests/ -v --tb=short -v -s
sde -${{ matrix.config.sde_cpu }} -- python -m pytest tests/ -v --tb=short -v -s
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
30 changes: 19 additions & 11 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,12 +115,6 @@ 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

# compiler flags for QBLAS compatibility
if not is_windows
# QBLAS requires extended numeric literals for Q suffix support
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