emu
Library Listed Dormant
A low-level GPGPU compute library featuring cross-platform support and SPIR-V as input
- Downloads
- 49
- Dependents
- 0
- Stars
- 1,604
- Forks
- 51
- Contributors
- 4
- Commits
- 90
- Latest release
- 0.1.1 ·
About
The old version of Emu (which used macros) is here.
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 providing specific functionality to make WebGPU feel more like CUDA. Here's a quick run-down of highlight features...
Read the full README
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<T>as a wrapper for data that lives on the GPU (thereby ensuring type-safe data movement)DevicePoolas 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::getwhen 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.
First, we just import a bunch of stuff
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.
#[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.
fn main() -> Result<(), Box<dyn std::error::Error>> {
futures::executor::block_on(assert_device_pool_initialized());
// first, we move a bunch of rectangles to the GPU
let mut x: DeviceBox<[Rectangle]> = vec![Default::default(); 128].as_device_boxed()?;
// then we compile some GLSL code using the GlslCompile compiler and
// the GlobalCache for caching compiler artifacts
let c = compile::<String, GlslCompile, _, GlobalCache>(
GlslBuilder::new()
.set_entry_point_name("main")
.add_param_mut()
.set_code_with_glsl(
r#"
#version 450
layout(local_size_x = 1) in; // our thread block size is 1, that is we only have 1 thread per block
struct Rectangle {
uint x;
uint y;
int w;
int h;
};
// make sure to use only a single set and keep all your n parameters in n storage buffers in bindings 0 to n-1
// you shouldn't use push constants or anything OTHER than storage buffers for passing stuff into the kernel
// just use buffers with one buffer per binding
layout(set = 0, binding = 0) buffer Rectangles {
Rectangle[] rectangles;
}; // this is used as both input and output for convenience
Rectangle flip(Rectangle r) {
r.x = r.x + r.w;
r.y = r.y + r.h;
r.w *= -1;
r.h *= -1;
return r;
}
// there should be only one entry point and it should be named "main"
// ultimately, Emu has to kind of restrict how you use GLSL because it is compute focused
void main() {
uint index = gl_GlobalInvocationID.x; // this gives us the index in the x dimension of the thread space
rectangles[index] = flip(rectangles[index]);
}
"#,
)
)?.finish()?;
// we spawn 128 threads (really 128 thread blocks)
unsafe {
spawn(128).launch(call!(c, &mut x));
}
// this is the Future we need to block on to get stuff to happen
// everything else is non-blocking in the API (except stuff like compilation)
println!("{:?}", futures::executor::block_on(x.get())?);
Ok(())
}
And last but certainly not least, we use an executor to execute.
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 for GPU-accelerated linear algebra
- Used in ipl3hasher for hash collision finding
- Used in bigbang for simulating gravitational acceleration (used older version of Emu)
Getting started
The latest stable version is on Crates.io. To start using Emu, simply add the following line to your Cargo.toml.
[dependencies]
emu_core = "0.1.1"
To understand how to start using Emu, check out the docs. If you have any questions, please ask in the Discord.
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 for shader compilation
- [ ] Add WASM support in
Cargo.toml - [ ] Add benchmarks`
- [ ] Reuse staging buffers between different
DeviceBoxes - [ ] Maybe use uniforms for
DeviceBox<T>whenTis 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.
Compatibility
- Runs on
- WebGPU
What shows it
- WebGPU: emu_core dependency wgpu
- Native code
- Required
- Binds native code: cl-sys, link-cplusplus (feature glsl-compile), shaderc-sys (feature glsl-compile)
- Python bindings
- No Python binding crate found
- License
- MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
A low-level GPGPU compute library featuring cross-platform support and SPIR-V as input |
49 downloads over 30 days | 0 | 1,604 | 0.1.1 | WebGPU | Binds native code: cl-sys, link-cplusplus (feature glsl-compile), shaderc-sys (feature glsl-compile) | MIT |
|
cubecl Featured
Multi-platform high-performance compute language extension for Rust. |
523,446 downloads over 30 days | 145 | 2,490 | 0.11.3 | CUDA, WebGPU, Metal, ROCm, Vulkan | Binds native code: cubecl-hip-sys (feature hip), llvm-sys (feature cpu), tracy-client-sys (feature profile-tracy) | Apache-2.0 OR MIT |
|
Micro compiler for tensor operations. Python bindings |
688,399 downloads over 30 days | 3 | 75 | 0.5.0 | CUDA, Metal | No native code found | Apache-2.0 OR MIT |
|
numr Listed
The base for numerical code in Rust, in the role NumPy has in Python: n-dimensional tensors, linear algebra, FFT, statistics and autograd on CPU, CUDA and WebGPU. The backends use native kernels, with no cuBLAS, MKL or other vendor math library. |
1,673 downloads over 30 days | 7 | 59 | 0.15.2 | CUDA, WebGPU | Binds native code: ring (feature distributed) | Apache-2.0 |
|
oxicuda Listed
OxiCUDA replaces the entire NVIDIA CUDA Toolkit software stack with type-safe, memory-safe Rust code. |
65 downloads over 30 days | 36 | 145 | 0.5.5 | WebGPU, Metal, ROCm, Vulkan | No native code found | Apache-2.0 |
|
GPU scientific computing on every platform |
Not measured | Not applicable | 150 | Not measured | Not measured | Not measured | Apache-2.0 |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 0 active dependents and 0 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 1,604 stars, 51 forks and 4 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
- The project is dormant and not finished. Dormancy rule
What else the check found
- The last activity is on 26 Mar 2021, 2054 days ago. That reaches the 365 days the rules expect, so the project is dormant. Dormancy rule
- The oldest outside issue waits 2715 days for a reply, past the limit of 270. No maintainer replied in 365 days. Rot signals rule
Not measured: Latest release fails cargo check.
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.1.1 base 300, capped at 2 releases = 100, raised to the 365-day floor: E = 365 daysdormancy: last activity 2021-03-26, 2054 days ago, E = 365: dormantrot: oldest unanswered issue 2715 days (limit 270), no maintainer reply in 365 daysfeatured: not featured: active_users 0 < 11 and new_adopters 0 < 9 and repository route stars 1604 (needs 4539), forks 51 (needs 434), contributors 4 (needs 79); dormant and not stablelisted: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption0 active dependents, 0 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 0 | crates.io database dump | Yes | |
| New dependents (365 days) | 0 | crates.io database dump | Yes | |
| Peak active dependents | 0 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 5 years ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2021-03-26 | GitHub repository | Yes | |
| Latest release | 2020-04-09 | crates.io database dump | Yes | |
| First release | 2019-05-27 | crates.io database dump | Yes | |
| Latest version | 0.1.1 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 2715 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution2 releases, 49 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 2 | crates.io database dump | Yes | |
| Downloads over 30 days | 49 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository1,604 stars, 51 forks, 4 contributors, 90 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 1604 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 51 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 4 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 90 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | WebGPU | crates.io database dump | No | |
| What shows each backend | WebGPU: emu_core dependency wgpu | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | Binds native code: cl-sys, link-cplusplus (feature glsl-compile), shaderc-sys (feature glsl-compile) | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 0 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.