如何在 Elemental 中将矩阵转换为 DistMatrix?

计算科学 线性代数 并行计算 网格
2021-12-06 01:11:55

我有Matrix<double>一个单核,是执行MPI_Reduce. 我想做 Cholesky,所以我需要分布在多个核心上。在 Elemental 中执行此操作的最简单/最标准的方法是什么?我是否需要MPI_Bcast先将其发送到所有节点,然后将其移动到 aDistMatrix中,或者是否有某种方法可以执行以下操作:

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

也许:

Matrix<double> A = doSomeStuff();
DistMatrix<double> Adist(A );
1个回答

DistMatrix<T,CIRC,CIRC>最近正是针对这种情况创建的,并将矩阵的完整副本存储在单个进程中。如果你有一个n×n Matrix<double>存储在根进程中,可以按如下方式分发:

// 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 );

请注意,DistMatrix<T,CIRC,CIRC>该类是非常新的,并且在不久的将来可能会简化语法。