Loading...
Searching...
No Matches
gpr::linalg::ScopedSolveThreads Class Reference

#include <gpr/linalg/ScalapackBackend.h>

Public Member Functions

 ScopedSolveThreads () noexcept
 ~ScopedSolveThreads ()
 ScopedSolveThreads (const ScopedSolveThreads &)=delete
ScopedSolveThreads & operator= (const ScopedSolveThreads &)=delete

Static Public Member Functions

static int solveThreadTarget () noexcept

Detailed Description

Raises the BLAS thread count to the kernel-block worker count for the scope of a large dense solve and restores it afterwards.

Definition at line 199 of file ScalapackBackend.h.

Constructor & Destructor Documentation

◆ ScopedSolveThreads() [1/2]

gpr::linalg::ScopedSolveThreads::ScopedSolveThreads ( )
inlinenoexcept

Definition at line 201 of file ScalapackBackend.h.

202 : previous_(blasThreadCount()),
203 target_(solveThreadTarget()),
204 raised_(previous_ > 0 && target_ > previous_)
205 {
206 if (raised_) configureLinalgThreads(target_);
207 if (std::getenv("GPR_GEOM_DEBUG") != nullptr) {
208 static bool reported = false;
209 if (!reported) {
210 reported = true;
211 std::fprintf(stderr,
212 "[solve-threads] previous=%d target=%d raised=%d "
213 "now=%d\n",
214 previous_, target_, raised_ ? 1 : 0,
216 }
217 }
218 }
static int solveThreadTarget() noexcept
int blasThreadCount() noexcept
void configureLinalgThreads(int threads)

◆ ~ScopedSolveThreads()

gpr::linalg::ScopedSolveThreads::~ScopedSolveThreads ( )
inline

Definition at line 227 of file ScalapackBackend.h.

228 {
229 if (raised_) configureLinalgThreads(previous_);
230 }

◆ ScopedSolveThreads() [2/2]

gpr::linalg::ScopedSolveThreads::ScopedSolveThreads ( const ScopedSolveThreads & )
delete

Member Function Documentation

◆ operator=()

ScopedSolveThreads & gpr::linalg::ScopedSolveThreads::operator= ( const ScopedSolveThreads & )
delete

◆ solveThreadTarget()

int gpr::linalg::ScopedSolveThreads::solveThreadTarget ( )
inlinestaticnodiscardnoexcept

Kernel workers can be reassigned to a dense solve. CPU affinity caps that budget; it does not grant every rank all CPUs in an allocation.

Definition at line 221 of file ScalapackBackend.h.

222 {
223 const int affinity = affinityCpuCount();
224 const int workers = LocalExecutor().concurrency();
225 return affinity > 0 ? std::min(affinity, workers) : workers;
226 }
int affinityCpuCount() noexcept
CPUs in this process's scheduling affinity, or 0 when unknown.

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