Commit 8c52609
committed
feat: size_of of live DistArray storage in a World
Adds a ground-truth tile-data accounting facility that finds every live
DistArray of a given type by walking a World's WorldObject registry,
rather than summing size_of over a set of handles. Because each array's
tile storage is a single DistributedStorage WorldObject, an array
referenced by N shallow-copy handles is counted exactly once -- handle
summation double-counts shared storage, which makes it unsuitable as a
cross-check.
API (TiledArray namespace, dist_array.h):
- size_of<S>(const detail::DistributedStorage<T>&)
Tile-data bytes of one storage object (sum of size_of<S>(tile) over
locally-owned, set tiles).
- size_of_live_distarray_storage<DistArrayT, S>(World&)
Walks world.get_object_ids(), recovers each registered pointer as
the common polymorphic base madness::WorldObjectBase, dynamic_casts
to the DistributedStorage matching DistArrayT's tile type (others
skipped), and sums the above.
- size_of_live_distarrays_storage<S, DistArrayTs...>(worlds)
[world][type] matrix of the above.
IMPORTANT: these report the DistributedStorage (tile-data) footprint
ONLY. They exclude the DistArray-level TiledRange, Shape, and Pmap --
those live in the owning ArrayImpl/TensorImpl, not the storage, and are
not reachable from the registered WorldObject. Under SparsePolicy the
Shape (per-tile Frobenius-norm table) can be sizeable, so the result is
NOT comparable term-for-term with a sum of size_of(const DistArray&)
over handles (which includes the shape). Names say "storage" to make
this explicit.
DistributedStorage gains for_each_local_tile(op): applies op to each
locally-owned, set tile -- the same tile set size_of(DistArray)
iterates. The size_of<S>(tile) summation is done by the size_of(storage)
overload in dist_array.h, where the tile-type overloads are visible
(they need not be at the point this low-level header is parsed).
Type-safety rests on WorldObjectBase sitting at offset 0 of every
registered WorldObject; verified that across MADNESS, TiledArray, and
MPQC no WorldObject-derived class has WorldObject as a non-primary base
(the single-inheritance "class X : public WorldObject<X>" idiom). The
recovered base is dynamic_cast, so a wrong type yields nullptr, not UB.
Counts only locally-owned set tiles; excludes remote-tile caches. Call
at a quiescent point (after a fence).
Test (array_suite/live_storage_size_in_world): builds two distinct
arrays plus a shallow copy of one, checks the storage walk equals the
two-array (deduplicated) tile-data total -- not the three-handle sum --
that a ToT-typed walk does not pick up regular-tensor arrays, and the
variadic matrix form. Passes at np=1 and np=2 (CI).1 parent 600c4ad commit 8c52609
3 files changed
Lines changed: 172 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2015 | 2015 | | |
2016 | 2016 | | |
2017 | 2017 | | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
2018 | 2105 | | |
2019 | 2106 | | |
2020 | 2107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
363 | 383 | | |
364 | 384 | | |
365 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1023 | 1088 | | |
1024 | 1089 | | |
1025 | 1090 | | |
| |||
0 commit comments