yasfpy.coupling.cuda_dense#

CUDA implementation of the dense coupling matvec.

This module implements yasfpy.coupling.ops.DenseCouplingOps using Numba’s CUDA backend. It caches device buffers (lookup tables, input/output vectors) and can autotune between kernel strategies for the single-wavelength matvec.

Environment Variables#

The following environment variables influence kernel selection and data movement:

  • YASF_GPU_COUPLING_STRATEGY: auto | thread_row | block_row

  • YASF_GPU_COUPLING_AUTOTUNE: enable/disable autotuning

  • YASF_GPU_COUPLING_AUTOTUNE_REPS: repetitions per strategy candidate

  • YASF_GPU_COUPLING_PIPELINE: enable chunked D2H overlap

  • YASF_GPU_COUPLING_CHUNK_ROWS: chunk size (rows) for pipelining

Notes

The coupling operator is based on VSWF translations as used in multiple-scattering approaches [Waterman, 1971] and in CELES [Egel et al., 2017].

Classes#

CudaDenseCouplingOps

CUDA dense coupling linear operator.

Module Contents#

class yasfpy.coupling.cuda_dense.CudaDenseCouplingOps(sim)#

Bases: yasfpy.coupling.ops.DenseCouplingOps

CUDA dense coupling linear operator.

Parameters:

sim – Simulation instance providing precomputed pairwise lookup tables.

Notes

This implementation caches device memory for lookup tables and uses pinned host buffers for asynchronous copies.

matvec(x, idx=None)#

Compute the dense coupling matvec on the GPU.

Parameters:
  • x – Input array. For multi-wavelength usage, the trailing dimension is the wavelength/channel axis.

  • idx – Optional wavelength/channel index. When provided, uses a single-wavelength kernel (avoids atomics).

Returns:

The product W @ x. If idx is not None, the result is squeezed to drop the singleton channel axis.

Return type:

numpy.ndarray