gpu.cpp  by AnswerDotAI

C++ library for portable GPU computation using WebGPU

created 1 year ago
3,893 stars

Top 12.8% on sourcepulse

GitHubView on GitHub
Project Summary

gpu.cpp provides a C++ library for portable, low-level GPU computation using the WebGPU specification. It targets individual developers and researchers seeking to integrate GPU acceleration into native applications with minimal boilerplate and dependencies, enabling fast iteration cycles across diverse hardware.

How It Works

The library leverages WebGPU as a cross-platform, low-level GPU API, allowing C++ code to run on GPUs from various vendors (Nvidia, Intel, AMD) via Vulkan, Metal, or DirectX backends. It emphasizes a small API surface area and minimal dependencies, offering a header-only C++ interface. For convenience, it bundles a pre-built binary of Google's Dawn WebGPU implementation, avoiding lengthy build times for the WebGPU backend during development.

Quick Start & Requirements

  • Install/Run: make from the top-level directory.
  • Prerequisites: clang++ (C++17), python3, make. Linux requires Vulkan drivers.
  • Setup: The first run automatically downloads the Dawn shared library. Build and execution take a few seconds.
  • Details: examples/hello_world/run.cpp

Highlighted Details

  • Lightweight, header-only C++ core implementation (~1000 lines).
  • Pre-built Dawn WebGPU implementation for rapid setup.
  • Supports MacOS, Linux, and Windows (WSL).
  • Example matrix multiplication achieves ~3.5+ TFLOPs on a Macbook Pro M1 Max.

Maintenance & Community

  • Developed by Answer.AI.
  • Community channel: #gpu-cpp on AnswerDotAI Discord.
  • Contact: @austinvhuang on X.

Licensing & Compatibility

  • License: MIT (for gpu.cpp itself). Dawn's license is not explicitly stated in the README but is typically BSD-style.
  • Compatibility: Suitable for commercial use and linking with closed-source applications.

Limitations & Caveats

Browser targets are a short-term priority and not yet tested. The library currently lacks a reusable kernel library, with WGSL implementations residing within examples.

Health Check
Last commit

2 weeks ago

Responsiveness

1 day

Pull Requests (30d)
1
Issues (30d)
0
Star History
52 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
7 more.

ThunderKittens by HazyResearch

0.6%
3k
CUDA kernel framework for fast deep learning primitives
created 1 year ago
updated 3 days ago
Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Nat Friedman Nat Friedman(Former CEO of GitHub), and
32 more.

llama.cpp by ggml-org

0.4%
84k
C/C++ library for local LLM inference
created 2 years ago
updated 14 hours ago
Feedback? Help us improve.