Commit 1910acc
committed
einsum: fence sub-Worlds 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.
One fence per sub-World suffices because lazy_deleter now bypasses
lazy_sync when invoked from `do_cleanup` (gated by
`world.gop.is_in_do_cleanup()`): the deferred-cleanup path performs
direct deletes rather than scheduling cross-rank tasks. The remaining
tasks this fence has to drain come only from non-deferred ~DistArray
calls (e.g. AB during exception unwind), and all participating ranks
of a sub-World reach this RAII guard in lockstep so their lazy_sync
handshakes match up.1 parent 9141b2e commit 1910acc
1 file changed
Lines changed: 32 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 | + | |
656 | 688 | | |
657 | 689 | | |
658 | 690 | | |
| |||
0 commit comments