Skip to content

Commit 9d74b29

Browse files
authored
Merge pull request scipy#18012 from andyfaff/blas
BLD: bump OpenBLAS to v0.3.20-571-g3dec11c6 [wheel build]
2 parents 4d5b2f2 + 9b07614 commit 9d74b29

File tree

8 files changed

+76
-47
lines changed

8 files changed

+76
-47
lines changed

.github/workflows/windows.yml

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,45 +46,32 @@ jobs:
4646
gfortran --version
4747
- name: pip-packages
4848
run: |
49-
pip install numpy==1.22.2 cython pybind11 pythran meson ninja pytest pytest-xdist pytest-timeout pooch
49+
pip install numpy==1.22.2 cython pybind11 pythran meson ninja pytest pytest-xdist pytest-timeout pooch rich_click click doit pydevtool
5050
- name: openblas-libs
5151
run: |
5252
# Download and install pre-built OpenBLAS library
5353
# Built with mingw-w64, -ucrt -static.
5454
# https://github.com/matthew-brett/openblas-libs/blob/ucrt-build/build_openblas.ps1
55-
choco install unzip -y
56-
choco install wget -y
57-
wget https://github.com/scipy/scipy-ci-artifacts/raw/main/openblas_32_if.zip
58-
unzip -d c:\ openblas_32_if.zip
59-
echo "PKG_CONFIG_PATH=c:\opt\openblas\if_32\64\lib\pkgconfig;" >> $env:GITHUB_ENV
60-
- name: meson-configure
61-
run: |
62-
meson setup build --prefix=$PWD\build
63-
- name: meson-build
64-
run: |
65-
ninja -j 2 -C build
66-
- name: meson-install
55+
choco install wget unzip -y --no-progress
56+
wget -q https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.20-571-g3dec11c6/download/openblas-v0.3.20-571-g3dec11c6-win_amd64-gcc_10_3_0.zip
57+
unzip -d c:\opt openblas-v0.3.20-571-g3dec11c6-win_amd64-gcc_10_3_0.zip
58+
echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV
59+
- name: build
6760
run: |
61+
echo "SCIPY_USE_PROPACK=1" >> $env:GITHUB_ENV
62+
python dev.py build -j 2 --win-cp-openblas
63+
64+
# following steps are required because the build step does not put
65+
# the *.pyd files in build-install! Furthermore the --win-cp-openblas
66+
# option does not seem to copy libopenblas*.dll, so manually copy it.
6867
cd build
6968
meson install
70-
- name: build-path
71-
run: |
72-
echo "installed_path=$PWD\build\Lib\site-packages" >> $env:GITHUB_ENV
73-
- name: post-install
74-
run: |
75-
$scipy_path = "${env:installed_path}\scipy"
76-
$libs_path = "${scipy_path}\.libs"
77-
mkdir ${libs_path}
78-
$ob_path = (pkg-config --variable libdir openblas) -replace "lib", "bin"
79-
cp $ob_path/*.dll $libs_path
80-
# Write _distributor_init.py to scipy dir to load .libs DLLs.
81-
& python tools\openblas_support.py --write-init $scipy_path
82-
- name: prep-test
83-
run: |
84-
echo "PYTHONPATH=${env:installed_path}" >> $env:GITHUB_ENV
85-
echo "SCIPY_USE_PROPACK=1" >> $env:GITHUB_ENV
69+
cd ..
70+
cp C:\opt\64\bin\*.dll $pwd\build-install\Lib\site-packages\scipy\.libs\
71+
echo "PYTHONPATH=$PWD\build-install\Lib\site-packages" >> $env:GITHUB_ENV
72+
python tools\openblas_support.py --write-init $PWD\build-install\Lib\site-packages\scipy\
8673
- name: test
8774
run: |
88-
mkdir tmp
89-
cd tmp
90-
python -c 'import scipy; scipy.test()'
75+
Get-ChildItem env:
76+
cd $env:PYTHONPATH
77+
python -c "import sys; import scipy; sys.exit(not scipy.test())"

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pr:
2121
# the version of OpenBLAS used is currently 0.3.21
2222
# and should be updated to match scipy-wheels as appropriate
2323
variables:
24-
openblas_version: 0.3.21
24+
openblas_version: 0.3.21.dev
2525
pre_wheels: https://pypi.anaconda.org/scipy-wheels-nightly/simple
2626
CCACHE_DIR: $(Pipeline.Workspace)/ccache
2727
SCIPY_AVAILABLE_MEM: 3G

dev.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,12 @@ def task_meta(cls, **kwargs):
143143
"cmd": "italic gray50",
144144
})
145145

146-
147-
class EMOJI:
148-
cmd = ":computer:"
146+
if sys.platform == 'win32':
147+
class EMOJI:
148+
cmd = ">"
149+
else:
150+
class EMOJI:
151+
cmd = ":computer:"
149152

150153

151154
rich_click.STYLE_ERRORS_SUGGESTION = "yellow italic"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,5 @@ select = "*-win_amd64"
165165
# An alternative is to set CMAKE_PREFIX_PATH="c:/opt/openblas/if_32/32"
166166
# Don't use double backslash for path separators, they don't get passed
167167
# to the build correctly
168+
# environment = { CMAKE_PREFIX_PATH="c:/opt/64" }
168169
environment = { PKG_CONFIG_PATH="c:/opt/64/lib/pkgconfig" }

scipy/linalg/tests/test_decomp.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646

4747
from scipy._lib._testutils import check_free_memory
4848
from scipy.linalg.blas import HAS_ILP64
49-
49+
try:
50+
from scipy.__config__ import CONFIG
51+
except ImportError:
52+
CONFIG = None
5053

5154
def _random_hermitian_matrix(n, posdef=False, dtype=float):
5255
"Generate random sym/hermitian array of the given size n"
@@ -2043,12 +2046,22 @@ def test_2x2(self):
20432046
assert_array_almost_equal(h2, b)
20442047

20452048

2049+
blas_provider = blas_version = None
2050+
if CONFIG is not None:
2051+
blas_provider = CONFIG['Build Dependencies']['blas']['name']
2052+
blas_version = CONFIG['Build Dependencies']['blas']['version']
2053+
2054+
20462055
class TestQZ:
20472056
def setup_method(self):
20482057
seed(12345)
20492058

2050-
@pytest.mark.xfail(sys.platform == 'darwin',
2051-
reason="gges[float32] broken for OpenBLAS on macOS, see gh-16949")
2059+
@pytest.mark.xfail(
2060+
sys.platform == 'darwin' and
2061+
blas_provider == 'openblas' and
2062+
blas_version < "0.3.21.dev",
2063+
reason="gges[float32] broken for OpenBLAS on macOS, see gh-16949"
2064+
)
20522065
def test_qz_single(self):
20532066
n = 5
20542067
A = random([n, n]).astype(float32)

scipy/linalg/tests/test_lapack.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
from scipy.linalg.lapack import _compute_lwork
2424
from scipy.stats import ortho_group, unitary_group
2525

26-
2726
import scipy.sparse as sps
27+
try:
28+
from scipy.__config__ import CONFIG
29+
except ImportError:
30+
CONFIG = None
2831

2932
try:
3033
from scipy.linalg import _clapack as clapack
@@ -37,6 +40,11 @@
3740
COMPLEX_DTYPES = [np.complex64, np.complex128]
3841
DTYPES = REAL_DTYPES + COMPLEX_DTYPES
3942

43+
blas_provider = blas_version = None
44+
if CONFIG is not None:
45+
blas_provider = CONFIG['Build Dependencies']['blas']['name']
46+
blas_version = CONFIG['Build Dependencies']['blas']['version']
47+
4048

4149
def generate_random_dtype_array(shape, dtype):
4250
# generates a random matrix of desired data type of shape
@@ -3052,7 +3060,12 @@ def test_trexc_NAG(t, ifst, ilst, expect):
30523060

30533061
@pytest.mark.parametrize('dtype', DTYPES)
30543062
def test_gges_tgexc(dtype):
3055-
if dtype == np.float32 and sys.platform == 'darwin':
3063+
if (
3064+
dtype == np.float32 and
3065+
sys.platform == 'darwin' and
3066+
blas_provider == 'openblas' and
3067+
blas_version < '0.3.21.dev'
3068+
):
30563069
pytest.xfail("gges[float32] broken for OpenBLAS on macOS, see gh-16949")
30573070

30583071
seed(1234)
@@ -3224,7 +3237,12 @@ def test_trsen_NAG(t, q, select, expect, expect_s, expect_sep):
32243237

32253238
@pytest.mark.parametrize('dtype', DTYPES)
32263239
def test_gges_tgsen(dtype):
3227-
if dtype == np.float32 and sys.platform == 'darwin':
3240+
if (
3241+
dtype == np.float32 and
3242+
sys.platform == 'darwin' and
3243+
blas_provider == 'openblas' and
3244+
blas_version < '0.3.21.dev'
3245+
):
32283246
pytest.xfail("gges[float32] broken for OpenBLAS on macOS, see gh-16949")
32293247

32303248
seed(1234)

scipy/linalg/tests/test_solvers.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,11 @@ def test_solve_discrete_are():
510510
#
511511
min_decimal = (12, 14, 13, 14, 13, 16, 18, 14, 14, 13,
512512
14, 13, 13, 14, 12, 2, 5, 6, 10)
513+
max_tol = [1.5 * 10**-ind for ind in min_decimal]
514+
# relaxed tolerance in gh-18012 after bump to OpenBLAS
515+
max_tol[11] = 2.5e-13
513516

514-
def _test_factory(case, dec):
517+
def _test_factory(case, atol):
515518
"""Checks if X = A'XA-(A'XB)(R+B'XB)^-1(B'XA)+Q) is true"""
516519
a, b, q, r, knownfailure = case
517520
if knownfailure:
@@ -522,10 +525,14 @@ def _test_factory(case, dec):
522525
res -= a.conj().T.dot(x.dot(b)).dot(
523526
solve(r+b.conj().T.dot(x.dot(b)), b.conj().T).dot(x.dot(a))
524527
)
525-
assert_array_almost_equal(res, np.zeros_like(res), decimal=dec)
528+
# changed from
529+
# assert_array_almost_equal(res, np.zeros_like(res), decimal=dec)
530+
# in gh-18012 as it's easier to relax a tolerance and allclose is
531+
# preferred
532+
assert_allclose(res, np.zeros_like(res), atol=atol)
526533

527534
for ind, case in enumerate(cases):
528-
_test_factory(case, min_decimal[ind])
535+
_test_factory(case, max_tol[ind])
529536

530537
# An infeasible example taken from https://arxiv.org/abs/1505.04861v1
531538
A = np.triu(np.ones((3, 3)))

tools/openblas_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from urllib.request import urlopen, Request
1414
from urllib.error import HTTPError
1515

16-
OPENBLAS_V = '0.3.21'
17-
OPENBLAS_LONG = 'v0.3.21'
16+
OPENBLAS_V = '0.3.21.dev'
17+
OPENBLAS_LONG = 'v0.3.20-571-g3dec11c6'
1818
BASE_LOC = 'https://anaconda.org/multibuild-wheels-staging/openblas-libs'
1919
BASEURL = f'{BASE_LOC}/{OPENBLAS_LONG}/download'
2020
SUPPORTED_PLATFORMS = [

0 commit comments

Comments
 (0)