answerdotai/gpu.cpp

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

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 3 minutes ago
Added to GitGenius on September 17th, 2026
Created on May 30th, 2024
Open Issues & Pull Requests: 10 (+0)
GitHub issues: Enabled
Number of forks: 199
Total Stargazers: 3,984 (+0)
Total Subscribers: 48 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 35.8 hours
Mean response time: 41.8 days
90th percentile: 244.2 days
Tracked items: 6

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 3
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 745 days
Stale 30+ days: 3
Stale 90+ days: 3

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

gpu.cpp is a lightweight, header-only C++ library for portable low-level GPU computation using WebGPU.

The library solves the problem of writing GPU compute code that runs across different platforms and devices without platform-specific rewrites. It wraps Google's Dawn WebGPU implementation, automatically selecting Metal on macOS, Vulkan on Linux, and WebGPU in browsers. The design stays deliberately close to WebGPU semantics: it owns native resources, manages asynchronous work and error handling, and eliminates repetitive descriptor boilerplate, but shaders still explicitly declare their resource bindings and execution model. The core API provides a Context to manage the GPU device and queue, Tensor objects for GPU buffers with shape and type metadata, Kernel objects for reusable compute pipelines, and Future-based async operations that work natively or suspend through JSPI in browsers.

Developers should choose this tool when they need GPU compute that runs on multiple platforms without maintaining separate code paths. It suits projects that can express their compute as WebGPU shaders and want to avoid the verbosity of raw WebGPU while staying close to its semantics. The library is particularly useful for teams already targeting both native and browser environments, since the same code compiles to both. The header-only design and CMake integration make it straightforward to embed in existing projects.

The project maintains exact pinned revisions of Dawn and Emscripten tooling, with dedicated build scripts that stage dependencies reproducibly. Native tests require actual GPU hardware and deliberately disable Dawn's Null backend to catch GPU access failures clearly rather than silently. The library supports optional SPIR-V input through a WebGPU-facing compiler contract rather than arbitrary Vulkan passthrough. Browser builds require specific Chrome features and coordinate with a sibling Emscripten SDK clone, with clear documentation in DEV.md for the dependency layout and update process.