Code Monkey home page Code Monkey logo

gemm's Introduction

General matrix multiplication (gemm)

First clone this repo and update the submodules by running:

git clone --recurse-submodules https://github.com/davidmallasen/gemm.git
cd gemm

Create gemm shared library in c

In directory gemm_c run:

gcc -fPIC -shared -o libmatrix.so matrix.c

This will create a column-major order matrix multiplication library.

Create gemm executable in fortran/c

In directory gemm_fort run:

mkdir build && cd build
cmake ..
make

To execute run ./bin/gemm_test.out.

The matrix multiplication should print Matrix multiply in c! as it is using the shared library c algorithm.

Python matrix extension

For this you will need a python3 environment with numpy 1.20 installed. For example using pip you can run at the root of the project:

python3 -m venv venv
source venv/bin/activate
pip3 install numpy

In directory gemm_py run:

mkdir build && cd build
cmake ..
make
cp ../run_matrix.py .
python3 run_matrix.py

The python module will be built into the gemm_py/build/ directory. It is in this directory where you should execute python so that it can find the matrix module.

The matrix multiplication should print Matrix multiply in c! as it is using the shared library c algorithm.

Using a custom gemm shared library in c

In this case you should follow the same header as in gemm_c/matrix.h, name the shared library as libmatrix.so and copy it to the gemm_c directory as gemm_c/libmatrix.so. The algorithm should perform the matrix multiplication in column-major order (as in Fortran).

gemm'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.