eholk/RustGPU


Language: C


Compiling Rust for GPUs

This repository contains a proof of concept for writing GPU kernels in Rust. The NVPTX LLVM backend is used to translate Rust code into PTX code for execution on the GPU. OpenCL is used to handle memory allocation, data transfer and kernel invocation.

Getting Started

This repository includes a custom version of Rust as a submodule. You will need to build this first. Do so with the following command:

make rustc

You will probably want to go get a cup of tea. The build will take about 30 minutes.

Once that's done, you can build the Rust OpenCL bindings and several example programs:

make

This will create several executables in the examples directory that illustrate various features of our proof of concept.

About the examples

We current have four examples:

  1. add-float demonstrates adding a single floating point number on the GPU. This is about the simplest possible kernel of any interest.
  2. thread-id demonstrates the use of Rust intrinsics to determine the current thread id. Without vector indexing, however, there is still only one thread with observable effects.
  3. enum demonstrates the use of Rust enum types. This shows that Rust on the GPU can handle more than just simple scalar data types.
  4. add-vector shows how to compute on multiple elements of an array. This uses unsafe pointers and raw pointer arithmetic.

Project Statistics

Sourcerank 4
Repository Size 383 KB
Stars 65
Forks 12
Watchers 11
Open issues 1
Dependencies 0
Contributors 2
Tags 0
Created
Last updated
Last pushed

Top Contributors See all

Eric Holk Milinda Pathirage

Something wrong with this page? Make a suggestion

Last synced: 2017-11-24 18:58:13 UTC

Login to resync this repository