# Efficient ways to implement a (distributed) matrix-matrix product?

**URL:** https://discourse.julialang.org/t/efficient-ways-to-implement-a-distributed-matrix-matrix-product/79466
**Category:** Numerics
**Tags:** package, linearalgebra, distributed, sparse, matrices
**Created:** [April 14, 2022, 4:40am UTC](https://discourse.julialang.org/t/efficient-ways-to-implement-a-distributed-matrix-matrix-product/79466 "2022-04-14T04:40:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Neo](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Neo](https://discourse.julialang.org/u/Neo)
#### Post date: [April 14, 2022, 4:40am UTC](https://discourse.julialang.org/t/efficient-ways-to-implement-a-distributed-matrix-matrix-product/79466/1 "2022-04-14T04:40:12Z")

</div>

There are a huge sparse matrix A and a tall-and-skinny matrix B (a set of multiple vectors). I want partition them into pieces for parallel distributed-memory matrix-matrix (matrix-vectors) multiplication. Is there any well-known and efficient ways to do this in Julia?

One candidate might be using Distributed.jl and DistributedArrays.jl, but it seems this way does not work well and I cannot get the correct scaling (see my another post [quetions on matrix-matrix products using DistributedArrays](https://discourse.julialang.org/t/why-passing-a-distributed-matrix-to-functions-hurts-performance/79353/2)).

Another candidate might be using PartitionedArrays.jl. But I am actually new to Julia and mpi, the test codes in PartitionedArrays.jl are overwhelming for me to read. What’s more, the authors posted an issue on asking help for implementing matrix-matrix products (see [issues waiting for help in PartitionedArrays.jl](https://github.com/fverdugo/PartitionedArrays.jl/labels/help%20wanted)). So I wonder if it is difficult or not to implement a distributed matrix-vectors product using the package.

Could anyone offer me any advice? Or even an example?

---

<div class="post-metadata">

### Author: ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)
#### Post date: [April 14, 2022, 4:43am UTC](https://discourse.julialang.org/t/efficient-ways-to-implement-a-distributed-matrix-matrix-product/79466/2 "2022-04-14T04:43:07Z")

</div>

I have the similar question, but about dense matrices, not sparse ones.

---

<div class="post-metadata">

### Author: ![fverdugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fverdugo/32/9446_2.png) [@fverdugo](https://discourse.julialang.org/u/fverdugo)
#### Post date: [February 27, 2024, 4:30pm UTC](https://discourse.julialang.org/t/efficient-ways-to-implement-a-distributed-matrix-matrix-product/79466/3 "2024-02-27T16:30:46Z")

</div>

(sorry for necroposting, but I just stumbled upon this post now)

The distributed sparse matrix-matrix product has been already implemented in [PartitionedArrays.jl](https://github.com/fverdugo/PartitionedArrays.jl).

The [documentation](https://www.francescverdugo.com/PartitionedArrays.jl/stable/) has also been improved meanwhile. Hopefully you don’t find to use the library that difficult anymore.
