Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

emu

> 编程语言
Open source

The write-once-run-anywhere GPGPU library for Rust

1.6K stars0 likes0 views
WebsiteGitHub

About

The write-once-run-anywhere GPGPU library for Rust

> The old version of Emu (which used macros) is [here](https://github.com/calebwin/emu/tree/master/em).

# Overview Emu is a GPGPU library for Rust with a focus on portability, modularity, and performance. It's a CUDA-esque compute-specific abstraction over [WebGPU](https://github.com/gfx-rs/wgpu-rs) providing specific functionality to make WebGPU feel more like CUDA. Here's a quick run-down of highlight features... - **Emu can run anywhere** - Emu uses WebGPU to support DirectX, Metal, Vulkan (and also OpenGL and browser eventually) as compile targets. This allows Emu to run on pretty much any user interface including desktop, mobile, and browser. By moving heavy computations to the user's device, you can reduce system latency and improve privacy. - **Emu makes compute easier** - Emu makes WebGPU feel like CUDA. It does this by providing... - `DeviceBox` as a wrapper for data that lives on the GPU (thereby ensuring type-safe data movement) - `DevicePool` as a no-config auto-managed pool of devices (similar to CUDA) - `trait Cache` - a no-setup-required LRU cache of JITed compute kernels. - **Emu is transparent** - Emu is a fully transparent abstraction. This means, at any point, you can decide to remove the abstraction and work directly with WebGPU constructs with zero overhead. For example, if you want to mix Emu with WebGPU-based graphics, you can do that with zero overhead. You can also swap out the JIT compiler artifact cache with your own cache, manage the device pool if you wish, and define your own compile-to-SPIR-V compiler that interops with Emu. - **Emu is asynchronous** - Emu is fully asynchronous. Most API calls will be non-blocking and can be synchronized by calls to `DeviceBox::get` when data is read back from device. # An example Here's a quick example of Emu. You can find more in `emu_core/examples` and most recent documentation [here](https://calebwin.github.io/emu). First, we just import a bunch of stuff ```rust use emu_glsl::*; use emu_core::prelude::*; use zerocopy::*; ``` We can define types of structures so that they can be safely serialized and deserialized to/from the GPU. ```rust #[repr(C)] #[derive(AsBytes, FromBytes, Copy, Clone, Default, Debug)] struct Rectangle { x: u32, y: u32, w: i32, h: i32, } ``` For this example, we make this entire function async but in reality you will only want small blocks of code to be async (like a bunch of asynchronous memory transfers and computation) and these blocks will be sent off to an executor to execute. You definitely don't want to do something like this where you are blocking (by doing an entire compilation step) in your async code. ``` … ``` And last but certainly not least, we use an executor to execute. ```rust fn main() { futures::executor::block_on(do_some_stuff()).expect("failed to do stuff on GPU"); } ``` # Built with Emu Emu is relatively new but has already been used for GPU acceleration in a variety of projects. - Used in [toil](https://github.com/vadixidav/toil) for GPU-accelerated linear algebra - Used in [ipl3hasher](https://github.com/awygle/ipl3hasher) for hash collision finding - Used in [bigbang](https://github.com/sezna/bigbang) for simulating gravitational acceleration (used older version of Emu) # Getting started The latest stable version is [on Crates.io](https://crates.io/crates/emu_core). To start using Emu, simply add the following line to your `Cargo.toml`. ```toml [dependencies] emu_core = "0.1.1" ``` To understand how to start using Emu, check out [the docs](https://calebwin.github.io/emu/). If you have any questions, please [ask in the Discord](https://discord.gg/sKf6KCs). # Contributing Feedback, discussion, PRs would all very much be appreciated. Some relatively high-priority, non-API-breaking things that have yet to be implemented are the following in rough order of priority. - [ ] Enusre that WebGPU polling is done correctly in `DeviceBox::get - [ ] Add support for WGLSL as input, use [Naga](https://github.com/gfx-rs/naga) for shader compilation - [ ] Add WASM support in `Cargo.toml` - [ ] Add benchmarks` - [ ] Reuse staging buffers between different `DeviceBox`es - [ ] Maybe use uniforms for `DeviceBox` when `T` is small (maybe) If you are interested in any of these or anything else, please don't hesitate to open an issue on GitHub or discuss more [on Discord](https://discord.gg/sKf6KCs).

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Emu makes compute easier - Emu makes WebGPU feel like CUDA. It does this by providing...
  • •DeviceBox<T> as a wrapper for data that lives on the GPU (thereby ensuring type-safe data movement)
  • •DevicePool as a no-config auto-managed pool of devices (similar to CUDA)
  • •trait Cache - a no-setup-required LRU cache of JITed compute kernels.
  • •Emu is asynchronous - Emu is fully asynchronous. Most API calls will be non-blocking and can be synchronized by calls to DeviceBox::get when data is read back from device.
  • •Used in toil for GPU-accelerated linear algebra
  • •Used in ipl3hasher for hash collision finding
  • •Used in bigbang for simulating gravitational acceleration (used older version of Emu)
  • •[ ] Enusre that WebGPU polling is done correctly in `DeviceBox::get
  • •[ ] Add support for WGLSL as input, use Naga for shader compilation

> Tags

Rustemugpgpugpugpu-acceleration

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言