I have a Matrix<double> on a single core, the result of doing an MPI_Reduce. I want to do the Cholesky, so I need to distribute over multiple cores. What's the easiest/most standard way of doing this in Elemental? Do I need to MPI_Bcast it out to all nodes first, and then move it into a DistMatrix, or is there some way of doing something like:

Matrix<double> A = doSomeStuff();
DistMatrix<double, single-node> AdistSingle( A );
DistMatrix<double> Adist(AdistSingle );

or perhaps:

Matrix<double> A = doSomeStuff();
DistMatrix<double> Adist(A );

1 Answer 1


DistMatrix<T,CIRC,CIRC> was recently created for exactly this situation and stores a fully copy of the matrix on a single process. If you have an $n \times n$ Matrix<double> stored on the root process, you can distribute it as follows:

// Construct an n x n matrix owned by process 0
DistMatrix<double,CIRC,CIRC> ARoot( n, n );
// Have the root process fill the local matrix of ARoot
if( commRank == 0 )
    ARoot.Matrix() = A;
// Redistribute ARoot into the standard matrix distribution
// (via a scatter)
DistMatrix<double> ADist( ARoot );

Note that the DistMatrix<T,CIRC,CIRC> class is very new and that the syntax might be simplified in the near future.

  • $\begingroup$ It might be worth allowing DistMatrix<T,CIRC,CIRC> to accept a Matrix<T> as input, and having the former attach to the latter, so that the extra (n,n) allocation does not take place here. $\endgroup$ Jun 21, 2013 at 10:46
  • $\begingroup$ Agreed, this is planned and only should only take a handful of lines of code, but, as I warned, the distribution is very new. $\endgroup$ Jun 21, 2013 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.