Skip to content

feat(gpu): the weather's air pressure and inverse barometer on the device (P2.7 Phase 4.5i) - #283

Open
EmilLindfors wants to merge 1 commit into
feat/gpu-3d-surface-fluxesfrom
feat/gpu-weather
Open

EmilLindfors wants to merge 1 commit into
feat/gpu-3d-surface-fluxesfrom
feat/gpu-weather

Conversation

@EmilLindfors

Copy link
Copy Markdown
Owner

P2.7 Phase 4.5i (notes/gpu.md). Stacked on #282 (4.5h): merge that first, then retarget this to main.

A 3D case with weather now runs on the GPU. Before, it stopped on the device before its first step, for two reasons:

  • its 2D module carries the weather's air pressure (GriddedAtmosphere2D::split_for_3d: the pressure gradient on the depth mean; the wind goes to the columns);
  • the case runner raises the open boundaries by the inverse barometer (InverseBarometer).

Neither had a device form. This was TODO P2.7's "the weather's device form", which 2D runs lacked too.

dgcom (the CPU's bits unchanged: the same arithmetic, moved into functions both sides call)

  • The source. DeviceSource2D::Atmosphere (GriddedAtmosphere2D::device_form). New for a device:
    • regridded(t): a snapshot on the mesh nodes; the CPU's cache, was private;
    • moment(t): the time stencil and the ramp;
    • switches, constants (AtmosphereConstants), has_level, is.
  • Pointwise functions, for the CPU and the device: add_snapshot, atmosphere_source ((τ − h∇p)/ρ) and inverse_barometer_level.
  • The boundary.
    • BoundaryLevel::device_form returns DeviceLevel::Atmosphere.
    • ExternalStateProvider::device_raise is new. InverseBarometer's device form is its provider's, raised by its level times its factor. It has none if the provider is raised already or the level has no form.
    • DeviceBoundary2D::Characteristic carries the raise.
  • DragCoefficient::{device_code, from_device_code}.
  • New unit test the_inverse_barometer_raises_its_providers_device_form.

The device (gpu/src/swe2d.rs)

  • The snapshots. Weather keeps them regridded in four device slots, as the CPU caches four.
    • A snapshot no slot holds goes into the slot read longest ago, never one the same RHS reads.
    • The upload is synchronous: the queued kernels have read the slot by then, and it happens only at the weather's hourly snapshots.
    • A level's row of the moments carries the weather's ramp, count, slots and weights.
  • The source. atmosphere_forcing is a kernel after the element kernels, where the CPU's list of sources puts it. Post runs the relaxation bands and the weather in the list's order (the case runner's is Coriolis, the bands, the weather). It calls dgcom's add_snapshot and atmosphere_source.
  • The boundary. The boundary kernel raises an open boundary's external η by the factor times the level at the face node (dgcom's inverse_barometer_level). It works on any external form: uniform, tides or parent.
  • Refused, by name:
    • The wind stress on the depth mean. Only 2D runs have it; a 3D run hands the wind to its columns. Its speed is the platform's hypot on the CPU, and math::hypot would change the CPU's bits of every weather run. That is your call, parked in the notes.
    • Two weather models.

Gates

  • dgcom-gpu weather (new, also in all; no NetCDF needed). nest's channel under a made-up 15 hPa low crossing it, 6 h, global steps and 3 levels: bit for bit, every node.
    • Configuration 1: an M2 tide raised by the full inverse barometer.
    • Configuration 2: nest's parent raised by a quarter of it, the band, then the pressure.
    • 4 mutants caught: no pressure source, the inverse barometer at half, the weather ramped over an hour, no inverse barometer.
  • Frøya in 3D with weather, through the case runner, CPU against the RTX 4060 (--no-fmad). The case is cases/froya/rivers_3d.toml (the NorKyst parent, nine rivers) with --set 'atmosphere.files=["../../data/froya_met_heat.nc"]' (MET Nordic's wind and heat budget; COARE 3.5 into Jerlov III), 2 h. Bit for bit:
    • 120 steps, Mausund's 65 records, the 89 MB snapshot and the volume;
    • the same with boundary.0.inverse_barometer=0.25, the end volume another (the level acts).
  • dgcom's tests around these pass (atmosphere, boundaries, wind: 54; the case runner's device recorders: 3). Clippy and rustfmt are clean.

🤖 Generated with Claude Code

…vice (P2.7 Phase 4.5i)

A 3D case with weather stopped on the device before its first step: its
2D module carries the weather's air pressure (GriddedAtmosphere2D's
pressure gradient on the depth mean), and the case runner raises the
open boundaries by the inverse barometer. Neither had a device form.

- dgcom (the CPU's bits unchanged): `DeviceSource2D::Atmosphere`;
  `GriddedAtmosphere2D::{regridded, moment, switches, constants,
  has_level, is}`; the pointwise `add_snapshot`, `atmosphere_source`,
  `inverse_barometer_level`, which the CPU calls too;
  `BoundaryLevel::device_form` (`DeviceLevel`),
  `ExternalStateProvider::device_raise`, `InverseBarometer`'s device form
  (its provider's, raised), `DeviceBoundary2D::Characteristic { raise }`;
  `DragCoefficient::{device_code, from_device_code}`.
- gpu: the regridded snapshots in four device slots (`Weather`), a
  level's moment with their slots and weights; `atmosphere_forcing` after
  the element kernels in the CPU's order of the sources (`Post`); the
  boundary kernel raises an open boundary's external level by the
  inverse barometer at the face node. Refused by name: the wind stress on
  a 2D run's depth mean (the CPU's speed is the platform's hypot), two
  weather models.

Gates: `dgcom-gpu weather` (new, in `all`): a low crossing `nest`'s
channel, a tide raised by the full inverse barometer and the parent
raised by a quarter with its band, global steps and 3 levels: bit for
bit, 4 mutants caught. Frøya in 3D with MET Nordic's wind and heat
budget through the case runner, CPU against the RTX 4060, 2 h (and with
`boundary.0.inverse_barometer=0.25`): stations, snapshot and volume bit
for bit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant