Commit a98accc
committed
einsum: double-fence each sub-World before destruction (incl. on exception unwind)
Add an inline RAII guard `FenceSubWorldsOnExit` to the generalized-
contraction path of einsum, declared right after the `worlds` vector so
it destructs *before* `worlds` (LIFO) and *after* AB/C. On normal exit
this is a final harmless drain; on exception unwind it drains any
`lazy_sync_children` tasks that ~DistArray scheduled via lazy_deleter
on sub-World taskqs before those sub-Worlds are torn down. Without
this, those tasks survive into the global ThreadPool past ~World, then
trip ~WorldObject's `World::exists(&world)` assertion when an enclosing
scope's fence runs them, masking the real exception with a cryptic
abort.
Two fences per sub-World are required: WorldGopInterface::fence_impl
runs `deferred_->do_cleanup()` only after its task-drain loop, so the
fresh lazy_sync_children tasks the destructors enqueue via lazy_sync
are left pending when the first fence returns; the second fence drains
them. (A single sub-World's ranks all call this collectively, so the
cross-rank lazy_sync handshake matches up correctly. The same trick
would not be safe inside the global fence_impl because main-world
peers have independent shared_ptr refcounts and need not reach the
same do_cleanup in lockstep.)1 parent 8ca1ff2 commit a98accc
1 file changed
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
656 | 689 | | |
657 | 690 | | |
658 | 691 | | |
| |||
0 commit comments