Skip to main content

Module gpu_backend

Module gpu_backend 

Source
Expand description

Unified GPU backend trait for tile-based FDTD simulation.

This module provides an abstraction layer over CUDA and WGPU backends, enabling GPU-resident state with minimal host transfers.

§Design

The key optimization is keeping simulation state on the GPU:

  • Pressure buffers persist on GPU across steps (no per-step upload/download)
  • Only halo data (64 bytes per tile edge) transfers for K2K messaging
  • Full grid readback only when GUI needs to render

§Buffer Layout

Each tile uses an 18x18 buffer (324 floats = 1,296 bytes):

+---+----------------+---+
| NW|   North Halo   |NE |  <- Row 0 (from neighbor)
+---+----------------+---+
|   |                |   |
| W |   16x16 Tile   | E |  <- Rows 1-16 (owned)
|   |    Interior    |   |
+---+----------------+---+
| SW|   South Halo   |SE |  <- Row 17 (from neighbor)
+---+----------------+---+

Structs§

FdtdParams
Parameters for FDTD computation.
TileGpuBuffers
GPU buffers for a single tile.

Enums§

BoundaryCondition
Boundary condition type for domain edges.
Edge
Edge direction for halo exchange.

Traits§

TileGpuBackend
Unified trait for GPU backends (CUDA and WGPU).

Functions§

buffer_index
Calculate buffer index for interior coordinates (0-indexed).
halo_col_index
Calculate halo column index.
halo_row_start
Calculate halo row index (row 0 or row buffer_width-1).