You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Continuous benchmarking of OpenBLAS performance
  2. We run a set of benchmarks of subset of OpenBLAS functionality.
  3. ## Benchmark runner
  4. [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/OpenMathLib/OpenBLAS/)
  5. Click on [benchmarks](https://codspeed.io/OpenMathLib/OpenBLAS/benchmarks) to see the performance of a particular benchmark over time;
  6. Click on [branches](https://codspeed.io/OpenMathLib/OpenBLAS/branches/) and then on the last PR link to see the flamegraphs.
  7. ## What are the benchmarks
  8. 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).
  9. 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.
  10. ## Adding a new benchmark
  11. `.github/workflows/codspeed-bench.yml` does all the orchestration on CI.
  12. Benchmarks live in the `benchmark/pybench` directory. It is organized as follows:
  13. - benchmarks themselves live in the `benchmarks` folder. Note that the LAPACK routines are imported from the `openblas_wrap` package.
  14. - 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`.
  15. 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
  16. `scipy.linalg.blas` and `scipy.linalg.lapack`.
  17. To change parameters of an existing benchmark, edit python files in the `benchmark/pybench/benchmarks` directory.
  18. To add a benchmark for a new BLAS or LAPACK function, you need to:
  19. - 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)
  20. - add an import to `benchmark/pybench/openblas_wrap/__init__.py`
  21. ## Running benchmarks locally
  22. This benchmarking layer is orchestrated from python, therefore you'll need to
  23. have all what it takes to build OpenBLAS from source, plus `python` and
  24. ```
  25. $ python -mpip install numpy meson ninja pytest pytest-benchmark
  26. ```
  27. The Meson build system looks for the installed OpenBLAS using pkgconfig, so the openblas.pc created during the OpenBLAS build needs
  28. to be somewhere on the search path of pkgconfig or in a folder pointed to by the environment variable PKG_CONFIG_PATH.
  29. If you want to build the benchmark suite using flang (or flang-new) instead of gfortran for the Fortran parts, you currently need
  30. to edit the meson.build file and change the line `'fortran_std=legacy'` to `'fortran_std=none'` to work around an incompatibility
  31. between Meson and flang.
  32. If you are building and running the benchmark under MS Windows, it may be necessary to copy the generated openblas_wrap module from
  33. your build folder to the `benchmarks` folder.
  34. The benchmark syntax is consistent with that of `pytest-benchmark` framework. The incantation to run the suite locally is `$ pytest benchmark/pybench/benchmarks/bench_blas.py`.
  35. An ASV compatible benchmark suite is planned but currently not implemented.