• Stars
    star
    815
  • Rank 55,957 (Top 2 %)
  • Language
    Rust
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust wrapper for ArrayFire

ci docs book slack github-discussions

ArrayFire Rust Bindings

ArrayFire is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices. This project provides Rust bindings for the ArrayFire library. Given below table shows the rust bindings compatability with ArrayFire. If you find any bugs, please report them here.

arrayfire-rust ArrayFire
M.m.p1 M.m.p2

Only, Major(M) & Minor(m) version numbers need to match. p1 and p2 are patch/fix updates for arrayfire-rust & ArrayFire respectively, and they don't need to match.

Supported platforms

Linux, Windows and OSX. Rust 1.31 or newer is required.

Use 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. Depending on the method of your installation for Linux, steps (2) & (3) may not be required. If that is the case, proceed to step (4) directly.
  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/lib
    • On Windows: Add %AF_PATH%\lib to your PATH environment variable.
  4. Add arrayfire = "3.8" 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. If you find any bugs, please report them here.

Build from Source

Edit build.conf to modify the build flags. The structure is a simple JSON blob. Currently Rust does not allow key:value pairs to be passed from the CLI. To use an existing ArrayFire installation modify the first three JSON values. You can install ArrayFire using one of the following two ways.

To build arrayfire submodule available in the rust wrapper repository, you have to do the following.

git submodule update --init --recursive
cargo build // use --all to build all crates in the workspace

This is recommended way to build Rust wrapper since the submodule points to the most compatible version of ArrayFire the Rust wrapper has been tested with. You can find the ArrayFire dependencies below.

Example

let num_rows: u64 = 5;
let num_cols: u64 = 3;
let dims = Dim4::new(&[num_rows, num_cols, 1, 1]);
let a = randu::<f32>(dims);
af_print!("Create a 5-by-3 matrix of random floats on the GPU", a);

Sample output

~/p/arrayfire_rust> cargo run --example helloworld
...
Create a 5-by-3 matrix of random floats on the GPU
[5 3 1 1]
    0.7402     0.4464     0.7762
    0.9210     0.6673     0.2948
    0.0390     0.1099     0.7140
    0.9690     0.4702     0.3585
    0.9251     0.5132     0.6814
...

Troubleshooting

If the build command fails with undefined references errors even after taking care of environment variables, we recommend doing a cargo clean and re-running cargo build or cargo test.

You can also use some environment variables mentioned in our book, such as AF_PRINT_ERRORS to print more elaborate error messages to console.

Acknowledgements

The ArrayFire library is written by developers at ArrayFire LLC with contributions from several individuals. The developers at ArrayFire LLC have received partial financial support from several grants and institutions. Those that wish to receive public acknowledgement are listed below:

Grants

This material is based upon work supported by the DARPA SBIR Program Office under Contract Numbers W31P4Q-14-C-0012 and W31P4Q-15-C-0008. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the DARPA SBIR Program Office.

More Repositories

1

arrayfire

ArrayFire: a general purpose GPU library.
C++
4,549
star
2

arrayfire-python

Python bindings for ArrayFire: A general purpose GPU library.
Python
418
star
3

forge

High Performance Visualization
C++
226
star
4

arrayfire-js

ArrayFire.js - ArrayFire for Node.js
C++
120
star
5

arrayfire-ml

ArrayFire's Machine Learning Library.
C++
102
star
6

arrayfire-dotnet

.NET wrapper for ArrayFire
C#
78
star
7

androidcl

Sample app that runs OpenCL kernels to process camera feed on Android devices
C++
76
star
8

arrayfire-haskell

Haskell bindings to ArrayFire
Haskell
60
star
9

arrayfire-rb

Ruby wrapper for ArrayFire
C
37
star
10

arrayfire-java

Java wrapper for ArrayFire
Java
35
star
11

xilinx_demos

OpenCL Demos for Xilinx FPGAs
C++
31
star
12

arrayfire-fortran

Fortran wrapper for ArrayFire
Fortran
24
star
13

arrayfire-r

R wrapper for ArrayFire
R
22
star
14

arrayfire-go

Go bindings for arrayfire
Go
16
star
15

cuda_deployment_tutorial

Scripts to Deploy GPU Enabled Containers
Shell
13
star
16

arrayfire_opengl_interop

Code sample to show interoperability between ArrayFire and OpenGL.
C++
12
star
17

arrayfire-windows-scripts

Batch Scripts for Building ArrayFire on Windows
Batchfile
11
star
18

arrayfire-lua

Lua wrapper for ArrayFire
Lua
10
star
19

valhalla

Benchmarks for Open Source Libraries with Parallel Vector algorithms.
CMake
8
star
20

arrayfire-project-templates

Template Projects for ArrayFire
CMake
7
star
21

arrayfire-docker

Dockerfile for Building and Using ArrayFire https://github.com/arrayfire/arrayfire.git
Dockerfile
6
star
22

arrayfire-api-cheat-sheet

A quick reference of arrayfire library API; equivalent API in it's language wrappers and other math libraries.
6
star
23

ml_lab

Machine Learning Lab
C++
6
star
24

arrayfire-data

ArrayFire Test Data
5
star
25

ITK-ArrayFire-Bridge-Tutorial

Hands-on tutorial on how to combine ITK with ArrayFire http://www.itk.org
C++
5
star
26

arrayfire-benchmark

Benchmark software for ArrayFire
C++
5
star
27

arrayfire-d

D-lang bindings for arrayfire
D
4
star
28

afQuantumSim

ArrayFire Quantum Simulator
C++
4
star
29

threads

C++
4
star
30

d3m-arrayfire-primitives

DARPA D3M TA1 Accelerated Primitives
Python
3
star
31

assets

Assets for the ArrayFire documentation
3
star
32

freetype2

C
2
star
33

arrayfire-lisp

Lisp bindings for ArrayFire
2
star
34

arrayfire-extras

Add-on functionality for the ArrayFire library
2
star
35

arrayfire-binary-python-wrapper

A python thin wrapper for ArrayFire library
Python
2
star
36

arrayfire-torch

Torch wrapper for ArrayFire
1
star
37

arrayfire.github.io

ArrayFire documentation
HTML
1
star
38

af-sklearn-monkeypatch

Monkey-patch for scikit-learn with accelerated ArrayFire components.
Python
1
star