Skip to content

Add OpenCL + CUDA GPU wind-tunnel solvers - #2

Merged
leonardoaraujosantos merged 1 commit into
mainfrom
feat/gpu-wind-tunnel
Jul 5, 2026
Merged

leonardoaraujosantos merged 1 commit into
mainfrom
feat/gpu-wind-tunnel

Conversation

@leonardoaraujosantos

Copy link
Copy Markdown
Contributor

Summary

Real GPU acceleration for the 3D wind tunnel, plus the Swift binding and README examples.

Key finding this addresses: the forEachIndex(n, f) backend seam takes a host lambda and
cannot dispatch to a GPU (the gpu_stubs.hpp structs just ran it serially on the CPU). GPU
acceleration is therefore implemented as bespoke device-kernel solvers, validated against
the fp64 CPU WindTunnel3D oracle.

What's included

  • OpenCL wind tunnel (WindTunnelOpenCL): collide + stream_bc device kernels,
    populations resident on the GPU (ping-pong buffers), fp64 host read-back. Validated on an
    Apple M2 Max
    : Linf/Uin ≈ 1e-5 vs the CPU oracle, deterministic, no-slip preserved;
    ~1.35 GLUPS (≈290× the serial macOS CPU path — the honest metric is the GPU throughput).
  • CUDA mirror (WindTunnelCuda): line-for-line translation of the OpenCL kernels; authored
    here, compiled + validated on an NVIDIA machine (-DCYBERFLUIDS_CUDA=ON).
  • Docs/spec honesty fix: forEachIndex is CPU-only; GPU = device-kernel solvers.
  • Swift WindTunnel wrapper (parity with Python) + README Python/Swift STL examples.

Validation

  • 37/37 CTest targets pass with -DCYBERFLUIDS_OPENCL=ON (incl. opencl_wind_tunnel).
  • Default build (all GPU flags OFF) unaffected.
  • CUDA: run ctest -R cuda_wind_tunnel on an NVIDIA box (skips cleanly without a device).

Notes

  • The add-gpu-wind-tunnel OpenSpec change is still active (adversarial review + CUDA-machine
    validation pending); it will be archived in a follow-up.

…ples

GPU acceleration for the 3D wind tunnel via bespoke device-kernel solvers (the
forEachIndex seam is CPU-only and cannot dispatch a host lambda to a device).

- WindTunnelOpenCL: porous convex-blend collide + stream_bc kernels, populations
  resident on the device (ping-pong), fp64 host read-back. Validated on Apple
  M2 Max vs the fp64 CPU WindTunnel3D oracle (Linf/Uin ~ 1e-5, deterministic,
  no-slip preserved); ~1.35 GLUPS. cmake/CyberfluidsOpenCL.cmake + test.
- WindTunnelCuda: line-for-line CUDA mirror of the validated OpenCL kernels;
  compiled and validated on an NVIDIA machine (-DCYBERFLUIDS_CUDA=ON). Test
  skips cleanly without a device.
- Docs/spec: correct docs/backends.md and the hardware-backends spec — the
  forEachIndex seam is CPU-only; GPU acceleration is bespoke device-kernel
  solvers validated against the CPU oracle.
- Swift WindTunnel wrapper (parity with the Python class) + README Python/Swift
  wind-tunnel-from-STL examples.

Default build (all GPU flags OFF) is unaffected. Full suite 37/37 with OpenCL on.
@leonardoaraujosantos
leonardoaraujosantos merged commit 677f2f0 into main Jul 5, 2026
2 of 3 checks passed
@leonardoaraujosantos
leonardoaraujosantos deleted the feat/gpu-wind-tunnel branch July 5, 2026 04:13
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