Skip to content

Commit 81cf0db

Browse files
committed
DOC: add a readme for benchmarks/pybench
1 parent 9f28161 commit 81cf0db

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

benchmark/pybench/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Continuous benchmarking of OpenBLAS performance
2+
3+
We run a set of benchmarks of subset of OpenBLAS functionality.
4+
5+
## Benchmark runner
6+
7+
[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/OpenMathLib/OpenBLAS/)
8+
9+
Click on [benchmarks](https://codspeed.io/OpenMathLib/OpenBLAS/benchmarks) to see the performance of a particular benchmark over time;
10+
Click on [branches](https://codspeed.io/OpenMathLib/OpenBLAS/branches/) and then on the last PR link to see the flamegraphs.
11+
12+
## What are the benchmarks
13+
14+
We run raw BLAS/LAPACK subroutines, via f2py-generated python wrappers. The wrappers themselves are equivalent to [those from SciPy](https://docs.scipy.org/doc/scipy/reference/linalg.lapack.html).
15+
In fact, the wrappers _are_ from SciPy, we take a small subset simply to avoid having to build the whole SciPy for each CI run.
16+
17+
18+
## Adding a new benchmark
19+
20+
`.github/workflows/codspeed-bench.yml` does all the orchestration on CI.
21+
22+
Benchmarks live in the `benchmark/pybench` directory. It is organized as follows:
23+
24+
- benchmarks themselves live in the `benchmarks` folder. Note that the LAPACK routines are imported from the `openblas_wrap` package.
25+
- the `openblas_wrap` package is a simple trampoline: it contains an f2py extension, `_flapack`, which talks to OpenBLAS, and exports the python names in its `__init__.py`.
26+
This way, the `openblas_wrap` package shields the benchmarks from the details of where a particular LAPACK function comes from. If wanted, you may for instance swap the `_flapack` extension to
27+
`scipy.linalg.blas` and `scipy.linalg.lapack`.
28+
29+
To change parameters of an existing benchmark, edit python files in the `benchmark/pybench/benchmarks` directory.
30+
31+
To add a benchmark for a new BLAS or LAPACK function, you need to:
32+
33+
- add an f2py wrapper for the bare LAPACK function. You can simply copy a wrapper from SciPy (look for `*.pyf.src` files in https://github.com/scipy/scipy/tree/main/scipy/linalg)
34+
- add an import to `benchmark/pybench/openblas_wrap/__init__.py`
35+
36+
37+
## Running benchmarks locally
38+
39+
This benchmarking layer is orchestrated from python, therefore you'll need to
40+
have all what it takes to build OpenBLAS from source, plus `python` and
41+
42+
```
43+
$ python -mpip install numpy meson ninja pytest pytest-benchmark
44+
```
45+
46+
The benchmark syntax is consistent with that of `pytest-benchmark` framework. The incantation to run the suite locally is `$ pytest benchmark/pybench/benchmarks/test_blas.py`.
47+
48+
An ASV compatible benchmark suite is planned but currently not implemented.
49+

0 commit comments

Comments
 (0)