Code Monkey home page Code Monkey logo

gemm_adv's Introduction

Advanced general matrix multiplication (gemm)

First clone this repo by running:

git clone https://github.com/davidmallasen/gemm_adv.git
cd gemm_adv

Install googletest and googlemock for unit testing and build OpenBLAS and LIBXSMM to improve the naive implementation.

To build OpenBLAS in Ubuntu download the tar.gz from OpenBLAS, extract it and run make. Then run make PREFIX=/path/to/installation install.

To build LIBXSMM in Ubuntu download the tar.gz from GitHub, extract it and run make PREFIX=/path/to/installation STATIC=0 install.

Detailed steps can be seen in the Dockerfile.

Set the following environment variables:

export OPENBLAS_NUM_THREADS=1
export OPENBLAS_LIB=/path/to/openblas/lib
export OPENBLAS_INCLUDE=/path/to/openblas/include
export LIBXSMM_LIB=/path/to/libxsmm/lib
export LIBXSMM_INCLUDE=/path/to/libxsmm/include
export LD_LIBRARY_PATH=$OPENBLAS_LIB:$LIBXSMM_LIB:$LD_LIBRARY_PATH

Where OPENBLAS_LIB contains libopenblas.so, LIBXSMM_LIB contains libxsmm.so, OPENBLAS_INCLUDE contains cblas.h and LIBXSMM_INCLUDE contains libxsmm.h. We set the number of threads to 1 to have a better comparison with the naive implementation.

To build the system, in the root of the repo run:

./autogen.sh
./configure
make

Unit testing

To execute the tests for the naive implementation and the OpenBLAS replacement run make check. To get the full output run ./tests/bin/gemm_test, ./tests/bin/openblas_gemm_test or ./tests/bin/libxsmm_gemm_test.

Performance comparisons

To measure the performance of the naive, OpenBLAS and LIBXSMM implementations you can run the measure_performance.sh script. For example:

./scripts/measure_performance.sh bin/naive data/naive_perf.dat
./scripts/measure_performance.sh bin/openblas data/openblas_perf.dat
./scripts/measure_performance.sh bin/libxsmm data/libxsmm_perf.dat

Performance data is given for an intel i7-9750H CPU running on one core. You can visualize the results in the images given or generate new plots using gnuplot with the .gp files.

Note: When using LIBXSMM, the matrices have to be transposed since the library expects column-major order. This could affect the comparison with the other implementations.

Deploying with docker

First create the distribution tarball by running make dist. Or download it from releases.

Then build and run the docker container:

sudo docker build -t gemm_adv-1:latest .
sudo docker run --rm -v `pwd`/data:/gemm_adv-1.0/data -it gemm_adv-1:latest

In the docker container you can run the same tests and performance comparisons as above.

gemm_adv's People

Contributors

davidmallasen avatar

Watchers

 avatar  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.