Skip to content

Commit 67b522b

Browse files
chongchongheclaude
andauthored
quokka script: add HIP/CUDA GPU and 2D presets (#1889)
### Description Extends the `quokka` helper script with GPU backend presets (`-hip`, `-cuda`) and 2D presets, enabling one-step configure/build/run workflows on GPU clusters without manually passing `-DAMReX_GPU_BACKEND=...` to CMake. New presets follow the pattern `<dim>-<backend>`: `1d-hip`, `2d-hip`, `3d-hip`, `1d-cuda`, `2d-cuda`, `3d-cuda`. The `parse_preset` function is also refactored to a compact inline-assignment form, and the build directory name now always matches the preset string (e.g. `build/3d-hip/`) instead of a separate `BUILD_NAME` variable. ### Related issues N/A ### Checklist _Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an `x` inside the square brackets `[ ]` in the Markdown source below:_ - [x] I have added a description (see above). - [x] I have added a link to any related issues (if applicable; see above). - [x] I have read the [Contributing Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md). - [ ] I have added tests for any new physics that this PR adds to the code. - [ ] *(For quokka-astro org members)* I have manually triggered the GPU tests with the magic comment `/azp run`. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 98b05ca commit 67b522b

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Core C++20 sources live in `src/`, with physics modules under `hydro/`, `radiation/`, `cooling/`, and `chemistry/`. Shared infrastructure such as `QuokkaSimulation.cpp` sits alongside module code, while scenario drivers compile from `src/problems/`. Runtime inputs (`*.in`) land in `inputs/`, docs in `docs/`, and helper utilities in `scripts/`. Generated builds and intermediates belong in `build/`; regression baselines and plotfiles stay under `tests/` and are tracked through `regression/quokka-tests.ini`.
55

66
## Build, Test, and Development Commands
7-
Prefer the `quokka` CLI in `scripts/bash/quokka` for routine workflows. Commands accept `-d <preset>` (`1d`, `3d`, `1d-debug`, `3d-debug`) and default to `QUOKKA_PRESET` when it is set, otherwise `1d`. Configure with `quokka config [-d <preset>]`, adding `--delete` when reconfiguring an existing preset build directory; `config` also accepts extra CMake definitions via repeatable `-D<k>=<v>` flags. Build one or more problems with `quokka build [-d <preset>] <problem> [<problem> ...]` or by glob with `quokka build [-d <preset>] --filter <glob>`. Run problem executables with `quokka run [-d <preset>] <problem>` (optionally `--input <file>` and `--fpe`), run CTest suites with `quokka run [-d <preset>] -j <N>` or `quokka run [-d <preset>] --filter <regex>`, and use `quokka buildrun --filter <pattern>` to build and run the same matched problem/test selection. List problems with `quokka list`, inspect targets with `quokka target [-d <preset>]`, and clean generated test outputs with `quokka clean`. Use `--source <file>` on `config/build/buildrun/run/target` when environment setup is required per command.
7+
Prefer the `quokka` CLI in `scripts/bash/quokka` for routine workflows. Commands accept `-d <preset>` (`1d`, `2d`, `3d`, `1d-debug`, `2d-debug`, `3d-debug`, `1d-hip`, `2d-hip`, `3d-hip`, `1d-cuda`, `2d-cuda`, `3d-cuda`) and default to `QUOKKA_PRESET` when it is set, otherwise `1d`. Configure with `quokka config [-d <preset>]`, adding `--delete` when reconfiguring an existing preset build directory; `config` also accepts extra CMake definitions via repeatable `-D<k>=<v>` flags. Build one or more problems with `quokka build [-d <preset>] <problem> [<problem> ...]` or by glob with `quokka build [-d <preset>] --filter <glob>`. Run problem executables with `quokka run [-d <preset>] <problem>` (optionally `--input <file>` and `--fpe`), run CTest suites with `quokka run [-d <preset>] -j <N>` or `quokka run [-d <preset>] --filter <regex>`, and use `quokka buildrun --filter <pattern>` to build and run the same matched problem/test selection. List problems with `quokka list`, inspect targets with `quokka target [-d <preset>]`, and clean generated test outputs with `quokka clean`. Use `--source <file>` on `config/build/buildrun/run/target` when environment setup is required per command.
88

99
Raw CMake/Ninja/CTest commands remain supported: configure once per build tree with `cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DAMReX_SPACEDIM=3`, build via `cmake --build build --target all` (or `ninja -C build`), inspect targets using `cmake --build build --target help`, and run tests via `ctest --output-on-failure` or `ctest -R <Pattern>`. Apply clang-tidy to staged changes through `scripts/tidy.sh build changed`.
1010

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The script optionally sources an environment file via `--source <file>` for comm
2424
- **Clean test output**: `quokka clean`
2525
- **Result summary**: `build`, `run`, and `buildrun` always print final per-target summary lines (`<name> SUCCESS|FAIL|SKIPPED`), so tooling/agents can reliably inspect outcomes by tailing the command output.
2626

27-
Presets: `1d`, `3d`, `1d-debug`, `3d-debug` (sets dimensionality and Release/Debug build type). Default preset is `1d`.
27+
Presets: `1d`, `2d`, `3d`, `1d-debug`, `2d-debug`, `3d-debug`, `1d-hip`, `2d-hip`, `3d-hip`, `1d-cuda`, `2d-cuda`, `3d-cuda` (sets dimensionality, Release/Debug build type, and optional GPU backend). Default preset is `1d`.
2828

2929
**Without the script (manual):**
3030
- **Configure**: `mkdir -p build/<preset> && cd build/<preset> && cmake ../.. -G Ninja -DCMAKE_BUILD_TYPE=<type> -DAMReX_SPACEDIM=<N>`

scripts/bash/quokka

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ Environment:
4343
4444
Presets:
4545
1d 1D Release build
46+
2d 2D Release build
4647
3d 3D Release build
4748
1d-debug 1D Debug build
49+
2d-debug 2D Debug build
4850
3d-debug 3D Debug build
51+
1d-hip 1D Release build with HIP GPU backend
52+
2d-hip 2D Release build with HIP GPU backend
53+
3d-hip 3D Release build with HIP GPU backend
54+
1d-cuda 1D Release build with CUDA GPU backend
55+
2d-cuda 2D Release build with CUDA GPU backend
56+
3d-cuda 3D Release build with CUDA GPU backend
4957
EOF
5058
}
5159

@@ -126,34 +134,27 @@ _require_no_delete() { [ "$DELETE_BUILD_DIR" -eq 0 ] || die "'${COMMAND}' does
126134

127135
parse_preset() {
128136
local preset="$1"
137+
GPU_BACKEND=""
129138

130139
case "$preset" in
131-
1d)
132-
DIM=1
133-
BUILD_TYPE=Release
134-
BUILD_NAME=1d
135-
;;
136-
3d)
137-
DIM=3
138-
BUILD_TYPE=Release
139-
BUILD_NAME=3d
140-
;;
141-
1d-debug)
142-
DIM=1
143-
BUILD_TYPE=Debug
144-
BUILD_NAME=1d-debug
145-
;;
146-
3d-debug)
147-
DIM=3
148-
BUILD_TYPE=Debug
149-
BUILD_NAME=3d-debug
150-
;;
140+
1d) DIM=1; BUILD_TYPE=Release ;;
141+
2d) DIM=2; BUILD_TYPE=Release ;;
142+
3d) DIM=3; BUILD_TYPE=Release ;;
143+
1d-debug) DIM=1; BUILD_TYPE=Debug ;;
144+
2d-debug) DIM=2; BUILD_TYPE=Debug ;;
145+
3d-debug) DIM=3; BUILD_TYPE=Debug ;;
146+
1d-hip) DIM=1; BUILD_TYPE=Release; GPU_BACKEND=HIP ;;
147+
2d-hip) DIM=2; BUILD_TYPE=Release; GPU_BACKEND=HIP ;;
148+
3d-hip) DIM=3; BUILD_TYPE=Release; GPU_BACKEND=HIP ;;
149+
1d-cuda) DIM=1; BUILD_TYPE=Release; GPU_BACKEND=CUDA ;;
150+
2d-cuda) DIM=2; BUILD_TYPE=Release; GPU_BACKEND=CUDA ;;
151+
3d-cuda) DIM=3; BUILD_TYPE=Release; GPU_BACKEND=CUDA ;;
151152
*)
152153
die "unsupported preset '${preset}'"
153154
;;
154155
esac
155156

156-
BUILD_DIR="${ROOT}/build/${BUILD_NAME}"
157+
BUILD_DIR="${ROOT}/build/${preset}"
157158
}
158159

159160
resolve_root() {
@@ -177,6 +178,9 @@ configure_build() {
177178
cd "$BUILD_DIR"
178179

179180
cmake_args=(../.. -G Ninja "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" "-DAMReX_SPACEDIM=${DIM}")
181+
if [ -n "$GPU_BACKEND" ]; then
182+
cmake_args+=("-DAMReX_GPU_BACKEND=${GPU_BACKEND}")
183+
fi
180184
if [ "${#CMAKE_DEFINES[@]}" -gt 0 ]; then
181185
cmake_args+=("${CMAKE_DEFINES[@]}")
182186
fi
@@ -534,6 +538,7 @@ JOBS=8
534538
CMAKE_DEFINES=()
535539
FILTER_MATCHED_PROBLEMS=()
536540
FILTER_MATCHED_TESTS=()
541+
GPU_BACKEND=""
537542

538543
while [ "$#" -gt 0 ]; do
539544
case "$1" in

0 commit comments

Comments
 (0)