OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::threadinfo Namespace Reference

Functions

int logicalCpus ()
 
int ompMaxThreads ()
 
int ompAvailable ()
 1 when built with SWMM_USE_OPENMP, else 0.
 
int perfCores ()
 
int kokkosOmpThreads ()
 
void setKokkosOmpThreads (int n)
 Recorded by the engine when it hands a thread count to the Kokkos plugin.
 
int hostReservedThreads ()
 
bool isOversubscribed (int threads)
 
int resolveRequested (int requested, const char *what, std::vector< std::string > *warnings)
 Resolve a [OPTIONS] THREADS request into a thread count.
 
int dwThreads (int requested, int n_conduits, std::vector< std::string > *warnings)
 Dynamic-wave Picard team size for a THREADS request.
 
int twoDThreads (int requested, int n_triangles, std::vector< std::string > *warnings)
 2D CPU-marcher team size for a THREADS request.
 

Variables

constexpr int kMinConduitsPerThread = 100
 

Function Documentation

◆ dwThreads()

int openswmm::threadinfo::dwThreads ( int requested,
int n_conduits,
std::vector< std::string > * warnings )

Dynamic-wave Picard team size for a THREADS request.

resolveRequested(), then the model-size gate (n_conduits / kMinConduitsPerThread, applied to explicit values too — with a warning), then, for auto only, the macOS performance-core clamp (perfCores() - 2). Does NOT consult SWMM_DW_THREADS; the caller handles that override.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hostReservedThreads()

int openswmm::threadinfo::hostReservedThreads ( )

Threads the HOST application keeps busy alongside the engine (OPENSWMM_HOST_RESERVED_THREADS; 0 when unset or invalid). A GUI that runs the engine in-process sets it — its own event thread, a render thread, the engine IO thread — so that isOversubscribed() and the active spin-wait decision see the whole process, not just the team.

Here is the caller graph for this function:

◆ isOversubscribed()

bool openswmm::threadinfo::isOversubscribed ( int threads)

True when threads plus hostReservedThreads() exceed the logical CPU count (the runtime would oversubscribe). Used to decide whether an active spin-wait policy is safe: a spinner waiting on a DESCHEDULED spinner turns every barrier into a scheduler-quantum stall.

Here is the call graph for this function:

◆ kokkosOmpThreads()

int openswmm::threadinfo::kokkosOmpThreads ( )

Threads the Kokkos OpenMP 2D backend was initialised with in this process; 0 until the plugin initialises (or when no plugin is loaded).

◆ logicalCpus()

int openswmm::threadinfo::logicalCpus ( )

Logical processors visible to the OS (SMT / hyper-threads included). std::thread::hardware_concurrency(); 0 when unknown.

Here is the caller graph for this function:

◆ ompAvailable()

int openswmm::threadinfo::ompAvailable ( )

1 when built with SWMM_USE_OPENMP, else 0.

◆ ompMaxThreads()

int openswmm::threadinfo::ompMaxThreads ( )

omp_get_max_threads() as seen by this process — the OpenMP runtime's default team size. Lower than logicalCpus() when OMP_NUM_THREADS, OMP_THREAD_LIMIT or a CPU-affinity mask limits the process. 1 when the engine is built without OpenMP.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perfCores()

int openswmm::threadinfo::perfCores ( )

macOS: logical CPUs on the PERFORMANCE cluster (hw.perflevel0.logicalcpu); 0 on Intel Macs, other platforms, or sysctl failure.

Here is the caller graph for this function:

◆ resolveRequested()

int openswmm::threadinfo::resolveRequested ( int requested,
const char * what,
std::vector< std::string > * warnings )

Resolve a [OPTIONS] THREADS request into a thread count.

Rule (plan §2):

  • requested == 0 → auto: ompMaxThreads(), callers then apply their own heuristics (model-size gate, macOS P-core clamp).
  • requested > 0 → honoured exactly. Warnings are appended when it exceeds logicalCpus() (oversubscription), exceeds ompMaxThreads() (environment / affinity lowered the runtime limit), or, on macOS, exceeds perfCores() (efficiency cores slow barrier-synchronised teams).
Parameters
requested[OPTIONS] THREADS value.
whatShort label for warning text ("OpenMP team", "dynamic wave", "2D").
warningsSink for human-readable warnings; may be nullptr.
Returns
Thread count to request from the runtime (>= 1).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setKokkosOmpThreads()

void openswmm::threadinfo::setKokkosOmpThreads ( int n)

Recorded by the engine when it hands a thread count to the Kokkos plugin.

◆ twoDThreads()

int openswmm::threadinfo::twoDThreads ( int requested,
int n_triangles,
std::vector< std::string > * warnings )

2D CPU-marcher team size for a THREADS request.

resolveRequested(), then n_triangles < 4 * nt → 1 (warned when it reduces an explicit request).

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ kMinConduitsPerThread

int openswmm::threadinfo::kMinConduitsPerThread = 100
constexpr

Minimum conduits of momentum work per dynamic-wave team thread before an extra thread pays for its barriers (PERFORMANCE-ONLY; bit-identical).