sunsided / rust-arrayfire-experiments

Toying around with ArrayFire in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GPGPU Experiments in Rust with ArrayFire

Toying around with / getting to know arrayfire-rust. Don't expect anything crazy here. 🙌

Example applications

  • conway.rs: GPU-enabled Conway's Game of Life through kernel convolutions, taken from the arrayfire-rust examples and spiced up for readability and understandability. Uses ArrayFire's graphics module to provide a window. See The Game of Life vs. Convolutions for a post on it.

    cargo run
    cargo run --bin conway
  • trivial.rs: The simple example from the arrayfire-rust README:

    cargo run --bin trivial
  • white_noise.rs: Just white noise in a window.

    cargo run --bin white-noise
  • half_precision.rs: FP16 example using half::f16. Doesn't work on my GTX 980 Ti (Compute 5.2) with CUDA 10 / driver 450, so the CPU back-end is used instead.

    cargo run --bin half-precision
  • adaptive_threshold.rs: Implements three adaptive thresholding techniques (mean, median and min-max average) as described in Image editing using ArrayFire: Part 3. Note that the path to the image is hard-coded, so it needs to be run from the repository root.

    cargo run --bin adaptive-threshold
  • histogram.rs: Implements RGB histogram calculation as described in Image editing using ArrayFire: Part 3. Makes use of slice() and/or index() to obtain individual channels from an Array<T>. Note that the path to the image is hard-coded, so it needs to be run from the repository root.

    cargo run --bin histogram

Installing ArrayFire

From the arrayfire-rust instructions:

To use the rust bindings for ArrayFire from crates.io, the following requirements are to be met first.

  1. Download and install ArrayFire binaries based on your operating system.
  2. Set the evironment variable AF_PATH to point to ArrayFire installation root folder.
  3. Make sure to add the path to lib files to your path environment variables.
    • On Linux: do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$AF_PATH/lib64
    • On OSX: do export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$AF_PATH/lib64
    • On Windows: Add %AF_PATH%\lib to your PATH environment variable.
  4. Add arrayfire = "3.7" to the dependencies section of your project's Cargo.toml file. Make sure to change the version to latest available.

Once step (4) is over, you should be able to use ArrayFire in your Rust project.

Further reading

License

About

Toying around with ArrayFire in Rust


Languages

Language:Rust 100.0%