Document FSI-SPH ROCm/HIP tuning on AMD Instinct GPUs - #770
Open
amd-pratmish wants to merge 1 commit into
Open
Conversation
Add Doxygen manual with build/run examples, typical improvement ranges, tuning catalog, and example env snippets for MI300X/MI350X.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds documentation for ROCm / HIP performance tuning of Chrono::FSI-SPH demos on AMD Instinct GPUs (MI300X gfx942, MI350X gfx950). No physics or solver source changes — this PR is documentation only: build/run instructions, tuning knobs, and why each change can improve wall-clock time.
Validated on seven standard FSI-SPH demos: DamBreak, Kernel, ObjectDrop, WaveTank, BaffleFlow, AngleRepose, RassorDrum.
Motivation
FSI-SPH wall time on Instinct is split between GPU kernels (forces, neighbor search, activity), CPU orchestration (MBS coupling, I/O), and ROCm runtime overhead (launches, copies, queues). Default demo settings often leave particle CSV output and every-step neighbor search enabled, which dominates long fluid runs. This PR documents which knobs remove each bottleneck and how to run tuned examples from the command line.
Files added
doxygen/documentation/manuals/fsi/fsi_sph_amd_instinct_tuning.mddoxygen/documentation/manuals/fsi/manual_fsi.mddocs/FSI_SPH_AMD_TUNING.mddocs/fsi_sph_tuning/*.env.exampleBuild all FSI-SPH demos
Run from the build directory so relative data paths (
../data/) resolve.Demo sources:
src/demos/fsi/sph/demo_FSI-SPH_*.cppBaseline ROCm environment
Apply before any tuned run:
HSA_XNACK=0HIP_LAUNCH_BLOCKING=0GPU_MAX_HW_QUEUES=24in combined profiles (see below)Recommended tuning by demo
ps_freq 2HSA_ENABLE_SDMA=0-ffast-mathHIP rebuild--output_particle_data false; do not useps_freq 2ps_freq 2Expected improvement (typical ranges)
Approximate wall-clock reduction vs default demo settings on AMD Instinct. Ranges are indicative — profile on your hardware, ROCm version, and problem size.
Per optimization knob
--output false/--output_particle_data false)--ps_freq 2)ps_freq 2(fluid demos, where stable)HSA_ENABLE_SDMA=0(Kernel micro-benchmark)GPU_MAX_HW_QUEUES=4-O3-ffast-math-amdgpu-early-inline-allPer demo (recommended recipe above)
Unified profile (one binary, all demos): 5–15% on I/O/search-bound fluid demos; 0–2% on RassorDrum; Kernel varies by GPU (see above).
Why these changes are faster
Each knob removes a specific bottleneck on the Instinct timeline:
--output false/--output_particle_data false--ps_freq 2SphCollisionSystem) every step at default. Atps_freq=2rebuild runs every other step; force integration still runs each step. Fluid demos spend large time in search — halving frequency reduces that subsystem cost.HSA_ENABLE_SDMA=0GPU_MAX_HW_QUEUES=4-O3 -ffast-math-mllvm -amdgpu-early-inline-all=true__device__helpers → many launches. Inlining merges them into fewer entry points.Why some demos see little benefit
ps_freq=2: Reduces search work but breaks WCSPH stability (solver abort) — not a usable tradeoff.Tuning catalog (knob → mechanism → command)
1. Skip particle output (demo CLI)
--output false--output_particle_data false--output falseWhy: Removes periodic device→host copies and CSV serialization from the critical path.
Example:
./bin/demo_FSI-SPH_DamBreak --no_vis --quiet --output falseEffect: Largest win on long fluid demos when combined with
ps_freq 2(typical combined range 10–25%).2. Reduced proximity-search frequency (
--ps_freq 2)Maps to
ChFsiFluidSystemSPH::SetNumProximitySearchSteps(2)— rebuild whenm_frame % num_proximity_search_steps == 0.Why: Neighbor search is O(N) (sort + hash grid). Halving rebuild rate reduces that subsystem cost while forces still integrate every step.
Example:
Effect: Major contributor to fluid-demo tuning (typical 5–15% from search cadence alone; stack with I/O off for 10–25%).
Caveat: Do not use on
demo_FSI-SPH_WaveTank— WCSPH aborts with stale neighbors.3. Disable SDMA (
HSA_ENABLE_SDMA=0)Why: Avoids SDMA engine scheduling overhead on micro-benchmark-sized transfers; compute path fits rapid kernel sequences.
Example:
export HSA_ENABLE_SDMA=0 ./bin/demo_FSI-SPH_KernelsEffect: Strongest on MI350-class Kernel runs (typical 25–40%); limited on MI300X fluid demos (0–5%).
4. Hardware queue depth (
GPU_MAX_HW_QUEUES=4)Why: More in-flight ROCm queues → better latency hiding between dependent SPH kernel chains.
Example:
export GPU_MAX_HW_QUEUES=4Effect: Modest alone (0–5%); useful stacked in combined profiles (8–20%).
5. HIP compile flags (requires rebuild)
CMAKE_HIP_FLAGS-O3-O3 -ffast-math-O3 -mllvm -amdgpu-early-inline-all=trueExample:
Tradeoff:
-ffast-mathrelaxes IEEE semantics — validate accuracy.Why RassorDrum ignores compile tuning: HBM-bandwidth saturated; faster instructions do not raise bytes/s.
Per-demo recommended commands
After
cd buildand settingLD_LIBRARY_PATH:./bin/demo_FSI-SPH_DamBreak --no_vis --quiet --output false --ps_freq 2HSA_ENABLE_SDMA=0 ./bin/demo_FSI-SPH_Kernels-ffast-math, then./bin/demo_FSI-SPH_ObjectDrop --no_vis --quiet --output false./bin/demo_FSI-SPH_WaveTank --no_vis --quiet --output_particle_data falseps_freq 2./bin/demo_FSI-SPH_BaffleFlow --no_vis --quiet --output false --ps_freq 2GPU_MAX_HW_QUEUES=4 HSA_ENABLE_SDMA=0 ./bin/demo_FSI-SPH_AngleRepose --no_vis --output false --ps_freq 2./bin/demo_FSI-SPH_RassorDrum --no_visBaseline (untuned) for comparison:
./bin/demo_FSI-SPH_DamBreak --no_vis --quiet ./bin/demo_FSI-SPH_Kernels ./bin/demo_FSI-SPH_AngleRepose --no_vis --output false ./bin/demo_FSI-SPH_RassorDrum --no_visUnified profile (one binary, all seven demos)
When one rebuild must serve all demos:
Then per demo:
--output false --ps_freq 2--output_particle_data falseonly (nops_freq 2)HSA_ENABLE_SDMA=0, no extra CLIThis is a cross-demo compromise: 5–15% on I/O/search-bound fluid cases; 0–2% on HBM-bound RassorDrum; Kernel 0–40% depending on GPU.
Example env snippets
Source before running (see
docs/fsi_sph_tuning/):Important caveats
ps_freq=2changes neighbor-search cadence — validate physics against your reference before production use.demo_FSI-SPH_WaveTankaborts withps_freq=2in tested WCSPH settings.--output_particle_data false, not--output false.-ffast-mathrelaxes IEEE semantics.CMAKE_HIP_ARCHITECTURES(gfx942 vs gfx950) — do not mix libraries and binaries across arches.Test plan
manual_fsi_sph_amd_instinct_tuningunder FSI manualdemo_FSI-SPH_DamBreak --output false --ps_freq 2completes on Instinctdemo_FSI-SPH_WaveTank --output_particle_data falsecompletes withoutps_freq 2HSA_ENABLE_SDMA=0 ./bin/demo_FSI-SPH_Kernelson MI350-class GPUbuild/Non-goals
See also (in-repo after merge)
manual_fsi_sph_amd_instinct_tuning— full manual with code referencesmanual_fsi_sph_parameter_selection— SPH parameter semantics (ps_freq, viscosity, time step)docs/FSI_SPH_AMD_TUNING.md— Markdown quick reference