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

#include <gpr/linalg/SerialEigenThreads.h>

Public Member Functions

 ScopedSerialEigenThreads ()
 ~ScopedSerialEigenThreads ()
 ScopedSerialEigenThreads (const ScopedSerialEigenThreads &)=delete
ScopedSerialEigenThreads & operator= (const ScopedSerialEigenThreads &)=delete

Detailed Description

Serialize callers that temporarily force Eigen's global thread budget to 1, restoring the previous budget when the outermost scope exits. Reentrant on the owning thread so nested scopes (e.g. AtomicInducingPosterior calling DenseLLTInverse) neither deadlock nor restore early.

Internal to libgpridge, not public API: only DenseLLTInverse.cpp and AtomicInducingPosterior.cpp use it, and no installed header declares or includes it, so this header is not installed. The class is hidden so the shared library's exported symbol set does not grow, and so no other module can depend on its layout.

Definition at line 23 of file SerialEigenThreads.h.

Constructor & Destructor Documentation

◆ ScopedSerialEigenThreads() [1/2]

gpr::linalg::ScopedSerialEigenThreads::ScopedSerialEigenThreads ( )

Definition at line 65 of file LinalgThreads.cpp.

66{
67 auto& state = serialEigenThreadState();
68 state.mutex.lock();
69 if (state.depth == 0) {
70 state.saved_threads = Eigen::nbThreads();
71 if (state.saved_threads != 1) Eigen::setNbThreads(1);
72 }
73 ++state.depth;
74}

◆ ~ScopedSerialEigenThreads()

gpr::linalg::ScopedSerialEigenThreads::~ScopedSerialEigenThreads ( )

Definition at line 76 of file LinalgThreads.cpp.

77{
78 auto& state = serialEigenThreadState();
79 --state.depth;
80 if (state.depth == 0 && state.saved_threads != 1) {
81 Eigen::setNbThreads(state.saved_threads);
82 }
83 state.mutex.unlock();
84}

◆ ScopedSerialEigenThreads() [2/2]

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

Member Function Documentation

◆ operator=()

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

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