High-precision calculations for one- and two-valence atomic systems
qip::SingleThreadBlas

ok

Scoped guard: forces single-threaded BLAS (OpenBLAS) for the lifetime of the object; restores the previous BLAS thread count on destruction.

BLAS calls made from inside an OpenMP parallel region contend badly with the pthread-build OpenBLAS thread pool (every concurrent call fights over the same pool and its global lock). The outer OpenMP parallelism already saturates the cores there, so BLAS should run single-threaded. Construct one of these in serial code just before entering such a region; the effect is strictly scoped to the object's lifetime.

OpenBLAS is located at run time (dlsym), so there is no compile-time dependence on it: with any other BLAS library the guard is a no-op (reference BLAS is single-threaded anyway). Also a no-op when OpenMP is not compiled in, or when only one OpenMP thread is available: BLAS threading is then the only parallelism, and is left alone.

#include <omp.hpp>

Public Member Functions

 SingleThreadBlas (const SingleThreadBlas &)=delete
 
SingleThreadBlas & operator= (const SingleThreadBlas &)=delete
 

The documentation for this class was generated from the following file: