Jason Brownlee's Blog, page 21
May 4, 2023
Combine NumPy BLAS Threads and Multiprocessing
You can combine BLAS threads and multiprocessing in a NumPy program. Maximizing these types of parallelism can help you fully utilize your CPU cores for a given application and achieve a speed-up compared to not using any or only one level of parallelism. It can also be tricky as sometimes combining multiprocessing with NumPy BLAS […]
Published on May 04, 2023 12:00
May 2, 2023
Numpy Multithreaded Matrix Multiplication (up to 5x faster)
Multithreaded matrix multiplication in numpy scales with the number of physical CPU cores available. An optimized number of threads for matrix optimization can be up to 5x faster than using a single thread to perform the operation. In this tutorial, you will discover how to benchmark matrix multiplication performance with different numbers of threads. Let’s […]
Published on May 02, 2023 12:00
April 30, 2023
Numpy Multithreaded Matrix Multiplication Scales With Size
Multithreaded matrix multiplication in numpy is faster than single-threaded matrix multiplication. The speed-up factor can range from slightly above 1.2x to nearly 3x, depending on the size of the matrices that are being multiplied. It is possible that multiplying smaller matrices, such as 100×100 or smaller may result in worse performance when using threads. In […]
Published on April 30, 2023 12:00
April 27, 2023
Numpy Multithreaded Matrix Solvers (up to 2x faster)
You can solve matrices of linear systems of equations in numpy in parallel using multithreaded implementations of the algorithms. In this tutorial, you will discover how to solve systems of linear equations using multithreaded numpy functions. Let’s get started. Numpy Matrix Solvers are Multithreaded Linear algebra is a field of mathematics concerned with linear equations […]
Published on April 27, 2023 12:00
April 25, 2023
Numpy Parallel Matrix Decompositions
You can calculate matrix decompositions in parallel with NumPy. NumPy uses the BLAS library to calculate matrix decompositions, and implementations of the BLAS library installed with numpy, such as OpenBLAS and ATLAS will implement multithreaded versions of matrix decomposition algorithms. This means matrix decomposition functions in numpy are parallel by default. In this tutorial, you […]
Published on April 25, 2023 12:00
April 23, 2023
NumPy Parallel Matrix-Vector Multiplication
You can multiply a matrix by a vector in parallel with numpy. Matrix-vector multiplication can be achieved in numpy using the numpy.dot() method, the ‘@‘ operator and the numpy.matmul() function. All three approaches call down into the BLAS library which implements the operation in parallel using native threads. This means that matrix-vector multiplication is parallel […]
Published on April 23, 2023 12:00
April 20, 2023
Numpy Multithreaded Matrix Functions (up to 3x faster)
You can calculate matrix linear algebra functions in parallel with NumPy. In this tutorial, you will discover how to calculate multithreaded matrix linear algebra functions with NumPy. Let’s get started. Numpy Linear Algebra Matrix Functions are Multithreaded Linear algebra is a field of mathematics concerned with linear equations with arrays and matrices of numbers. Numpy […]
Published on April 20, 2023 12:00
April 18, 2023
Which NumPy Functions Are Multithreaded
Some NumPy functions will execute in parallel using multithreading automatically and behind the scenes. In this tutorial, you will discover which NumPy functions support parallelism via multithreading in Python. Let’s get started. Which NumPy Functions Are Multithreaded? NumPy supports multithreading by default. Some NumPy functions make use of the BLAS (Basic Linear Algebra Subprograms) and […]
Published on April 18, 2023 12:00
April 16, 2023
NumPy Supports Multithreaded Parallelism
Some NumPy functions run in parallel and use multiple threads, by default. Parts of NumPy are built on top of a standard API for linear algebra operations called BLAS and BLAS libraries make use of multiple threads to speed up some operations by default. As such, your installation of NumPy almost certainly already supports parallelism. […]
Published on April 16, 2023 12:00
April 13, 2023
Limit BLAS Threads in Numpy with threadpoolctl
You can configure the number of threads used by BLAS via numpy with the threadpoolctl library. In this tutorial, you will discover how to control the number of threads used by BLAS with threadpoolctl library. Let’s get started. Need to Limit Number of BLAS Threads NumPy is an array library in Python. It makes use […]
Published on April 13, 2023 12:00


