Add explicit synchronized L2 runtime continuation
This commit is contained in:
1 parent
999d3a0e94
commit
766658185f
4 files changed
+330
-5
No files matched your search
@@ -1,11 +1,11 @@
|
||||
# Synchronized leaf G remap (CPU only)
|
||||
# Synchronized leaf G remap and manual continuation
|
||||
|
||||
This is a CPU state-transfer component, **not a runtime adaptive solver**.
|
||||
It changes only a separated L2 rectangle set in a three-level, body-free,
|
||||
periodic hierarchy. L0/L1 topology, relaxation parameters, direction order,
|
||||
physical frame and completed time remain unchanged. Existing geometry checks
|
||||
validate child support/nesting and separation. No CUDA, scheduler, allocator,
|
||||
boundary handling, collision, ghost refill or runtime installation is added.
|
||||
validate child support/nesting and separation. The CPU helper itself adds no CUDA, scheduler, allocator, boundary handling,
|
||||
collision or ghost refill. A bounded runtime adapter is described below.
|
||||
|
||||
```python
|
||||
from CelerisLab.lbm.refinement import FixedPatchSet2D
|
||||
@@ -56,7 +56,7 @@ dtype. New nonleaves are NaN. Source arrays/metadata are not changed.
|
||||
and new `topology.leaf_masks`. Existing `FixedPatchStepper.initialize` resets
|
||||
the counter: using it is **not** a continuation adapter. This component neither
|
||||
publishes a candidate nor retires old state. Runtime table rebuild/halo refill
|
||||
and correct first-step scheduling remain separate integration work.
|
||||
and correct first-step scheduling are handled only by the explicit adapter below.
|
||||
|
||||
Tests accumulate leaf-area integrals in FP64 for each population, mass and
|
||||
momentum. The declared absolute tolerance is `2e-13 * sum(abs(old population
|
||||
@@ -68,3 +68,44 @@ is not invertible. No kinetic accuracy or stability claim follows.
|
||||
```sh
|
||||
PYTHONPATH=src python -m unittest discover -s tests/unit -p 'test_synchronized_remap.py' -v
|
||||
```
|
||||
|
||||
## Explicit runtime continuation
|
||||
|
||||
`replacement = current.remap_child(rectangles)` returns a new ready
|
||||
`FixedPatchStepper` at the **same absolute step_count**. It supports only
|
||||
body-free periodic three-level runs whose existing L2 uses
|
||||
`child_rectangles_in_parent`. Scalar or union L1 parents are supported; scalar
|
||||
`child=` is deliberately rejected. L0/L1, relaxation and block sizes stay fixed.
|
||||
No tagger, scheduler, in-place replacement, or general rollback is provided.
|
||||
|
||||
The method holds the stepper lock, validates geometry, synchronizes its stream,
|
||||
and downloads the actual current owned leaves. It certifies postcollision G
|
||||
and completed 1:2:4 counts internally, applies the CPU helper, rebuilds all
|
||||
geometry/transfer/kind/halo buffers, and uploads both current and spare buffers.
|
||||
No old halo is reused. The regular step schedule fills transit ghosts/halos
|
||||
before use. `initialize` itself still resets the count to zero.
|
||||
|
||||
The old stepper remains ready, unchanged and independently usable. The caller
|
||||
owns **both** objects and must close both before closing their shared CUDA
|
||||
context. Candidate construction or upload failure releases only candidate
|
||||
resources; an actual old-device synchronization/read failure marks the old
|
||||
stepper failed, consistent with its existing failure semantics.
|
||||
|
||||
```python
|
||||
replacement = current.remap_child([(20, 16, 36, 40)])
|
||||
# Explicitly choose the returned continuation only after success.
|
||||
current.close()
|
||||
current = replacement
|
||||
current.step() # advances the preserved absolute count by one
|
||||
```
|
||||
|
||||
CPU lifecycle mocks cover fresh current-buffer reads, exact transfer, separate
|
||||
ownership, time preservation, ordinary initialization reset, unsupported states
|
||||
and geometry, and candidate/source failure cleanup. GPU tests are predeclared
|
||||
in `tests/validation/multigrid/test_runtime_child_remap_gpu.py`: identity next
|
||||
step bitwise, shifted A→B→A with two intervals between changes, uniform moving
|
||||
and nonequilibrium states, exact CPU remap and overlap, both buffers reset,
|
||||
finite leaves, exact masks and absolute counts. They were not run on the CPU
|
||||
host. The separate independent FP64 capture/replay gate is max population
|
||||
error **3e-6**, with exact masks; remap mass/momentum allow FP32 roundoff.
|
||||
Per-population conservation is not an advancement target under collision.
|
||||
Reference in new issue
Block a user