Skip to content
GitHub no longer supports this web browser. Learn more about the browsers we support.
Emu is a framework for developing safe, robust GPU-accelerated applications in Rust.
Rust
Branch: master
Clone or download
Cannot retrieve the latest commit at this time.
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
docs added comparison Oct 22, 2019
em fixed example Oct 21, 2019
emu_examples/arithmetic
emu_macro
emu_tests
.gitignore added gitignore Oct 15, 2019
CONTRIBUTING.md
Cargo.lock final changes Oct 21, 2019
Cargo.toml implemented a minimum viable product Oct 15, 2019
LICENSE
README.md changed into Nov 19, 2019

README.md

Gitter

Emu is a framework/compiler for GPU acceleration of Rust, GPU programming. It is a procedural macro (#[gpu_use]) that walks through your Rust code and off-loads parts of it to the GPU. It looks for annotations (gpu_do!()) embedded in your code to know where to add GPU-specific action (like moving data and launching computation).

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

features

  • ease of use
    • download a library, not a whole new compiler
    • work with cargo test, cargo doc, crates.io
    • 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

#[macro_use]
extern crate em;
use em::*;

#[gpu_use]
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);
}

usage

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.

contributing

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 CONTRIBUTING.md)
  • 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.