solprop.backends#
Execution backends behind one seam.
The NumPy reference and native backends
(docs/dev/backends.md). This package exports the seam itself — the
Backend protocol and the record types it returns —
and solprop.backends.registry, which selects a backend by name and says why one
is not usable, and the thread budget every backend’s pools are held within.
- class solprop.backends.ThreadBudget(threads, source, oversubscribe=False, requested=None)#
Bases:
objectThe threads a process may run at once, and the limit that set it.
- Attributes:
- threadsint
The budget, at least one.
- sourcestr
The tightest limit:
"affinity","physical cores","top-tier cores","cgroup quota"or"SOLPROP_THREADS".- oversubscribebool
Whether
SOLPROP_OVERSUBSCRIBElets an explicit count exceed the CPUs and the quota (seeexplicit()).- requestedint or None
SOLPROP_THREADS, which nothing exceeds, orNonewhen it is unset.
- explicit(count)#
Clamp a count someone asked for to what this budget allows.
Normally the budget itself. With
SOLPROP_OVERSUBSCRIBE=1onlySOLPROP_THREADSholds, so a test can run more threads than the machine has CPUs on purpose (a thread-count invariance test on a small runner).- Parameters:
- countint
The positive count asked for.
- Returns:
- int
The count allowed.
Examples
>>> from solprop.backends import ThreadBudget >>> ThreadBudget(4, "affinity").explicit(8) 4 >>> ThreadBudget(4, "affinity", oversubscribe=True).explicit(8) 8
- solprop.backends.thread_budget()#
Return how many threads this process may run at once (ADR-052).
The smallest of the CPUs it may run on (
allowed_cpus:taskset, a batch scheduler’s allocation), the physical cores that hold them (physical_cores) and, on a chip with cores of several kinds, those of the fastest kind (top_tier_cores), both unlessSOLPROP_THREADSis set, its control groups’ CPU quota (cgroup_cpus) andSOLPROP_THREADS. Every pool solprop sizes is held within it, and so is any count asked for explicitly unlessSOLPROP_OVERSUBSCRIBE=1(ThreadBudget.explicit()); the pools take turns, so each may use the whole budget.- Returns:
- ThreadBudget
The budget and the limit that set it; on a tie, the earlier in that order.
- Raises:
- ValueError
If
SOLPROP_THREADSis not a positive thread count, orSOLPROP_OVERSUBSCRIBEis neither0nor1.
Examples
>>> from solprop.backends import thread_budget >>> thread_budget().threads >= 1 True
Modules
The Adams march's controller as functions of its policy and its state (SEP 39). |
|
The engine protocols: what a march asks of the state it advances (SEP 52 §5.2). |
|
The records an execution session hands its service loop (SEP 47 section 5.3). |
|
The phi functions and exponential Adams weights, in NumPy (SEP 16 sections 4.2-4.3). |
|
Destination-based export of a session's field (SEP 47 section 5.4). |
|
The Adams march's bookkeeping, shared by both backends (SEP 13 section 5, SEP 39). |
|
The low-storage interaction-picture RK4 march: replay-only, accepted in place. |
|
Byte counts and sizes the backends share for their memory ledgers. |
|
How many nodes a response pass holds at once: the backend's node-chunk plan. |
|
The NumPy reference backend: the oracle. |
|
Map backend channel reductions onto the mixture's ordered species axis. |
|
The seam: what a backend is, and what comes back from one. |
|
The run records: what one run's march, session and monitor read (SEP 52 §5.1). |
|
Selecting one of the two backends by name, and saying why one is not usable. |
|
The Runge-Kutta march's controller as functions of its policy and state (SEP 45). |
|
The execution-session contract between solprop and a backend (SEP 47 section 5). |
|
The run layer's one door to a backend's sessions (SEP 47 phases 2 to 5). |
|
Collect spatial host statistics through bounded transverse reconstruction chunks. |
|
Assemble the TDSE response's macroscopic source at one evaluation (SEP 49). |