Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/documentation/amr.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ owner and the ranks it overlaps. All exchanges are posted in a fixed order, so r

On GPUs every block array is device-resident. A rank advances its blocks of equal level in batches stacked along the
last dimension, one solver call per batch; this is why AMR needs a uniform Cartesian grid. The toolchain enables
`amr_device_pack` (fused exchange kernels) when `amr_max_grid_size <= 64` and sets `amr_snap = min(2, amr_buf - 2)`
`amr_device_pack` (fused exchange kernels) and sets `amr_snap = min(2, amr_buf - 2)`
(regrid hysteresis) under dynamic regrid, unless they are set explicitly.

`rank_time_wrt = T` prints a per-phase time budget of the AMR step, the block-balance report, and at the end of the run
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ uniform Cartesian grid.
| `amr_prolong` | Integer | Prolongation: 1 limited linear, 2 quartic with a positivity fallback (default 1) |
| `amr_place_owner` | Logical | Place each block on the rank owning most of its coarse cells (default F) |
| `amr_snap` | Integer | Regrid hysteresis in coarse cells, <= `amr_buf - 2` (default 0; set by the toolchain under regrid) |
| `amr_device_pack` | Logical | Fused device pack/unpack of the coarse-patch exchange (default F; set by the toolchain when `amr_max_grid_size <= 64`) |
| `amr_device_pack` | Logical | Fused device pack/unpack of the coarse-patch exchange (default F; set by the toolchain for every AMR case) |

Each save writes the block hierarchy and fine solution next to the level-0 restart data; a restart reads the block
geometry from it, not from `amr_block_beg`/`amr_block_end`.
Expand Down
9 changes: 2 additions & 7 deletions toolchain/mfc/case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3906,8 +3906,6 @@ def _format_errors(self) -> str:

# AMR defaults the toolchain derives for a case that leaves them unset. The Fortran defaults stay off on purpose: a
# default set there bypasses every rule above, so the decision lives here, under the same prohibitions.
# The fused pack/unpack is derived only up to cap 64 (many small blocks).
DEVICE_PACK_MAX_CAP = 64
# Regrid hysteresis under dynamic regrid when the tag buffer leaves room (amr_snap <= amr_buf - 2).
SNAP_DEFAULT = 2

Expand All @@ -3917,13 +3915,10 @@ def apply_amr_defaults(params: Dict[str, Any]) -> bool:
simulation validation with them on. Returns True when they were applied."""
if params.get("amr", "F") != "T":
return False
defaults: Dict[str, Any] = {}
if 0 < int(params.get("amr_max_grid_size", 0)) <= DEVICE_PACK_MAX_CAP:
defaults["amr_device_pack"] = "T"
# fused exchange kernels: faster at every block size measured (Frontier MI250X, 8-512 GPUs)
defaults: Dict[str, Any] = {"amr_device_pack": "T"}
if int(params.get("amr_regrid_int", 0)) > 0 and int(params.get("amr_buf", 3)) - 2 >= 1:
defaults["amr_snap"] = min(SNAP_DEFAULT, int(params.get("amr_buf", 3)) - 2)
if not defaults:
return False
trial = dict(params)
trial.update({k: params.get(k, v) for k, v in defaults.items()})
try:
Expand Down
9 changes: 5 additions & 4 deletions toolchain/mfc/test_case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,11 @@ class TestAmrDefaults(unittest.TestCase):
def test_admissible_amr_case_gets_defaults(self):
p = dict(self.AMR)
self.assertTrue(apply_amr_defaults(p))
self.assertEqual(p["amr_device_pack"], "T") # cap 16 <= DEVICE_PACK_MAX_CAP
q = {**self.AMR, "amr_max_grid_size": 96}
self.assertFalse(apply_amr_defaults(q)) # static block above the cap: nothing to derive
self.assertNotIn("amr_device_pack", q)
self.assertEqual(p["amr_device_pack"], "T")
for cap in (96, 0): # large or rank-derived blocks get the fused kernels too
q = {**self.AMR, "amr_max_grid_size": cap}
self.assertTrue(apply_amr_defaults(q))
self.assertEqual(q["amr_device_pack"], "T")
r = {**self.AMR, "amr_device_pack": "F"}
self.assertTrue(apply_amr_defaults(r))
self.assertEqual(r["amr_device_pack"], "F")
Expand Down
Loading