GithubHelp home page GithubHelp logo

linalg-bench's Introduction

Benchmarks for Rust Linear Algebra Packages

We tested the following packages for performance:

The OpenBlas and NumPy implementations serve as a reference point. Any library should be no slower than NumPy, and ideally as fast as direct calls to OpenBlas.

To keep tests consistent, we ensure that we're only using one thread. In some cases we need to set the OMP_NUM_THREADS=1 environment variable.

We also looked at the following libraries but skipping for the following reasons:

  • simd_linalg - only handles dot and gemv
  • vek - only handles up to 4x4 matrices

Maybe as these libraries improve over time we can take a look, but considering how far behind they are to the others, it might be a while before they ever catch up.

Compiler Dependencies

You will need to install OpenBlas and Fortran:

sudo apt install libopenblas-dev gfortran

Running the Benchmarks

There is a Makefile included, which you can just invoke with make. This will run all the Rust, Python and C benchmarks in one go.

Results

  • nalgebra is quite slow, slower than NumPy in some cases (specially in GEMM).
  • Numpy seems to have a 1 usec minimum latency for any function call.
  • ndarray provides good performance overall, as good as pure OpenBLAS.
  • ndarray beats pure OpenBLAS for the dot product, which is interesting.

results

NOTE - all timings above (the y-axis) are in nanoseconds.

Conclusions

Let's use ndarray, just make sure we compile it with OpenBLAS.

Using ndarray with OpenBLAS

Without OpenBLAS, ndarray is actually very slow. To enable it, add this to your Cargo.toml:

ndarray = { version = "0.14", features = ["blas"] }
blas-src = { version = "0.6.1", default-features = false, features = ["openblas"] }
openblas-src = { version = "0.9", default-features = false, features = ["cblas", "system"] }

linalg-bench's People

Contributors

aleon1138 avatar

Stargazers

 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.