Effect of CPU Thread Count on Dense Matrix Multiplication Performance in NumPy
NumPy can delegate dense matrix multiplication to a multithreaded Basic Linear Algebra Subprograms (BLAS) library. The useful thread count depends on the size of the problem and the execution environment. This study measured double-precision multiplication of square matrices with side lengths from 64 to 3,072 using OpenBLAS limits of one, two, and four CPU threads. Six sessions covered all orders of the three limits, with each limit run in a fresh Python process. Each session measured four batches per size and limit, yielding 720 timed batches. At size 64, median paired speedups were 1.01× with two threads and 0.92× with four. Both limits met the study’s consistency criterion at size 128 and at every larger size tested. At size 3,072, median time was 869.6 ms with one thread and 321.7 ms with four. The median of the six paired speedups was 2.89×. At intermediate sizes the incremental benefit of four threads over two was variable. These results illustrate how input size and the choice of a baseline affect thread-count decisions for a single NumPy and OpenBLAS environment.
Authors
- Assan Kumarkhanov
Institutions
- Al-Farabi Kazakh National University (KZ)
Publication Details
- Journal
- Research Square
- Published
- 2026-12-02
- DOI
- https://doi.org/10.21203/rs.3.rs-11929265/v1
- Primary Topic
- Parallel Computing and Optimization Techniques
- Type
- preprint