Rust wrapper for ArrayFire

Pradeep ArrayFire Leave a Comment

In this post, we would like to introduce our latest & newest language bindings for ArrayFire library: ArrayFire-Rust - Rust bindings for ArrayFire. We have been working on the wrapper and using it in daily production within the company for the last few months and now regard it stable enough for public distribution.

How to use ArrayFire from crates.io

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. If you are on Linux or OSX, set the environment variable AF_PATH to point to ArrayFire installation root folder. (This is automatically set for you on Windows.)
  3. Make sure you add the path to library files to your path environment variables.
    • On Linux & OSX: do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$AF_PATH/lib
    • On Windows: Add %AF_PATH%\lib to your PATH environment variable.
  4. Run cargo new --bin helloworld && helloworld
  5. Edit Cargo.toml to add the line arrayfire = "3.3.0" to the [dependencies] section.
  6. Add the following sample rust code to your source file helloworld/src/main.rs.
  7. Run cargo run and you should see output similar to the one below.

Documentation

You can find the documentation for all the functions and macros available in the crate over here. You can also look at the ArrayFire C/C++ API documentation on ArrayFire.com which categorizes ArrayFire functions into several specific domains.

Example Project

hal project is one of the initial adaptors of our rust wrapper for ArrayFire to enable use of GPUs from Rust via ArrayFire.

Credits

We would like to thank Jason Ramapuram for helping us in writing and reviewing the rust bindings. We would also like to thank the users from rust community who provided their invaluable feedback while working on the bindings for ArrayFire.

 

Facebooktwittergoogle_plusredditlinkedinmail