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 ()
 Query OS-visible logical CPU concurrency.
 
int ompMaxThreads ()
 Query the current calling-context OpenMP maximum.
 
int ompAvailable ()
 Report whether engine OpenMP support was compiled.
 
int perfCores ()
 Query macOS performance-cluster logical CPU count.
 
int kokkosOmpThreads ()
 Read the engine-recorded Kokkos OpenMP team hint.
 
void setKokkosOmpThreads (int n)
 Store the engine-recorded Kokkos OpenMP team hint.
 
int hostReservedThreads ()
 Read host thread reservation from the current environment.
 
bool isOversubscribed (int threads)
 Compare a team plus host reservation with known logical concurrency.
 
int resolveRequested (int requested, const char *what, std::vector< std::string > *warnings)
 Resolve a thread request and optionally append oversubscription diagnostics.
 
int dwThreads (int requested, int n_conduits, std::vector< std::string > *warnings)
 Resolve a dynamic-wave team request with model-size and automatic core caps.
 
int twoDThreads (int requested, int n_triangles, std::vector< std::string > *warnings)
 Resolve a 2D marcher team request using core and triangle-count heuristics.
 

Variables

constexpr int kMinConduitsPerThread = 100
 

Function Documentation

◆ dwThreads()

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

Resolve a dynamic-wave team request with model-size and automatic core caps.

Applies model-size cap to explicit and automatic requests, warning only for explicit reductions. Exactly requested=0 additionally caps to performance cores minus two on macOS when that count exceeds two. Negative requests use OpenMP maximum without that auto-only clamp.

Parameters
[in]requestedRequested team size; <=0 resolves from OpenMP maximum. Exactly zero additionally enables automatic core-clamp heuristics.
[in]n_conduitsConduit count used in floor(count/100), normalized to a minimum one-worker cap.
[in,out]warningsOptional caller-owned sink; new messages append without clearing existing entries.
Returns
Positive recommended team size; does not set OpenMP or honor SWMM_DW_THREADS directly.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hostReservedThreads()

int openswmm::threadinfo::hostReservedThreads ( )

Read host thread reservation from the current environment.

Value is read on every call; trailing nonnumeric bytes accepted by atoi are not separately rejected. Caller avoids environment mutation races and out-of-int-range tokens.

Returns
Positive atoi prefix of OPENSWMM_HOST_RESERVED_THREADS, or zero when absent/empty/nonpositive.
Here is the caller graph for this function:

◆ isOversubscribed()

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

Compare a team plus host reservation with known logical concurrency.

Parameters
[in]threadsTeam count; caller keeps threads+hostReservedThreads() representable as int.
Returns
True only when logical CPU count is known and the sum exceeds it; false when hardware count is unknown.
Here is the call graph for this function:

◆ kokkosOmpThreads()

int openswmm::threadinfo::kokkosOmpThreads ( )

Read the engine-recorded Kokkos OpenMP team hint.

Does not query or initialize the plugin/runtime.

Returns
Relaxed atomic stored hint; zero until set or after a nonpositive reset.

◆ logicalCpus()

int openswmm::threadinfo::logicalCpus ( )

Query OS-visible logical CPU concurrency.

Returns
std::thread::hardware_concurrency() converted to int; zero if unavailable.
Here is the caller graph for this function:

◆ ompAvailable()

int openswmm::threadinfo::ompAvailable ( )

Report whether engine OpenMP support was compiled.

Returns
One with SWMM_USE_OPENMP, zero otherwise; no runtime/plugin qualification.

◆ ompMaxThreads()

int openswmm::threadinfo::ompMaxThreads ( )

Query the current calling-context OpenMP maximum.

Does not create a team or guarantee that the runtime will provide this many workers.

Returns
Positive omp_get_max_threads() result, normalized to at least one; one without SWMM_USE_OPENMP.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perfCores()

int openswmm::threadinfo::perfCores ( )

Query macOS performance-cluster logical CPU count.

Returns
Positive hw.perflevel0.logicalcpu value, or zero for sysctl failure/unsupported platform.
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 thread request and optionally append oversubscription diagnostics.

For positive requests, warns when request+host reservation exceeds known logical CPUs; otherwise warns above the current OpenMP maximum. On macOS can additionally warn above performance-cluster size. No actual runtime team is changed. Caller keeps request+reservation representable as int.

Parameters
[in]requestedRequested team size; <=0 resolves from OpenMP maximum. Exactly zero additionally enables automatic core-clamp heuristics.
[in]whatBorrowed non-null NUL-terminated activity label used in formatted warnings.
[in,out]warningsOptional caller-owned sink; new messages append without clearing existing entries.
Returns
OpenMP maximum for requested<=0; otherwise the positive request is returned unchanged.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setKokkosOmpThreads()

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

Store the engine-recorded Kokkos OpenMP team hint.

Uses relaxed atomic storage; provides no synchronization for plugin initialization or other engine state.

Parameters
[in]nTeam count; nonpositive values store zero.

◆ twoDThreads()

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

Resolve a 2D marcher team request using core and triangle-count heuristics.

Exactly requested=0 applies the macOS performance-core-minus-two cap before the mesh test. Positive requests reduced by the mesh test append a diagnostic. Negative requests skip the auto-only core cap.

Parameters
[in]requestedRequested team size; <=0 resolves from OpenMP maximum. Exactly zero additionally enables automatic core-clamp heuristics.
[in]n_trianglesTriangle count; recommends one worker when n_triangles<4*resolved team. Caller keeps that product representable as int.
[in,out]warningsOptional caller-owned sink; new messages append without clearing existing entries.
Returns
Positive recommended team size; does not create or alter a runtime team.
Here is the call 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).