Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scipy: Use NPY_BLAS_LIBS and NPY_LAPACK_LIBS environment variables #3048

Merged
merged 2 commits into from Aug 31, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/CLAPACK/meta.yaml
Expand Up @@ -35,5 +35,6 @@ build:
emmake make -j ${PYODIDE_JOBS:-3} blaslib lapacklib
mkdir -p dist
emcc blas_WA.a lapack_WA.a F2CLIBS/libf2c.a ${SIDE_MODULE_LDFLAGS} -o dist/clapack_all.so
mkdir -p ${WASM_LIBRARY_DIR}/CLAPACK
mkdir -p ${WASM_LIBRARY_DIR}/CLAPACK/LIB
cp -r INCLUDE ${WASM_LIBRARY_DIR}/CLAPACK/
cp dist/clapack_all.so ${WASM_LIBRARY_DIR}/CLAPACK/LIB
24 changes: 13 additions & 11 deletions packages/scipy/meta.yaml
Expand Up @@ -21,17 +21,15 @@ source:
- patches/0002-loadDynamicLibrary-flapack.patch
- patches/0003-Add-lapack_extras-to-linalg-setup.py.patch
- patches/0004-int-to-string.patch
- patches/0005-disable-blas-detection.patch
- patches/0006-fix-fotran-files-minpack.patch
- patches/0007-gemm_-no-const.patch
- patches/0008-make-int-return-values.patch
- patches/0009-Rename-_page_trend_test.py-to-prevent-test-unvendori.patch
- patches/0010-sasum-returns-double-not-float.patch
- patches/0011-skip-fortran-fails-to-link.patch
- patches/0012-Disable-lapack-detection.patch
- patches/0013-Add-extra-END-to-prini.f.patch
- patches/0014-BUG-Fix-signature-of-D_IIR_forback-1-2.patch
- patches/0015-Change-qh_eachvoronoi_all-FILE-type.patch
- patches/0005-fix-fotran-files-minpack.patch
- patches/0006-gemm_-no-const.patch
- patches/0007-make-int-return-values.patch
- patches/0008-Rename-_page_trend_test.py-to-prevent-test-unvendori.patch
- patches/0009-sasum-returns-double-not-float.patch
- patches/0010-skip-fortran-fails-to-link.patch
- patches/0011-Add-extra-END-to-prini.f.patch
- patches/0012-BUG-Fix-signature-of-D_IIR_forback-1-2.patch
- patches/0013-Change-qh_eachvoronoi_all-FILE-type.patch

build:
cflags: |
Expand All @@ -48,6 +46,10 @@ build:
# Scipy has a bunch of custom logic implemented in
# pyodide-build/pyodide_build/_f2c_fixes.py.
script: |
set -x
export NPY_BLAS_LIBS="-I$WASM_LIBRARY_DIR/CLAPACK/INCLUDE $WASM_LIBRARY_DIR/CLAPACK/LIB/clapack_all.so"
export NPY_LAPACK_LIBS="-I$WASM_LIBRARY_DIR/CLAPACK/INCLUDE"

pip install -t $HOSTSITEPACKAGES pythran
# We get linker errors because the following 36 functions are missing
# Copying them from a more recent LAPACK seems to work fine.
Expand Down
@@ -1,7 +1,7 @@
From 90a2cac7e8812f0a3e64c6bbc45fb1ece8d5f4d1 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Fri, 18 Mar 2022 16:25:39 -0700
Subject: [PATCH 01/15] Fix dstevr in special/lapack_defs.h
Subject: [PATCH 01/13] Fix dstevr in special/lapack_defs.h

---
scipy/special/lapack_defs.h | 5 ++---
Expand Down
@@ -1,7 +1,7 @@
From 9e6c2ad31267a5ed0c30645e70a0b290b3973dd1 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 2 Apr 2022 14:20:25 -0700
Subject: [PATCH 02/15] loadDynamicLibrary flapack
Subject: [PATCH 02/13] loadDynamicLibrary flapack

We are using CLAPACK for our LAPACK, but CLAPACK only supports
LAPACK v3.2 since starting in v3.3 LAPACK started adding fortran
Expand Down
@@ -1,7 +1,7 @@
From f6e479ea524c286f0a96d5df60d1f8edb595f643 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Fri, 31 Dec 2021 22:27:07 -0800
Subject: [PATCH 03/15] Add lapack_extras to linalg/setup.py
Subject: [PATCH 03/13] Add lapack_extras to linalg/setup.py

---
scipy/linalg/setup.py | 2 +-
Expand Down
2 changes: 1 addition & 1 deletion packages/scipy/patches/0004-int-to-string.patch
@@ -1,7 +1,7 @@
From 3c0ad123668366e82b64f459941eb36943745c43 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 25 Dec 2021 18:04:18 -0800
Subject: [PATCH 04/15] int to string
Subject: [PATCH 04/13] int to string

f2c does not handle implicit casts of function arguments correctly. The msg
argument of `xerrwv` is defined to be an `int *`, and then implicitly cast
Expand Down
29 changes: 0 additions & 29 deletions packages/scipy/patches/0005-disable-blas-detection.patch

This file was deleted.

@@ -1,7 +1,7 @@
From 84a590dd8d7563306c09f1f3ba5299e68c9bd359 Mon Sep 17 00:00:00 2001
From e6c3af032ba6bdc61ab002bdbf61ec8eb6fce059 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Wed, 6 Apr 2022 21:21:53 -0700
Subject: [PATCH 06/15] fix fotran files minpack
Subject: [PATCH 05/13] fix fotran files minpack

---
scipy/optimize/minpack/chkder.f | 3 +--
Expand Down
@@ -1,7 +1,7 @@
From e3140b25165537ddc731f1d72e46ec9059faa6d6 Mon Sep 17 00:00:00 2001
From 90aa49e8b1372cf36966c231022b75e7a8a08072 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 18 Dec 2021 11:41:15 -0800
Subject: [PATCH 07/15] gemm_ no const
Subject: [PATCH 06/13] gemm_ no const

cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but
other places don't have the cosnt causing compile errors.
Expand Down
@@ -1,7 +1,7 @@
From 3187f7c7b940c7d3a74bf8a30db74a1e0214bace Mon Sep 17 00:00:00 2001
From b0acd7ece717660f9a28f60383313c52f2aa219f Mon Sep 17 00:00:00 2001
From: Joe Marshall <joe.marshall@nottingham.ac.uk>
Date: Wed, 6 Apr 2022 21:25:13 -0700
Subject: [PATCH 08/15] make int return values
Subject: [PATCH 07/13] make int return values

The return values of f2c functions are insignificant in most cases, so often it
is treated as returning void, when it really should return int (values are
Expand Down
@@ -1,7 +1,7 @@
From 3c3ada887e548b868ecb796741dd1a769a245b9a Mon Sep 17 00:00:00 2001
From 154a9c45846e2a4e57f547d8e5458d1d4382053c Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sun, 26 Dec 2021 07:34:40 -0800
Subject: [PATCH 09/15] Rename _page_trend_test.py to prevent test unvendoring
Subject: [PATCH 08/13] Rename _page_trend_test.py to prevent test unvendoring

unvendor_tests will unvendor any file that ends in _test.py.
Prevent that by changing the name of this file.
Expand Down
@@ -1,7 +1,7 @@
From 8901c3e687a46ee2e13b9357b5122c679b1fcf06 Mon Sep 17 00:00:00 2001
From f96536f51efc2cb7ebbfe2228a7339af0211428c Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 18 Dec 2021 12:31:51 -0800
Subject: [PATCH 10/15] sasum returns double not float
Subject: [PATCH 09/13] sasum returns double not float

---
scipy/sparse/linalg/_dsolve/SuperLU/SRC/slacon2.c | 2 +-
Expand Down
@@ -1,7 +1,7 @@
From 5b7d4751308016d821c2f6dfadc53e870eb4ed91 Mon Sep 17 00:00:00 2001
From afe320f7a68db3071b763e26691c7b6669a9d529 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 25 Dec 2021 15:08:18 -0800
Subject: [PATCH 11/15] skip fortran fails to link
Subject: [PATCH 10/13] skip fortran fails to link

These are tests and they have both void vs int return value problems and implicit
function argument cast problems. Not worth fixing for tests.
Expand Down
@@ -1,7 +1,7 @@
From ce60b3e7c5d1327c9b4fe00dbfc2292ffef6456f Mon Sep 17 00:00:00 2001
From 00b8c46a16125f76a1b103a666993e2006e3a312 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Thu, 7 Apr 2022 10:41:26 -0700
Subject: [PATCH 13/15] Add extra END to prini.f
Subject: [PATCH 11/13] Add extra END to prini.f

---
scipy/linalg/src/id_dist/src/prini.f | 1 +
Expand Down
@@ -1,7 +1,7 @@
From bf6124c9b92a8c536b6cfc02bd0467476d18129d Mon Sep 17 00:00:00 2001
From d1230a8b448fd38d16d4f4bb34a3005b90f156b6 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Thu, 7 Apr 2022 11:02:29 -0700
Subject: [PATCH 14/15] BUG Fix signature of D_IIR_forback(1,2)
Subject: [PATCH 12/13] BUG Fix signature of D_IIR_forback(1,2)

The precision parameter has type float but it is declared in `_splinemodule.c`
with type double.
Expand Down
25 changes: 0 additions & 25 deletions packages/scipy/patches/0012-Disable-lapack-detection.patch

This file was deleted.

@@ -1,7 +1,7 @@
From e17fd39807ca476d4acf6ad0470040f3c772e4c1 Mon Sep 17 00:00:00 2001
From 637cd45e932a8f66c0e593fa57da497757eab76c Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Mon, 29 Aug 2022 16:45:21 -0700
Subject: [PATCH 15/15] Change qh_eachvoronoi_all FILE type
Subject: [PATCH 13/13] Change qh_eachvoronoi_all FILE type

---
scipy/spatial/_qhull.pyx | 7 ++++---
Expand Down