AnswerDotAI/gpu.cpp

A lightweight library for portable low-level GPU computation using WebGPU.

What it solves

It provides a concise, header-only C++20 interface for GPU compute, removing the repetitive descriptor code and complex setup associated with raw WebGPU while maintaining direct control over shaders and data movement.

How it works

It acts as a lightweight wrapper around Dawn (Google's WebGPU implementation), allowing developers to write compute shaders in WGSL or SPIR-V. It manages native resources, handles asynchronous work and errors through a Future system, and supports multiple backends including Metal (macOS), Vulkan (Linux), and Emdawnwebgpu (browsers).

Who it’s for

Developers who need general-purpose GPU compute capabilities in C++, Python, or JavaScript/Wasm, but want to avoid the boilerplate of the full WebGPU API.

Highlights

  • Cross-platform support: Works across macOS, Linux, and web browsers.
  • Multi-language bindings: Includes a Python module (via pybind11) and JavaScript/Wasm support.
  • Flexible shader input: Supports both WGSL and SPIR-V (native only).
  • Efficient data handling: Supports float16, float32, and int32 types with NumPy integration for Python.

Related

  • Project
  • Project
  • Project
  • Project
  • Project