GithubHelp home page GithubHelp logo

hhy5277 / emu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from calebwin/emu

0.0 1.0 0.0 298.78 MB

a language for programming GPUs

Home Page: https://calebwin.github.io/emu

License: MIT License

Rust 100.00%

emu's Introduction

a picture of a real-world emu

Emu is a high-level language for programming GPUs. Unlike other languages such as OpenCL or Halide that are designed for embedding in C or C++, Emu is designed for embedding in Rust. It provides a single procedural macro for writing functions. The macro translates the functions at compile time into lower-level code so that they can be run on the GPU.

Emu also provides several features that aim to make programming GPUs more accessible such as built-in mathematical and physical constants, unit annotation and implicit conversion. Here are some example functions...

emu! {
	// more particles
	more_particles(num_particles u32, num_moles u32) u32 {
		return num_particles + num_moles * L;
	}

	// moves particles
	move_particles(global_particles_x [f32], global_particles_y f32, global_particles_z f32) {
		global_particles_z[get_global_id(0)] += 7.3e1 as nm;
		global_particles_x[get_global_id(0)] += 2 as cm;
		global_particles_y[get_global_id(0)] += 6 as cm;
	}
	
	// moves particles in circle
	rotate_particles(global_particles_r [f32]) {
		global_particles_r[get_global_id(0)] += 7.5 * TAU;
	}

	// multiplies 2 matrices
	// n is the dimension of the matrices
	// a and b are the matrices to be multiplied, c is the result
	multiply_matrices(n i32, global_a [f32], global_b [f32], global_c [f32]) {
		// indices of cells to multiply
		let i: i32 = get_global_id(0);
		let j: i32 = get_global_id(1);

		// execute step of multiplication
		for k in 0..n {
			global_c[i * n + j] += global_a[i * n + k] * global_b[k * n + j];
		}
	}
}

To get started programming GPUs with Emu, check out the book, the examples, and the crate itself.

emu's People

Contributors

calebwin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.