Skip to content

Commit e14c254

Browse files
committed
resolve SLEEF before QBLAS so disable_fma actually applies
Meson caches the first subproject() call by name. When the QBLAS dependency was resolved first, qblas's internal subproject('sleef') ran with no options, configuring SLEEF with FMA enabled. Our later subproject('sleef', default_options: ['disable_fma=true']) was then silently a no-op - meson returned the already-configured instance. Net effect on the old-CPU CI: the SLEEF in the wheel still had the PURECFMA scalar code path enabled, and Intel SDE trapped on the first vfnmadd132sd from Sleef_log10q1_u10purecfma when emulating Sandy Bridge. Move the whole SLEEF resolution block above the qblas dependency line. SLEEF gets configured with the right options on its first (and only) load; QBLAS's later subproject('sleef') call returns the same instance, so there's now exactly one SLEEF in the build with the options we wanted.
1 parent ca3ab0c commit e14c254

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

meson.build

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,11 @@ if is_windows
1515
add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp'])
1616
endif
1717

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
34-
35-
# Try to find SLEEF system-wide first, fall back to subproject if not found
36-
# Required SLEEF version (must match sleef.wrap revision)
18+
# Resolve SLEEF BEFORE the QBLAS subproject. QBLAS calls subproject('sleef')
19+
# without options when it's loaded as a subproject, and meson caches the
20+
# first subproject() call - so if QBLAS were loaded first, our disable_fma
21+
# option would be silently dropped (the SLEEF instance with FMA enabled
22+
# would be the one shipped, breaking Sandy Bridge SDE tests).
3723
required_sleef_version = '3.9.0'
3824
# Don't use fallback here - we need to call subproject() explicitly later with disable_fma option
3925
sleef_dep = dependency('sleef', version: '>=' + required_sleef_version, required: false)
@@ -45,7 +31,7 @@ if sleef_dep.found() and sleef_dep.version().startswith(required_sleef_version)
4531
# SLEEF found system-wide - verify quad-precision support
4632
cpp = meson.get_compiler('cpp')
4733
sleefquad_lib = cpp.find_library('sleefquad', required: false)
48-
34+
4935
if sleefquad_lib.found()
5036
sleefquad_test_code = '''
5137
#include <sleefquad.h>
@@ -63,7 +49,7 @@ if sleef_dep.found() and sleef_dep.version().startswith(required_sleef_version)
6349
dependencies: [sleef_dep, sleefquad_lib],
6450
name: 'SLEEF quad-precision support'
6551
)
66-
52+
6753
if quad_works
6854
sleefquad_dep = declare_dependency(
6955
dependencies: [sleef_dep, sleefquad_lib]
@@ -95,6 +81,23 @@ else
9581
message('Proceeding with vendored SLEEF subproject instead')
9682
endif
9783

84+
# QBLAS does not build under MSVC (GCC-only flags, POSIX-only APIs, GCC
85+
# built-ins for CPUID); force-disable it on Windows. Users on other
86+
# platforms can opt out via -Ddisable_quadblas=true to fall back to the
87+
# naive matmul kernel.
88+
disable_quadblas = is_windows or get_option('disable_quadblas')
89+
if disable_quadblas
90+
if is_windows
91+
message('QBLAS disabled (Windows / MSVC) - using naive matmul kernel')
92+
else
93+
message('QBLAS disabled by user option - using naive matmul kernel')
94+
endif
95+
add_project_arguments('-DDISABLE_QUADBLAS', language: ['c', 'cpp'])
96+
qblas_dep = declare_dependency()
97+
else
98+
qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])
99+
endif
100+
98101
incdir_numpy = run_command(py,
99102
['-c', 'import numpy; print(numpy.get_include())'],
100103
check : true

0 commit comments

Comments
 (0)