Skip to content
Open
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
5 changes: 3 additions & 2 deletions docs/documentation/amr.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ the memory each group of AMR arrays holds per rank (`[amr-mem]`: block store, ad
registers, the fine IB ghost-point park, and the host-side per-slot IB marker copies). Every block's store column is
sized to the block size cap (`amr_max_grid_size`, or the rank-derived cap) plus ghost layers, so it also prints that column's
size and, per level, the most blocks any rank held over the run, their store, and how much of its column (ghost layers
included, so below 1 even at the cap) a block's interior fills (min, mean, max).
included, so below 1 even at the cap) a block's interior fills (min, mean, max). Each level's row also splits its store into the ghost-layer part and gives its flux registers (one register slot per block), and GPU builds add one line with the device and host totals: every group but the IB marker copies is device-resident and keeps a host mirror.

## Supported physics {#amr-physics}

Expand Down Expand Up @@ -222,7 +222,8 @@ comparable (forces on coarse faces only).
only grow); a missing fine-level file aborts the restart.
- **Nesting.** A level-2 or deeper block lies inside one block of the level above; regrid builds each block's children
inside it, a few coarse cells from its edge. Where a feature crosses the seam between two parent blocks, the children
on the two sides are joined across it when their extents along it are equal (a feature that crosses it squarely):
on the two sides are joined across it when their extents along it are equal (the tag buffer usually makes them so,
also for a disc crossing the seam off its centre):
each is extended to the seam, or, where that would exceed its level's size cap, the gap is filled by a thin block of
its own. Otherwise a strip that wide on each side of the seam stays at the parent's resolution; so does every seam with
immersed boundaries, or with `amr_prolong = 2` on a scheme with fewer
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/validation_amr.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Peak shell-averaged density over \f$\rho_0\f$ at t = 0.16: 3.25 (uniform 96³),
Limits:
- **Early times.** The energy sits in a finite sphere (0.04, 3-13 cells) with a staircase surface, which shifts the virtual origin; the first save (t = 0.02, R = 5.4 r0) carries that and the startup transient. The patch stair-step loses 0.9 % of the energy at 96³/192³ and 0.5 % at 384³; the reference uses the measured energy.
- **Counter-pressure.** \f$p_0 = 10^{-3}\f$ leaves the shock at Mach 33 at the end (\f$\dot R = 0.4 R/t\f$ against \f$c_0 = \sqrt{\gamma p_0/\rho_0}\f$); the strong-shock solution ignores \f$p_0\f$ (an effect of order \f$1/M^2\f$, about 0.1 %, not separated from the discretization error here).
- **Scheme.** WENO5 with `mp_weno = T` went NaN next to the blast at t = 0.004 on a uniform 256³ octant (no AMR), so the check uses MUSCL with minmod. An octant with symmetry walls cannot be refined at the walls (a block must lie `buff_size` cells inside the domain), so the whole sphere is simulated.
- **Scheme.** On a uniform 256³ octant (no AMR), WENO5 with `mp_weno = T` goes NaN at t = 0.0024, at the collapsing centre in the reflective corner: WENO5 has no positivity safeguard there (#2502, as in #2469). With `face_bound = 1` or `2` (see [Positivity](validation_positivity.md)) the same run reaches t = 0.02. The check uses MUSCL with minmod. An octant with symmetry walls cannot be refined at the walls (a block must lie `buff_size` cells inside the domain), so the whole sphere is simulated.
- Save times come from `run_time.inf`, which has four significant digits (0.04 % in R).
- Only the radius and the peak density are checked; the interior profiles are not compared.

Expand Down
3 changes: 2 additions & 1 deletion src/simulation/m_amr_distribution.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ contains
fill(nb) = product(merge(real((amr_region_hi_all(:,k) - amr_region_lo_all(:,k) + 1)*amr_ref_ratio**lev, &
& wp)/real(mbuf_hi - mbuf_lo + 1, wp), 1._wp, amr_dim))
end do
if (nb > 0) call s_mem_note_level(lev, nint(maxval(rc)), fill(1:nb), 2_8*f_amr_col_bytes())
if (nb > 0) call s_mem_note_level(lev, nint(maxval(rc)), fill(1:nb), 2_8*f_amr_col_bytes(), &
& 1._wp - product(merge(real(max_f + 1, wp), 1._wp, amr_dim))/product(real(mbuf_hi - mbuf_lo + 1, wp)))
end do

end subroutine s_amr_note_level_fill
Expand Down
253 changes: 192 additions & 61 deletions src/simulation/m_amr_registers.fpp

Large diffs are not rendered by default.

30 changes: 24 additions & 6 deletions src/simulation/m_phase_timing.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module m_phase_timing
public :: s_phase_tic, s_phase_toc, s_phase_step_tic, s_phase_step_toc, s_phase_report, PH_HALO, PH_GATHER, PH_GFILL, &
& PH_SEAM, PH_RHS, PH_RK, PH_REFLUX, PH_REGRID, PH_COARSE, PH_SWAP, PH_RESTR, PH_LERP, PH_RG_HALO, PH_RG_TAG, PH_RG_CLUS, &
& PH_RG_OWN, PH_RG_MIG, PH_RG_BUILD, PH_RG_REC, s_mem_note, s_mem_note_fields, MEM_STORE, MEM_SCRATCH, MEM_PATCH, &
& MEM_REG, MEM_IB, MEM_IBHOST, s_mem_note_level, s_mem_reset_levels
& MEM_REG, MEM_IB, MEM_IBHOST, s_mem_note_level, s_mem_reset_levels, s_mem_note_reg_slot

integer, parameter :: PH_HALO = 1 !< coarse cons halo exchange (once per stage)
integer, parameter :: PH_GATHER = 2 !< fill waves: coarse-patch gather into every block
Expand Down Expand Up @@ -65,6 +65,8 @@ module m_phase_timing
integer, allocatable :: mem_lev_hw(:)
real(wp), allocatable :: mem_fill_min(:), mem_fill_max(:), mem_fill_sum(:), mem_fill_n(:)
real(wp) :: mem_col_mib = 0._wp
!> Ghost-layer share of one store column (s_mem_note_level) and one block's flux-register slot (s_mem_note_reg_slot).
real(wp) :: mem_ghost_frac = 0._wp, mem_reg_slot_mib = 0._wp

contains

Expand Down Expand Up @@ -147,41 +149,57 @@ contains
do i = 1, MEM_N + 1
print '(A,A8,2F12.1)', '[amr-mem] ', MEM_NAME(i), msum(i)/real(num_procs, wp), mmax(i)
end do
#ifdef MFC_GPU
! every group but the IB marker copies is device-resident and keeps a host mirror
print '(A,F12.1,A,F12.1,A)', '[amr-mem] device ', (msum(MEM_N + 1) - msum(MEM_IBHOST))/real(num_procs, wp), &
& ' MiB mean per rank; host ', msum(MEM_N + 1)/real(num_procs, wp), ' MiB (device arrays keep a host mirror)'
#endif
print '(A,F8.2,A)', '[amr-mem] solver work arrays are allocated ', &
& product(real(idwbuff_alloc%end - idwbuff_alloc%beg + 1, wp))/product(real(idwbuff%end - idwbuff%beg + 1, wp)), &
& 'x the coarse extent (largest block or batch slab)'
if (.not. allocated(mem_lev_hw)) return
print '(A,F10.2,A)', '[amr-mem] per block ', mem_col_mib, ' MiB of store (every block is sized to the size cap)'
print '(A)', '[amr-mem] level blocks/rank store MiB fill min mean max (busiest rank, high-water over regrids)'
print '(A)', &
& '[amr-mem] level blocks/rank store MiB ghost MiB regs MiB fill min mean max (busiest rank, high-water over regrids)'
do i = 1, size(mem_lev_hw)
if (mem_fill_n(i) <= 0._wp) cycle
print '(A,I5,I13,F11.1,3F9.3)', '[amr-mem] ', i, mem_lev_hw(i), mem_lev_hw(i)*mem_col_mib, mem_fill_min(i), &
print '(A,I5,I13,3F11.3,3F9.3)', '[amr-mem] ', i, mem_lev_hw(i), mem_lev_hw(i)*mem_col_mib, &
& mem_lev_hw(i)*mem_col_mib*mem_ghost_frac, mem_lev_hw(i)*mem_reg_slot_mib, mem_fill_min(i), &
& mem_fill_sum(i)/mem_fill_n(i), mem_fill_max(i)
end do

end subroutine s_phase_report

!> Note one regrid's level lev for the per-level table: nmax blocks on the busiest rank, fill(:) the column share of each
!! block's interior, col_bytes one block's store column.
impure subroutine s_mem_note_level(lev, nmax, fill, col_bytes)
impure subroutine s_mem_note_level(lev, nmax, fill, col_bytes, ghost_frac)

integer, intent(in) :: lev, nmax
real(wp), intent(in) :: fill(:)
real(wp), intent(in) :: fill(:), ghost_frac
integer(kind=8), intent(in) :: col_bytes

if (.not. allocated(mem_lev_hw)) then
allocate (mem_lev_hw(amr_max_level), mem_fill_min(amr_max_level), mem_fill_max(amr_max_level), &
& mem_fill_sum(amr_max_level), mem_fill_n(amr_max_level))
mem_lev_hw = 0; mem_fill_min = huge(1._wp); mem_fill_max = 0._wp; mem_fill_sum = 0._wp; mem_fill_n = 0._wp
end if
mem_col_mib = real(col_bytes, wp)/1024._wp**2
mem_col_mib = real(col_bytes, wp)/1024._wp**2; mem_ghost_frac = ghost_frac
mem_lev_hw(lev) = max(mem_lev_hw(lev), nmax)
if (size(fill) == 0) return
mem_fill_min(lev) = min(mem_fill_min(lev), minval(fill)); mem_fill_max(lev) = max(mem_fill_max(lev), maxval(fill))
mem_fill_sum(lev) = mem_fill_sum(lev) + sum(fill); mem_fill_n(lev) = mem_fill_n(lev) + real(size(fill), wp)

end subroutine s_mem_note_level

!> One block's flux-register slot (every direction, coarse and fine sides), for the per-level table.
impure subroutine s_mem_note_reg_slot(bytes)

integer(kind=8), intent(in) :: bytes

mem_reg_slot_mib = real(bytes, wp)/1024._wp**2

end subroutine s_mem_note_reg_slot

!> Forget the per-level notes so far (a restart replaces the initial layout before the first step).
impure subroutine s_mem_reset_levels()

Expand Down
196 changes: 196 additions & 0 deletions tests/49E41590/golden-metadata.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading