question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Temporarily allow MKL/OPENBLAS threading?

See original GitHub issue

I noticed this Issue #317 and its associated fix: https://github.com/pyscf/pyscf/blob/e064645ee08728c64412ed9bc8e7ffe45fc8e1f4/pyscf/__init__.py#L42

Suppresses MKL and OPENBLAS threading for the entire pyscf calculation. With @hongzhouye’s RSDF (#1034) speedup over GDF, calls to scipy solve_triangular become a bottleneck in the process, e.g. https://github.com/pyscf/pyscf/blob/8a4d973aeab9f7f3adb08cf1d15ba73a05fc7c17/pyscf/pbc/df/df.py#L362 which appears to be single threaded due to the aforementioned setting.

I wonder if there is a way to temporarily allow BLAS/LAPACK multithreading for these calls to solve_triangular? They only show in df modules.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jamesETsmithcommented, Nov 14, 2021

@btglau I’m 99% sure scipy.linalg.solve_triangular should not be parallelized across threads. That function calls the LAPACK function trtrs, see the SciPy source here: https://github.com/scipy/scipy/blob/47bb6febaa10658c72962b9615d5d5aa2513fa3a/scipy/linalg/basic.py#L349.

The MKL docs don’t list trtrs as a function that’s parallelized with threads. I’ve tried out using scipy.linalg.solve_triangular on it’s own (with MKL and several OpenBLAS versions as the SciPy backend) and none show threading dependence while other methods like scipy.linalg.solve do (see the mini-benchmark here).

0reactions
fishjojocommented, Apr 22, 2022

You may try the threadpoolctl package, which allows to set BLAS threading dynamically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenBLAS set number of threads for one routine only
While this works, it sets the openblas num threads globally, preventing each subroutines to use a different number of threads when running in ......
Read more >
Multithreading · ITensors.jl - JuliaHub
Enable or disable block sparse multithreading. In addition, we have found that it is best to disable BLAS and Strided multithreading when using ......
Read more >
changelog file - OpenBLAS
A new compile-time option USE_TLS has been added to enable the new code, and it is hoped that ... (d744c9) * Improved cblas.h...
Read more >
BLAS performance testing for Julia 1.8
Let OpenBLAS detect the number of threads on startup, which is usually Sys.CPU_THREADS. With Julia master on a 20 core box (40 hyperthreads),...
Read more >
Speedup by using external BLAS/LAPACK with CmdStan and ...
e.g. OpenBLAS and Intel MKL can use more than one thread also for BLAS/LAPACK. You can set the number of threads with environment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found