flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
weak_swarm Namespace Reference

Functions

 arg (name, default, cast=str)
 tiles (p)
 bubble_seeds ()
 one (timed)
 fmt (v)

Variables

 A = list(sys.argv)
 AR
 BO
 RHO_RATIO
 MU_RATIO
 RHO_L
 G
 D
 RHO_G = RHO_RATIO * RHO_L
 MU_L = np.sqrt(RHO_L * abs(RHO_G - RHO_L) * G * D ** 3) / AR
 MU_G = MU_RATIO * MU_L
int SIGMA = abs(RHO_G - RHO_L) * G * D ** 2 / BO
 SEED
 PERTURB
 N = int(A[1])
 WARM = arg("--warm", 5, int)
 CELLS = arg("--cells", 256, int)
 S = arg("--d-over-h", 20.0, float)
 B = arg("--bubbles-per-axis", 2, int)
 RTOL = arg("--rtol", 1e-8, float)
 LEVELS = arg("--levels", None, int)
 CA = arg("--comm-avoiding", None)
 OUT = arg("--out", None)
 TAG = arg("--tag", "")
 comm = MPI.COMM_WORLD
 rank
 size
str SINGLE = "--single" in A
 TX
 TY
 TZ
 NX
 NY
 NZ
 t_setup0 = time.perf_counter()
 org
 siz
 s = pf.Solver(*siz)
 seeds = bubble_seeds()
 vol = comm.allreduce(sum(b["volume"] for b in s.diagnostics.vof_block_stats()), op=MPI.SUM)
 alpha = vol / (NX * NY * NZ)
 rho_av = RHO_L + (RHO_G - RHO_L) * alpha
 t_setup = comm.allreduce(time.perf_counter() - t_setup0, op=MPI.MAX)
 dts
 iters
 rows
tuple KEYS = ("step", "projection", "momentum", "predictor", "pressure_allreduce")
 file
 stderr
 flush
 w0 = time.perf_counter()
 wall = time.perf_counter() - w0
 R = np.asarray(rows)
 Rmax = np.empty_like(R)
 op
float mean_ms = 1000.0 * Rmax.mean(axis=0)
 h = hashlib.sha256()
 digests = comm.gather(h.hexdigest(), root=0)
 blocks = comm.gather("x".join(map(str, siz)), root=0)
 g = hashlib.sha256()
 ub = sorted(set(blocks))
dict res
 fo
 indent

Detailed Description

Multi-GPU WEAK scaling of a periodic swarm of deformable bubbles (block VoF, momentum advection
on, the case-A groups): a fixed box of cells per rank, tiled along x, then y, then z.

    PYTHONPATH=<PECLET_FLOW_MPI build> \\
        srun --mpi=pmix --ntasks=P --gpus-per-task=1 --gpu-bind=per_task:1 \\
            python tests/study/vof_perf/weak_swarm.py N [--warm W] [--cells n] [--d-over-h D]
                [--bubbles-per-axis B] [--rtol R] [--levels L] [--comm-avoiding MODE] [--single]
                [--out FILE.json] [--tag T]

The case is case A of the bubble-swarm validation (tests/study/case_a on branch case-a: Ar 29.9,
Bo 2, rho_b/rho_l = mu_b/mu_l = 0.1, buoyancy with the mixture weight removed, the volume mean u_x
held at 0 by set_superficial_velocity) with many bubbles instead of one, in CELL units as
prof_mpi.py / run_peclet.build() (D = rho_l = g = 1, lengths scaled by S = d/h: mu' = S^2 mu,
sigma' = S^3 sigma, g' = S g; test_vof_blocks_physical_units.py proves the physical domain equal
to 1e-12). Gravity along -x, triply periodic, starting at rest.

Per rank: an n^3 box (default 256^3) carrying B^3 bubbles (default 2^3 = 8) of diameter d/h cells
(default 20) on a lattice of spacing n/B, each centre perturbed by up to +-PERTURB/2 of the free
gap with the fixed seed SEED. The rank box is tiled (TX, TY, TZ) times, doubling x, then y, then z
(P = 1, 2, 4, 8, 16, 32 -> (1,1,1), (2,1,1), (2,2,1), (2,2,2), (4,2,2), (4,4,2)); every tile carries
the SAME perturbed bubble set, so every rank has the same work when the ORB blocks are the tiles.

--levels L sets the pressure multigrid depth (set_pressure_multigrid(True, L), before the geometry);
without it the solver default (4) is used. At 4 levels a 256^3 box keeps a 32^3-per-rank coarsest
level, which goes to the host GraphAMG bottom (rebuilt every step under variable density).

--comm-avoiding MODE sets diagnostics.set_comm_avoiding(MODE) ('both' | 'off' | 'momentum' |
'pressure') before init_mpi; without it the solver default ('both') is used. The modes are
bit-identical by construction: a measurement of the halo-exchange cost, not of the physics.

At P = 1 the default is the DISTRIBUTED path (init_mpi at size 1, as prof_mpi.py); --single runs the
single-rank solver instead (no mpi_block/init_mpi, as run_mpi.py), the honest one-GPU reference.

W warm-up steps (default 5), then N timed steps, dt = 0.25 min(CFL, capillary) every step (case A).
Rank 0 prints one `RESULT key=value ...` line and, with --out, writes the same numbers as JSON:
ms/step (wall), max-rank step / projection / momentum / predictor / pressure-allreduce ms, pressure
iterations, cells per rank, the ORB block sizes, setup seconds, and `hash`: SHA-256 over every
rank's u, v, w, p, C (rank order) plus the timed dt and iteration sequences -- equal hashes at the
same P are the bit-identity gate across MPI transports (PECLET_CORE_GPU_AWARE_MPI=0/1).

Function Documentation

◆ arg()

weak_swarm.arg ( name,
default,
cast = str )

Definition at line 54 of file weak_swarm.py.

◆ tiles()

weak_swarm.tiles ( p)
Doubling x, then y, then z: p must be a power of two.

Definition at line 84 of file weak_swarm.py.

◆ bubble_seeds()

weak_swarm.bubble_seeds ( )
One rank box's perturbed B^3 lattice (fixed seed), replicated over every tile; cell units.

Definition at line 100 of file weak_swarm.py.

◆ one()

weak_swarm.one ( timed)

Definition at line 165 of file weak_swarm.py.

References one().

Referenced by one().

◆ fmt()

weak_swarm.fmt ( v)

Definition at line 225 of file weak_swarm.py.

Variable Documentation

◆ A

weak_swarm.A = list(sys.argv)

Definition at line 51 of file weak_swarm.py.

◆ AR

weak_swarm.AR

Definition at line 59 of file weak_swarm.py.

◆ BO

weak_swarm.BO

Definition at line 59 of file weak_swarm.py.

◆ RHO_RATIO

weak_swarm.RHO_RATIO

Definition at line 59 of file weak_swarm.py.

◆ MU_RATIO

weak_swarm.MU_RATIO

Definition at line 59 of file weak_swarm.py.

◆ RHO_L

weak_swarm.RHO_L

Definition at line 60 of file weak_swarm.py.

◆ G

weak_swarm.G

Definition at line 60 of file weak_swarm.py.

◆ D

weak_swarm.D

Definition at line 60 of file weak_swarm.py.

◆ RHO_G

weak_swarm.RHO_G = RHO_RATIO * RHO_L

Definition at line 61 of file weak_swarm.py.

◆ MU_L

weak_swarm.MU_L = np.sqrt(RHO_L * abs(RHO_G - RHO_L) * G * D ** 3) / AR

Definition at line 62 of file weak_swarm.py.

◆ MU_G

weak_swarm.MU_G = MU_RATIO * MU_L

Definition at line 63 of file weak_swarm.py.

◆ SIGMA

int weak_swarm.SIGMA = abs(RHO_G - RHO_L) * G * D ** 2 / BO

Definition at line 64 of file weak_swarm.py.

◆ SEED

weak_swarm.SEED

Definition at line 65 of file weak_swarm.py.

◆ PERTURB

weak_swarm.PERTURB

Definition at line 65 of file weak_swarm.py.

◆ N

weak_swarm.N = int(A[1])

Definition at line 67 of file weak_swarm.py.

◆ WARM

weak_swarm.WARM = arg("--warm", 5, int)

Definition at line 68 of file weak_swarm.py.

◆ CELLS

weak_swarm.CELLS = arg("--cells", 256, int)

Definition at line 69 of file weak_swarm.py.

◆ S

weak_swarm.S = arg("--d-over-h", 20.0, float)

Definition at line 70 of file weak_swarm.py.

◆ B

weak_swarm.B = arg("--bubbles-per-axis", 2, int)

Definition at line 71 of file weak_swarm.py.

◆ RTOL

weak_swarm.RTOL = arg("--rtol", 1e-8, float)

Definition at line 72 of file weak_swarm.py.

◆ LEVELS

weak_swarm.LEVELS = arg("--levels", None, int)

Definition at line 73 of file weak_swarm.py.

◆ CA

weak_swarm.CA = arg("--comm-avoiding", None)

Definition at line 74 of file weak_swarm.py.

◆ OUT

weak_swarm.OUT = arg("--out", None)

Definition at line 75 of file weak_swarm.py.

◆ TAG

weak_swarm.TAG = arg("--tag", "")

Definition at line 76 of file weak_swarm.py.

◆ comm

weak_swarm.comm = MPI.COMM_WORLD

Definition at line 77 of file weak_swarm.py.

◆ rank

weak_swarm.rank

Definition at line 78 of file weak_swarm.py.

◆ size

weak_swarm.size

Definition at line 78 of file weak_swarm.py.

◆ SINGLE

str weak_swarm.SINGLE = "--single" in A

Definition at line 79 of file weak_swarm.py.

◆ TX

weak_swarm.TX

Definition at line 96 of file weak_swarm.py.

◆ TY

weak_swarm.TY

Definition at line 96 of file weak_swarm.py.

◆ TZ

weak_swarm.TZ

Definition at line 96 of file weak_swarm.py.

◆ NX

weak_swarm.NX

Definition at line 97 of file weak_swarm.py.

◆ NY

weak_swarm.NY

Definition at line 97 of file weak_swarm.py.

◆ NZ

weak_swarm.NZ

Definition at line 97 of file weak_swarm.py.

◆ t_setup0

weak_swarm.t_setup0 = time.perf_counter()

Definition at line 123 of file weak_swarm.py.

◆ org

weak_swarm.org

Definition at line 127 of file weak_swarm.py.

◆ siz

weak_swarm.siz

Definition at line 127 of file weak_swarm.py.

◆ s

weak_swarm.s = pf.Solver(*siz)

Definition at line 130 of file weak_swarm.py.

◆ seeds

weak_swarm.seeds = bubble_seeds()

Definition at line 146 of file weak_swarm.py.

◆ vol

weak_swarm.vol = comm.allreduce(sum(b["volume"] for b in s.diagnostics.vof_block_stats()), op=MPI.SUM)

Definition at line 149 of file weak_swarm.py.

◆ alpha

weak_swarm.alpha = vol / (NX * NY * NZ)

Definition at line 150 of file weak_swarm.py.

◆ rho_av

weak_swarm.rho_av = RHO_L + (RHO_G - RHO_L) * alpha

Definition at line 151 of file weak_swarm.py.

◆ t_setup

weak_swarm.t_setup = comm.allreduce(time.perf_counter() - t_setup0, op=MPI.MAX)

Definition at line 159 of file weak_swarm.py.

◆ dts

weak_swarm.dts

Definition at line 161 of file weak_swarm.py.

◆ iters

weak_swarm.iters

Definition at line 161 of file weak_swarm.py.

◆ rows

weak_swarm.rows

Definition at line 161 of file weak_swarm.py.

◆ KEYS

tuple weak_swarm.KEYS = ("step", "projection", "momentum", "predictor", "pressure_allreduce")

Definition at line 162 of file weak_swarm.py.

◆ file

weak_swarm.file

Definition at line 183 of file weak_swarm.py.

◆ stderr

weak_swarm.stderr

Definition at line 183 of file weak_swarm.py.

◆ flush

weak_swarm.flush

Definition at line 183 of file weak_swarm.py.

◆ w0

weak_swarm.w0 = time.perf_counter()

Definition at line 184 of file weak_swarm.py.

◆ wall

weak_swarm.wall = time.perf_counter() - w0

Definition at line 188 of file weak_swarm.py.

◆ R

weak_swarm.R = np.asarray(rows)

Definition at line 191 of file weak_swarm.py.

◆ Rmax

weak_swarm.Rmax = np.empty_like(R)

Definition at line 192 of file weak_swarm.py.

◆ op

weak_swarm.op

Definition at line 193 of file weak_swarm.py.

◆ mean_ms

float weak_swarm.mean_ms = 1000.0 * Rmax.mean(axis=0)

Definition at line 194 of file weak_swarm.py.

◆ h

weak_swarm.h = hashlib.sha256()

Definition at line 196 of file weak_swarm.py.

◆ digests

weak_swarm.digests = comm.gather(h.hexdigest(), root=0)

Definition at line 199 of file weak_swarm.py.

◆ blocks

weak_swarm.blocks = comm.gather("x".join(map(str, siz)), root=0)

Definition at line 200 of file weak_swarm.py.

◆ g

weak_swarm.g = hashlib.sha256()

Definition at line 202 of file weak_swarm.py.

◆ ub

weak_swarm.ub = sorted(set(blocks))

Definition at line 207 of file weak_swarm.py.

◆ res

weak_swarm.res
Initial value:
1= {
2 "tag": TAG, "np": size, "path": "single" if SINGLE else "distributed",
3 "gpu_aware_env": os.environ.get("PECLET_CORE_GPU_AWARE_MPI", "unset"),
4 "flow_module": os.path.dirname(pf.__file__), "space": str(getattr(pf, "execution_space", "?")),
5 "grid": [NX, NY, NZ], "tiles": [TX, TY, TZ], "cells_per_rank": CELLS ** 3,
6 "blocks": ub, "d_over_h": S, "bubbles": len(seeds), "alpha": alpha, "rtol": RTOL,
7 "levels": LEVELS if LEVELS is not None else "default",
8 "comm_avoiding": s.diagnostics.comm_avoiding,
9 "warm": WARM, "steps": N, "setup_s": t_setup, "wall_ms": 1000.0 * wall / N,
10 "step_ms": float(mean_ms[0]), "timer_step_ms": float(mean_ms[1]),
11 "proj_ms": float(mean_ms[2]), "momentum_ms": float(mean_ms[3]),
12 "predictor_ms": float(mean_ms[4]), "allreduce_ms": float(mean_ms[5]),
13 "proj_frac": float(mean_ms[2] / mean_ms[0]),
14 "iters_mean": float(np.mean(iters)), "iters_min": int(min(iters)),
15 "iters_max": int(max(iters)), "dt_first": dts[0], "dt_last": dts[-1],
16 "hash": g.hexdigest(),
17 }

Definition at line 208 of file weak_swarm.py.

◆ fo

weak_swarm.fo

Definition at line 233 of file weak_swarm.py.

◆ indent

weak_swarm.indent

Definition at line 233 of file weak_swarm.py.