Skip to content
Emu is a framework for developing safe, robust GPU-accelerated applications in Rust.
Branch: master
Clone or download
Latest commit 7ca482f Nov 9, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs added comparison Oct 22, 2019
em fixed example Oct 21, 2019
emu_examples/arithmetic thinking about support for block algorithms Oct 27, 2019
emu_macro thinking about support for block algorithms Oct 27, 2019
emu_tests preparing for publishing Oct 21, 2019
.gitignore added gitignore Oct 15, 2019 added clarification Oct 28, 2019
Cargo.lock final changes Oct 21, 2019
Cargo.toml implemented a minimum viable product Oct 15, 2019
LICENSE added license Oct 15, 2019 added feature Nov 9, 2019


Emu is a framework/compiler for GPU acceleration of Rust, GPU programming. It is a procedural macro that accept pure, safe Rust code as input, identifies portions to attempt to accelerate, and automatically writes in code to run portions on the GPU instead of the CPU.

Ultimately, Emu helps you develop single-source, GPU-accelerated applications in Rust, taking advantage of Rust's tooling, ecosystem, and safety guarantees.


  • ease of use
    • download a library, not a whole new compiler
    • work with cargo test, cargo doc,
    • work with rustfmt, racer, rls
    • switch between CPU and GPU with 1 line
    • seamlessly drop down to low-level OpenCL, SPIR-V
  • safety guarantees
    • no null pointer errors
    • no type mismatch errors
    • no syntax errors
  • more fun
    • up to 80% less code
    • up to 300x speedup
    • as fast as single-GPU, single-threaded, idiomatic usage of OpenCL

an example

extern crate em;
use em::*;

fn main() {
    let mut x = vec![0.0; 1000];
    gpu_do!(load(x)); // move data to the GPU
    gpu_do!(launch()); // off-load to run on the GPU
    for i in 0..1000 {
        x[i] = x[i] * 10.0;
    gpu_do!(read(x)); // move data back from the GPU
    println!("{:?}", x);


You can use Emu in your Rust projects by doing the following-

  1. Add em = 0.3.0 to Cargo.toml
  2. Confirm that an OpenCL library is installed for your platform

Learn how to get started with Emu by looking at the documentation.


Emu currently works very well (robust, well-documented, OK-ish baseline performance) but only with a small subset of Rust. The roadmap for what to do next is pretty straightforward - expand that subset of Rust that we look at. Here is an up-to-date (but not necessarily complete) list of things to work on.

  • Constant address space by default
  • Data race safety with Rayon
  • Multiple GPU usage
  • Multiple thread usage (from host)
  • Support for methods (details in
  • Support for block algorithms
  • Support for reduction algorithms
  • Support for for x in &data
  • Support for for x in &mut data
  • Support for variables
  • Support for if statements
  • Support for if/else-if/else statements
  • Support for all Rust with NVPTX
  • insert your super-cool idea here

We want people to be able to implement all sorts of cool things (simulations, AI, image processing) with Rust + Emu. If you are excited about building a framework for accelerating Rust code with GPUs, create a GitHub issue for whatever you want to work on and/or discuss on Gitter.

You can’t perform that action at this time.