Skip to content

Commit

Permalink
Add scipy-openblas support
Browse files Browse the repository at this point in the history
Currently bundles the header because of
MacPython/openblas-libs#163
  • Loading branch information
serge-sans-paille committed Jun 30, 2024
1 parent ab9f31a commit 19bc103
Show file tree
Hide file tree
Showing 4 changed files with 1,362 additions and 45 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install scipy-openblas64
pip install pytest-xdist
sudo apt install libopenblas-dev ${{ matrix.cpp-version }}
sudo apt install ${{ matrix.cpp-version }}
if test ${{ matrix.python-version }} != 'pypy-3.9'; then pip install scipy ; fi
- name: Setup
run: |
python -m pip install .
python -m pip install . 'pythran[test]'
printf '[compiler]\nblas=openblas\n' > ~/.config/.pythranrc
printf 'cflags=-std=c++11 -Wall -Werror -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-cpp -Wno-deprecated-declarations -Wno-absolute-value -Wno-parentheses-equality\n' >> ~/.config/.pythranrc
printf '[compiler]\nblas=scipy-openblas\n' > ~/.config/.pythranrc
printf 'cflags=-std=c++11 -Wall -Werror -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-cpp -Wno-deprecated-declarations' >> ~/.config/.pythranrc
if test "${{ matrix.cpp-version }}" = "clang-7" ; then printf -- " -Wno-absolute-value -Wno-parentheses-equality\n" ; else printf "\n" ; fi >> ~/.config/.pythranrc
- name: Testing minimal CLI
run: |
pythran --version
Expand Down
24 changes: 13 additions & 11 deletions docs/MANUAL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ loaded. This can be helpful for reproducible builds.
All the options in the ``.pythranrc`` file can be specified when running pythran by using the command line argument --config= .
For example::

pythran --config compiler.blas=pythran-openblas this_file.py
pythran --config compiler.blas=scipy-openblas this_file.py

would specify that pythran-openblas is the blas library to use.
would specify that ``scipy-openblas`` is the blas library to use.

Options specified using command-line arguments override the options found in the ``.pythranrc`` file

Expand Down Expand Up @@ -648,15 +648,17 @@ This section contains compiler flags configuration. For education purpose, the d

:``blas``:

BLAS library to use. ``none``, ``pythran-openblas``, ``blas``,
``openblas``, ``atlas`` or ``mkl`` are viable choices.
``none`` prevents from linking with blas.
``pythran-openblas`` requires the `pythran-openblas
<https://pypi.org/project/pythran-openblas/>`_ package, which provides a
statically linked version of `OpenBLAS <https://www.openblas.net/>`_. Other
options are system dependant. Depending on your setup, you *may* need to
update ``include_dirs`` to point to the location of the BLAS headers, e.g.
``/usr/include/openblas``.
BLAS library to use. ``none``, ``scipy-openblas``, ``pythran-openblas``,
``blas``, ``openblas``, ``atlas`` or ``mkl`` are viable choices. ``none``
prevents from linking with blas. ``scipy-openblas`` requires the
`scipy-openblas64 <https://pypi.org/project/scipy-openblas64/>`_ package,
which provides a prepcompiled version of `OpenBLAS
<https://www.openblas.net/>`_. ``pythran-openblas`` requires the
`pythran-openblas <https://pypi.org/project/pythran-openblas/>`_ package,
which provides a statically linked version of `OpenBLAS
<https://www.openblas.net/>`_. Other options are system dependant. Depending
on your setup, you *may* need to update ``include_dirs`` to point to the
location of the BLAS headers, e.g. ``/usr/include/openblas``.

:``ignoreflags``:

Expand Down
17 changes: 16 additions & 1 deletion pythran/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def parse_define(define):
extension['include_dirs'].append(numpy.get_include())

# blas dependency
reserved_blas_entries = 'pythran-openblas', 'none'
reserved_blas_entries = 'scipy-openblas', 'pythran-openblas', 'none'
user_blas = cfg.get('compiler', 'blas')
if user_blas == 'pythran-openblas':
try:
Expand All @@ -247,6 +247,21 @@ def parse_define(define):
"Please install it or change the compiler.blas "
"setting. Defaulting to 'none'")
user_blas = 'none'
elif user_blas == 'scipy-openblas':
try:
import scipy_openblas64 as openblas
# required to cope with atlas missing extern "C"
extension['define_macros'].append('PYTHRAN_BLAS_SCIPY_OPENBLAS')
extension['include_dirs'].append(openblas.get_include_dir())
extension['library_dirs'].append(openblas.get_lib_dir())
extension['libraries'].append(openblas.get_library())
extension['extra_link_args'].append("-Wl,-rpath=" + openblas.get_lib_dir())
except ImportError:
logger.warning("Failed to find 'scipy-openblas64' package. "
"Please install it or change the compiler.blas "
"setting. Defaulting to 'none'")
user_blas = 'none'


if user_blas == 'none':
extension['define_macros'].append('PYTHRAN_BLAS_NONE')
Expand Down
Loading

0 comments on commit 19bc103

Please sign in to comment.