Commit 9141b2e
committed
DistArray::lazy_deleter: skip lazy_sync when invoked from fence's do_cleanup
Use the new MADNESS `WorldGopInterface::is_in_do_cleanup()` flag to
short-circuit the cross-rank `lazy_sync` handshake when `lazy_deleter`
is called from inside `fence_impl`'s deferred-cleanup phase: `delete
pimpl` directly, decrement `cleanup_counter_`, return.
Why it is safe:
- `fence_impl` runs the global-termination protocol before calling
`deferred_->do_cleanup()`, so all ranks are at the same point with
no AM in flight.
- `defer_deleter_to_next_fence` is, by contract, used collectively, so
every rank's deferred list holds the same set of pimpls at this
point and every rank performs the matching delete in lockstep.
- The `lazy_sync` handshake exists to guarantee that no peer is still
about to send AM addressed to this object before we delete it; the
fence already establishes that.
Why it matters: the original `lazy_sync` path enqueues a
`lazy_sync_children` task on this world's taskq *after* the fence's
drain loop has exited. Such tasks survive the fence and are picked up
later by some other fence that drives the global ThreadPool. If the
world is destroyed in the meantime (e.g. einsum's per-Hadamard
sub-Worlds torn down at function exit or during exception unwind),
the stranded task runs `delete pimpl` against a world whose taskq /
gop are already freed; `~WorldObject` then trips its
`World::exists(&world)` assertion and aborts, masking any real error.
The fast path avoids ever scheduling that task.
The general (non-deferred) path is unchanged: `lazy_deleter` invoked
outside `do_cleanup` still goes through `lazy_sync` because we cannot
rely on synchronization with peers in that case.1 parent 7d18300 commit 9141b2e
1 file changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
483 | 501 | | |
484 | 502 | | |
485 | 503 | | |
| |||
0 commit comments