Repository navigation
Commit 06b7523
committed
Tensor::permute returns an owning tile for arena nested outers
For a Tensor<ArenaTensor<...>> outer tile, permute() rebuilt the outer
cell array in permuted order but rebound the 8-byte cell views onto the
source's slab (arena_permute_shallow), keeping the source alive through
the new tile's deleter. The permuted tile therefore aliased the source.
The expression layer consumes a permuted operand temporary in place
(BinaryWrapper with a consumable left/right: `x(perm) - y` becomes
subt_to on the permuted tile), so the subtraction wrote through into x:
after `z("i,j,q,k;a") = x("q,k,i,j;a") - y("i,j,q,k;a")` the array x was
left corrupted (its norm dropped from 2.5e5 to 1.2e2 in the reproducer,
to 0 in another run). A permute-copy (`y(perm) = x(...)`) and owning
Tensor<Tensor> inners were unaffected.
permute() now copies every cell into a fresh single-page slab in
permuted order (arena_permute_deep), the same ownership rule the generic
Tensor(other, perm) constructor and owning_copy_of() already follow, so a
permuted tile may be consumed without touching its source. The shallow
helper stays for callers that only read the permuted view.
Cost: one slab copy per outer permute of an arena tile. On a mixed
nested-times-flat product whose result the engine permutes this is
visible in isolation (0.13 s -> 0.19 s on the tests' benchmark product);
on an MPQC CSV-CCSD water-8-mer iteration it is within noise (9.4 s ->
9.7 s DF+occupied batched, 3.3 s -> 3.4 s DF batched), with energies
and residual norms unchanged to 12 digits. An rvalue permute for the
engine's own result temporaries could restore the zero-copy path there.
tests/arena_mixed_product_order.cpp: the second case (the reproducer)
now passes; its note is updated.1 parent 282a876 commit 06b7523
3 files changed
Lines changed: 62 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
628 | 672 | | |
629 | 673 | | |
630 | 674 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1710 | 1710 | | |
1711 | 1711 | | |
1712 | 1712 | | |
1713 | | - | |
1714 | | - | |
1715 | | - | |
1716 | | - | |
1717 | | - | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1718 | 1723 | | |
1719 | 1724 | | |
1720 | 1725 | | |
1721 | | - | |
| 1726 | + | |
1722 | 1727 | | |
1723 | 1728 | | |
1724 | 1729 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
0 commit comments