enki-gpu 0.1.0

Pure Rust heterogeneous GPU compute platform with JIT compilation
Documentation
enki-gpu-0.1.0 has been yanked.

What is Enki?

enki-gpu (enki) is a heterogeneous GPU compute platform for Rust. Use crates.io dependencies, structs, enums, generics, atomics, traits, and macros directly on GPU silicon.

Write idiomatic Rust functions and run them on the GPU. Want to run them on the CPU instead? You don't need to change anything, just call the function natively.

Runs on stable Rust (No nightly toolchain required).

A Quick Look

use enki::*;
use glam::{Mat4, Vec3};

const N: usize = 5;

#[nam]
fn mat_mul(_space: &Space, a: &Mat4, b: &Mat4, c: &mut Mat4) {
    *c = *a * *b;
}

fn main() {
    let enki = Enki::init();

    // Initialize Data
    let a_cpu = vec![Mat4::from_scale(Vec3::splat(2.0)); N];
    let b_cpu = vec![Mat4::from_translation(Vec3::splat(5.0)); N];
    let mut c_cpu = vec![Mat4::ZERO; N];

    let a_gpu = gpu_vec![Mat4::from_scale(Vec3::splat(2.0)); N];
    let b_gpu = gpu_vec![Mat4::from_translation(Vec3::splat(5.0)); N];
    let mut c_gpu = gpu_vec![Mat4::ZERO; N];

    // Run mat_mul function on the GPU
    enki.flow(|_| {
        mat_mul.run(&Space::gpu_x(N), &a_gpu, &b_gpu, &mut c_gpu);
    });

    // Run the exact same function natively on the CPU
    for i in 0..N {
        mat_mul(&Space::cpu_x(i, N), &a_cpu[i], &b_cpu[i], &mut c_cpu[i]);
    }

    println!("\nCPU: {:?}", c_cpu);
    println!("\nGPU: {:?}", c_gpu);

    assert_eq!(&c_cpu[..], &c_gpu.to_vec()[..]);
}

Quick Start

# Add Enki to your project
cargo add enki-gpu

# Install the Enki CLI runner
cargo install cargo-enki

# Run your project with GPU JIT
cargo enki run

# Or you can just use cargo run instead
cargo run