Book on GitHub Code on GitHub Crate on Crates.io

emu

Emu is a language for programming GPUs. Unlike OpenCL/CUDA/Halide/Futhark, Emu is embedded in Rust. This lets it take advantage of the ecosystem (cargo build, cargo doc, cargo test, crates.io, docs.rs) in ways that let it provide a far more streamlined system for programming GPUs. Consequently, Emu makes Rust ideal - compared to Python/Julia/C++ - for writing minimalistic programs that do robust, data-intensive computation.

emu! {
	function compute_sigmoid(x f32) f32 {
		return 1 / (1 + pow(E, -x));
	}

	function apply_sigmoid(data [f32]) {
		data[..] = compute_sigmoid(data[..]);
	}

	function apply_relu(data [f32]) {
		if data[..] < 0 { data[..] = 0; }
	}

	fn apply_sigmoid(data: &mut Vec);
	fn apply_relu(data: &mut Vec);
}

fn main() {
	let mut inputs = vec![1.9, 2.8, 3.7, 4.6];

	apply_sigmoid(&mut inputs);
	apply_relu(&mut inputs);
}
[dependencies]
em = "0.1.2"