Commit 9fb198d
committed
Replace read-everywhere checkpoint reads with swarm-routed reads
MeshVariable.read_timestep and SwarmVariable.read_timestep both used to
have every rank h5py-open the saved file and build a rank-local KDTree
over the *full* saved field. PR underworldcode#146 measured 3.92 TB resident at 1152
ranks for a 1/128 spherical case driven by exactly this pattern.
Both methods now use a transient swarm to route saved (coord, value)
pairs to the rank that owns each location. Per-rank memory is bounded
by file_size / n_ranks instead of file_size per rank.
Two pieces:
* Swarm._route_by_nearest_centroid() (new, swarm.py) — deterministic
centroid-distance routing. Bypasses Swarm.migrate's points_in_domain
test, which can return True on multiple ranks for vertex DOFs sitting
on a partition boundary (owner + ghost). With this routing rule the
destination is a pure function of the coordinate, so a saved point
and a query at the same coord always land on the same rank.
* MeshVariable.read_timestep — round-trip pattern with two transient
swarms. Source swarm carries (coord, saved_value); rank 0 reads the
file once and ships chunks via the centroid router. Query swarm
carries each rank's live DOF coordinates, also routed by centroid.
The interpolation runs rank-local against the landed source data,
then results migrate back to the live DOF's home rank via the bare
DMSwarm migrate idiom (rank-stamped, no validation).
* SwarmVariable.read_timestep — same recipe, single direction (the
live swarm's particles already have a known home; the source data is
routed to where the live particles landed, then a rank-local KDTree
fills in the values).
The serial round-trip tests (tests/test_0003_save_load.py) pass exactly
as before. New parallel test ptest_0762_read_timestep_swarm_routed.py
exercises the MeshVariable parallel round-trip on 2 ranks; the matching
SwarmVariable parallel test is skipped because Swarm.write_timestep
itself hangs in parallel — a pre-existing issue unrelated to read.
Underworld development team with AI support from Claude Code1 parent d004787 commit 9fb198d
3 files changed
Lines changed: 303 additions & 87 deletions
File tree
- src/underworld3
- discretisation
- tests/parallel
Lines changed: 121 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
1155 | 1157 | | |
1156 | 1158 | | |
1157 | 1159 | | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1161 | 1164 | | |
1162 | | - | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1163 | 1171 | | |
1164 | | - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1165 | 1179 | | |
1166 | | - | |
1167 | | - | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
1168 | 1183 | | |
1169 | 1184 | | |
1170 | 1185 | | |
1171 | 1186 | | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
| 1187 | + | |
1176 | 1188 | | |
1177 | 1189 | | |
1178 | 1190 | | |
1179 | 1191 | | |
1180 | 1192 | | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1190 | 1207 | | |
1191 | | - | |
| 1208 | + | |
| 1209 | + | |
1192 | 1210 | | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
1193 | 1257 | | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
1228 | 1263 | | |
1229 | | - | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1230 | 1267 | | |
1231 | | - | |
| 1268 | + | |
1232 | 1269 | | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1237 | 1286 | | |
1238 | | - | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
1239 | 1293 | | |
1240 | | - | |
1241 | | - | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1242 | 1299 | | |
1243 | 1300 | | |
1244 | 1301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1910 | 1910 | | |
1911 | 1911 | | |
1912 | 1912 | | |
1913 | | - | |
1914 | | - | |
1915 | | - | |
1916 | | - | |
1917 | | - | |
1918 | | - | |
1919 | | - | |
1920 | | - | |
1921 | | - | |
1922 | | - | |
1923 | | - | |
1924 | | - | |
1925 | | - | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
1926 | 1929 | | |
1927 | | - | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
1928 | 1933 | | |
1929 | 1934 | | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
1930 | 1951 | | |
1931 | | - | |
1932 | | - | |
1933 | | - | |
1934 | | - | |
1935 | | - | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
1936 | 1956 | | |
1937 | | - | |
1938 | | - | |
| 1957 | + | |
| 1958 | + | |
1939 | 1959 | | |
1940 | | - | |
| 1960 | + | |
| 1961 | + | |
1941 | 1962 | | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
1942 | 1971 | | |
1943 | | - | |
| 1972 | + | |
1944 | 1973 | | |
1945 | 1974 | | |
1946 | 1975 | | |
| |||
2557 | 2586 | | |
2558 | 2587 | | |
2559 | 2588 | | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
2560 | 2619 | | |
2561 | 2620 | | |
2562 | 2621 | | |
| |||
0 commit comments