Appearance
MPI and clusters
Recipes for running on more than one rank, on a workstation and under a batch scheduler. The GPU-specific settings are in GPU.
C1. Run on several ranks
Problem. Run a case with MPI.
Command (the FLUME Sod tube, src/tests/flume/regression/sod-x):
bash
cd src/tests/flume/regression/sod-x
mpirun -np 4 ../../../../../exe/adam_flume_cpu input.iniThe executable takes the input file as its only argument (default input.ini); a file with a [forest] section is a multi-realm manifest (forest R0). Each rank writes its own -procNNNNNN.h5 field files and -procNNNNNN.fbd restart files.
What you get. The blocks are spread over the ranks by Morton order, in whole sibling families. A grid with fewer families than ranks leaves ranks with no block: that is supported (they take part in every collective and do no work), not an error, on both backends (ranks without blocks). A restart needs the rank count it was saved with; more or fewer ranks stop the run, unless the FLUME files are repartitioned first (repartition.py, IO4).
Reference. [amr] iu_ref_levels (the family distribution).
C2. A batch job
Problem. Run under Slurm on a cluster node.
Job (the shape of src/tests/flume/speedup/jobs/medooza-cpu.slurm and medooza-fnl.slurm, with the site names removed):
bash
#!/bin/bash
#SBATCH --job-name=flume-cpu
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --mem=96G
#SBATCH --time=02:00:00
set -euo pipefail
# load the toolchain the executable was built with (the varset's compiler and MPI)
srun --mpi=pmix --cpu-bind=cores -n "$SLURM_NTASKS" ./adam_flume_cpu input.iniFor FNL, one rank per GPU:
bash
#SBATCH --gres=gpu:4
#SBATCH --ntasks-per-node=4
srun --mpi=pmix -n "$SLURM_NTASKS" ./adam_flume_fnl input.iniUnder PBS Pro (ESA SpaceHPC, src/tests/flume/speedup/jobs/spacehpc-fnl.pbs), one rank per GPU on whole nodes:
bash
#PBS -l select=2:ngpus=4:ncpus=96:mpiprocs=4:mem=400gb
#PBS -l place=excl
module purge; module load nvhpc-hpcx-cuda12/26.3
mpirun -machinefile "$PBS_NODEFILE" --map-by ppr:4:node -np 8 ./adam_flume_fnl input.iniOpen MPI forwards to the ranks only the environment variables named with -x; PBS passes no arguments to a job script (the speedup jobs read a plan file named in -v).
Rules.
- Check the GPUs before timing. A GPU with a hardware power brake or thermal slowdown runs several times slower without an error (an H100 at 495 of 1980 MHz was 4.3 times slower): read
nvidia-smi --query-gpu=clocks_event_reasons.active,enforced.power.limiton every node first, asspacehpc-fnl.pbsdoes. - Same toolchain at run time as at build time. Load the compiler and MPI of the varset the executable was built with; HDF5 and the MPI Fortran modules are compiler-specific.
- Give
--mem. On the CPU backend a rank's block budget is the node's memory, capped by the job's cgroup limit (what--memsets), divided by the ranks on the node (mpih_object,src/lib/common/adam_mpih_object.F90); on FNL it is the device memory. - GPU binding. FUNDAL picks device
mod(local_rank, visible devices)on each node. With one rank per GPU andsrun --gpu-bind(or one visible device per task) every rank gets its own GPU; ranks that see the same device share it, and the block budget is divided among them (count_device_sharers), so they never oversubscribe it. - Open MPI 5 with hcoll on some clusters segfaults in
MPI_Finalize(exit 139) after a correct run. Disable it withexport OMPI_MCA_coll_hcoll_enable=0; the regression harnesses fail a case whose run exits non-zero, so a crash at finalize does not pass unseen.
Reference. GPU5 for the settings that belong to a WSL2 workstation only.
C3. Workstation (WSL2) and cluster settings are not interchangeable
Problem. Know which environment settings belong where.
The WSL2 workstation settings, and what to use instead on a cluster, are in GPU5; never copy them into a job script.
AMD GPUs (OpenMP offload). The FNL ghost exchange posts MPI directly on device buffers, so the MPI must be ROCm-aware. Without it a run is correct and very slow, with no warning. Measured on 8 MI300X, FLUME profile-couette3d large, Open MPI 5.0.10: 209 s with the default transport, 9.3 s with
bash
export OMPI_MCA_pml=ucx OMPI_MCA_osc=ucx
export UCX_TLS=self,sm,rocm # or self,sm,rocm_copy,rocm_ipc: the same time
export HSA_ENABLE_IPC_MODE_LEGACY=1
export UCX_MAX_RNDV_RAILS=1These settings come from one cluster (Thera, Open MPI built with UCX and ROCm): check them against your site's. If a multi-rank run is much slower than the kernels explain, check the transport first.
Reference. GPU5.