Giter VIP home page Giter VIP logo

distmatrix's Introduction

distmatrix

distmatrix is a lightweight C++ distributed matrix library. It wraps BLACS, ScaLAPACK and MPI-RMA in a user-friendly interface that lets you seamlessly distribute matrices across multiple machines.

Example usage

See the tests directory for more examples.

#include <blacs.h>
#include <distmatrix.h>
...
// initialize BLACS
blacs::initialize();

// create matrix object with default blocking
DistMatrix<int> A(10,10);

// initialize all the elements
A = [](int i, int j){return 2*i + j;};

// synchronize
blacs::barrier();

// all mpi ranks can now read any element of A,
// local or remote
assert(A(3,4) == 10);

// set a matrix element, either local or remote
if(blacs::mpirank == 0) A.set(1,2,-1);
A.fence();

// all ranks can now read that element
assert(A(1,2)==-1);

// finalize BLACS
blacs::finalize();

Features

Design choices

  • 0-based indexing.
  • Column-major memory layout.
  • Reference semantics, i.e. B=A makes B point to the same underlying data as A.
  • Leaving everything accessible to the user. While bad software design, it allows the user to call e.g. ScaLAPACK directly when this library does not wrap the required functionality.

Caveats

  • We use MPI_Win_lock/MPI_Win_unlock around the remote setting and fetching of elements, but that does not guarantee much. Use blacs::barrier() generously.
  • The parenthesis operator cannot be used to set elements, so A(1,2) = 4 does not work. This is because we cannot return a reference to a non-local element. Use A.set(1,2,4) instead.

distmatrix's People

Contributors

anjohan avatar yuuuxie avatar

Stargazers

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