Skip to content

Commit

Permalink
WIP: Improved CSR matmul
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Dec 9, 2024
1 parent c51f189 commit 1aca6f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/distributed_csr_matmul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ fn main() {

println!("Distributed matrix-vector product successfully executed.");
} else {
// Create a distributed matrix on the non-root node (compare to `from_serial_root`).
dist_mat = DistributedCsrMatrix::from_serial(0, &domain_layout, &range_layout, &world);

// Distribute the vector x.
dist_x.scatter_from(0);

// Execute the distributed matmul.
dist_mat.matmul(1.0, &dist_x, 0.0, &mut dist_y);

// Send the information back to root.
dist_y.gather_to_rank(0);
}
}
11 changes: 11 additions & 0 deletions src/sparse/sparse_mat/distributed_csr_mat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::sparse::index_layout::DefaultDistributedIndexLayout;
use crate::sparse::sparse_mat::csr_mat::CsrMatrix;
use crate::sparse::sparse_mat::SparseMatType;
use crate::sparse::traits::index_layout::IndexLayout;
use crate::RlstResult;
use bempp_ghost::GhostCommunicator;
use itertools::{izip, Itertools};

Expand Down Expand Up @@ -134,6 +135,16 @@ impl<'a, T: RlstScalar + Equivalence, C: Communicator> DistributedCsrMatrix<'a,
self.range_layout
}

/// Create a new distributed CSR matrix from an aij format.
pub fn from_aij(
shape: [usize; 2],
rows: &[usize],
cols: &[usize],
data: &[T],
) -> RlstResult<Self> {
todo!();
}

/// Create from root
pub fn from_serial(
root: usize,
Expand Down

0 comments on commit 1aca6f8

Please sign in to comment.