Skip to content

Commit 27cd8cc

Browse files
committed
docs: trim reference enumerations to essentials + source-of-truth pointers
1 parent e35a99b commit 27cd8cc

2 files changed

Lines changed: 33 additions & 66 deletions

File tree

.claude/rules/gpu-and-mpi.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,15 @@ compiles to either OpenACC or OpenMP target offload depending on the build flag:
2323

2424
### Key GPU Macros (always use the `GPU_*` prefix)
2525

26-
Inline macros (use `$:` prefix):
27-
- `$:GPU_PARALLEL_LOOP(collapse=N, private=[...], reduction=[...], reductionOp='+')`
28-
Parallel loop over GPU threads. Most common GPU macro.
29-
- `$:END_GPU_PARALLEL_LOOP()` — Required closing for GPU_PARALLEL_LOOP.
30-
- `$:GPU_LOOP(collapse=N, ...)` — Inner loop within a GPU parallel region.
31-
- `$:GPU_ENTER_DATA(create=[...])` — Allocate device memory (unscoped).
32-
- `$:GPU_EXIT_DATA(delete=[...])` — Free device memory.
33-
- `$:GPU_UPDATE(host=[...])` — Copy device → host (before MPI send).
34-
- `$:GPU_UPDATE(device=[...])` — Copy host → device (after MPI receive).
35-
- `$:GPU_ROUTINE(parallelism='[seq]')` — Mark routine for device compilation.
36-
- `$:GPU_DECLARE(create=[...])` — Declare device-resident data.
37-
- `$:GPU_ATOMIC(atomic='update')` — Atomic operation on device.
38-
- `$:GPU_WAIT()` — Synchronization barrier.
39-
40-
Block macros (use `#:call`/`#:endcall`):
41-
- `GPU_PARALLEL(...)` — GPU parallel region (used for scalar reductions like `maxval`/`minval`).
42-
- `GPU_DATA(copy=..., create=..., ...)` — Scoped data region.
43-
- `GPU_HOST_DATA(use_device_addr=[...])` — Host code with device pointers.
26+
Full set with signatures in `parallel_macros.fpp`. The ones you reach for most:
27+
- `$:GPU_PARALLEL_LOOP(collapse=N, private=[...], reduction=[...], reductionOp='+')`
28+
+ `$:END_GPU_PARALLEL_LOOP()` — parallel spatial loop; by far the most common (see pattern below).
29+
- `$:GPU_LOOP(collapse=N, ...)` — inner loop *within* a parallel region.
30+
- `$:GPU_UPDATE(host=[...])` / `$:GPU_UPDATE(device=[...])` — device↔host copies (around MPI; see below).
31+
- `#:call GPU_PARALLEL(...)` — block region for scalar reductions (`maxval`/`minval`).
32+
33+
Others in `parallel_macros.fpp`: `GPU_ENTER_DATA`/`GPU_EXIT_DATA`, `GPU_DECLARE`, `GPU_ROUTINE`,
34+
`GPU_ATOMIC`, `GPU_WAIT`, and the block macros `GPU_DATA`, `GPU_HOST_DATA`.
4435

4536
Typical GPU loop pattern (used 750+ times in the codebase):
4637
```
@@ -108,16 +99,10 @@ Use `#ifdef` for feature, target, compiler, and library gating:
10899
- `MFC_POST_PROCESS` — Only in post_process builds
109100

110101
### Compiler gating (for compiler-specific workarounds)
111-
- `_CRAYFTN` — Cray Fortran compiler
112-
- `__NVCOMPILER_GPU_UNIFIED_MEM` — NVIDIA unified memory (GH-200 / `--unified`)
113-
- `__PGI` — Legacy PGI/NVIDIA compiler
114-
- `__INTEL_COMPILER` — Intel compiler
115-
- `FRONTIER_UNIFIED` — Frontier HPC unified memory
116-
117-
### Library-specific code
118-
- FFTW (`m_fftw.fpp`) uses heavy `#ifdef` gating for `MFC_GPU` and `__PGI`
119-
- CUDA Fortran (`cudafor` module) is gated behind `__NVCOMPILER_GPU_UNIFIED_MEM`
120-
- SILO/HDF5 interfaces may have conditional paths
102+
Compiler/feature macros: `_CRAYFTN`, `__NVCOMPILER_GPU_UNIFIED_MEM` (NVIDIA unified mem, GH-200 /
103+
`--unified`), `__PGI` (legacy PGI/NVIDIA), `__INTEL_COMPILER`, `FRONTIER_UNIFIED`. Library code is
104+
similarly gated (FFTW in `m_fftw.fpp` on `MFC_GPU`/`__PGI`; CUDA Fortran `cudafor` on
105+
`__NVCOMPILER_GPU_UNIFIED_MEM`; SILO/HDF5 paths). Grep the relevant file for exact usage.
121106

122107
When adding new `#ifdef` blocks, always provide an `#else` or `#endif` path so
123108
the code compiles in all configurations (CPU-only, GPU-ACC, GPU-OMP, with/without MPI).

CLAUDE.md

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,29 @@ compilers directly unless you have a specific reason.
2222

2323
All commands run from the repo root via `./mfc.sh`.
2424

25+
Run `./mfc.sh <command> --help` for the full flag set; the most-used invocations:
26+
2527
```bash
26-
# Building
27-
./mfc.sh build -j 8 # Build all 3 targets (pre_process, simulation, post_process)
28-
./mfc.sh build -t simulation -j 8 # Build only simulation
29-
./mfc.sh build --gpu acc -j 8 # Build with OpenACC GPU support
30-
./mfc.sh build --gpu mp -j 8 # Build with OpenMP target offload GPU support
31-
./mfc.sh build --debug -j 8 # Debug build
32-
./mfc.sh build -i case.py --case-optimization -j 8 # Case-optimized build (10x speedup)
33-
34-
# Running
35-
./mfc.sh run case.py -n 4 # Run case with 4 MPI ranks
36-
./mfc.sh run case.py --no-build # Run without rebuilding
37-
./mfc.sh run case.py -e batch -N 2 -n 4 -c phoenix -a ACCOUNT # Batch submit on Phoenix
38-
39-
# Testing
40-
./mfc.sh test -j 8 # Run full test suite (560+ tests)
41-
./mfc.sh test --only 1D -j 8 # Only 1D tests
42-
./mfc.sh test --only 2D Bubbles -j 8 # Only 2D bubble tests
43-
./mfc.sh test --only <UUID> -j 8 # Run one specific test by UUID
44-
./mfc.sh test -l # List all tests with UUIDs and traces
45-
./mfc.sh test -% 10 -j 8 # Run 10% random sample
46-
./mfc.sh test --generate --only <feature> # Regenerate golden files after intentional output change
47-
48-
# Verification (pre-commit CI checks)
49-
./mfc.sh precheck -j 8 # Run all 7 checks (same as CI gate)
50-
./mfc.sh format -j 8 # Auto-format Fortran (.fpp/.f90) + Python
51-
./mfc.sh lint # Ruff lint + Python unit tests
52-
./mfc.sh spelling # Spell check
53-
54-
# Module loading (HPC clusters only — must use `source`)
55-
source ./mfc.sh load -c p -m g # Load Phoenix GPU modules
56-
source ./mfc.sh load -c f -m g # Load Frontier GPU modules
57-
source ./mfc.sh load -c p -m c # Load Phoenix CPU modules
58-
59-
# Other
60-
./mfc.sh validate case.py # Validate case file without running
61-
./mfc.sh params <query> # Search 3,400 case parameters
62-
./mfc.sh clean # Remove build artifacts
63-
./mfc.sh new <name> # Create new case from template
28+
# Build / run / test (-j N = parallel jobs)
29+
./mfc.sh build -j 8 # all 3 targets; flags: -t <target>, --gpu acc|mp, --debug,
30+
# -i case.py --case-optimization (10x speedup)
31+
./mfc.sh run case.py -n 4 # run with 4 MPI ranks; --no-build; -e batch (toolchain/templates/)
32+
./mfc.sh test -j 8 # full suite (560+); --only <1D|Bubbles|UUID>, -l, -% N (sample),
33+
# --generate (regenerate golden files after an intended output change)
34+
35+
# Verify before committing
36+
./mfc.sh precheck -j 8 # all 7 CI lint checks
37+
./mfc.sh format -j 8 # auto-format Fortran (.fpp/.f90) + Python
38+
./mfc.sh lint # ruff lint + Python unit tests (spelling: ./mfc.sh spelling)
39+
40+
# Case files
41+
./mfc.sh validate case.py # validate without running
42+
./mfc.sh params <query> # search 3,400 case parameters
43+
./mfc.sh new <name> # new case from template (clean: ./mfc.sh clean)
6444
```
6545

46+
Module loading (`source ./mfc.sh load -c <slug> -m <mode>`) is covered under System Identification below.
47+
6648
## System Identification and Module Loading
6749

6850
On an HPC cluster, load modules before building: `source ./mfc.sh load -c <slug> -m <mode>`

0 commit comments

Comments
 (0)