morphogen.settings

Global run-time settings (number of threads).

morphogen.settings.set_num_threads(n: int | None) → None[source]

Number of threads used by compiled kernels and SciPy (None: all cores).

morphogen.settings.workers() → int[source]

workers argument for SciPy routines.

morphogen.settings.blas_on_one_thread() → Iterator[None][source]

Within the block, the BLAS of NumPy and SciPy (OpenBLAS) on one thread; the number of its threads is restored after it.

The compiled kernels run on their own threads. A product of BLAS between two of them (a norm, a small factorization) wakes the threads of OpenBLAS, which then stay busy for a tenth of a second, waiting for the next product, and take the cores of the kernels that follow: a loading path or a Krylov iteration is slowed by a third to a half. The dense algebra within those loops is small (6 x 6 systems, the Hessenberg matrices of GMRES): one thread serves it as well. Without OpenBLAS (another BLAS, or none found), the block runs as it is.

morphogen.settings.without_blas_threads(function)[source]

Decorator: the function runs within blas_on_one_thread().