MPI域的分解和块Tridiagonal矩阵
我需要一些建议,即如何构建用MPI分解2D域的块三基因矩阵。 让我解释一下,我需要在2D中求解像方程一样的热扩散,然后使用虚拟的笛卡尔拓扑结构在用MPI的块中分解了域。 报道了分解的域 在这里,其中单元格中的数字代表全局索引中的单元格坐标。
例如,当我使用有限差异分散方程式时,我获得了一个块tridiagonal矩阵,例如矩阵中的数字再次是与以前相同的全局索引中的单元格坐标。
腮腺
- 作为
- 我使用
- 求解器
, 1D域(导致Tridiagonal矩阵)也很容易。 问题在于,我无法在每个过程中找到与DO循环分配的清晰的索引序列,因为离散化后计算域(第一个图像)的位置导致矩阵中的非连续元素(第二张图像)。
我知道图形重新排序是由诸如Parmetis之类的库执行的,但是据我所知,它并不能保留原始域分解模式,因为它在矩阵级别上进行了重新定位。 我认为这是一个非常普遍的问题,这应该是微不足道的,但是我看不出一种清晰的方法。
I need some advice regarding how to build a block tri-diagonal matrix having decomposed a 2D domain with MPI.
Let me explain, I need to solve a heat diffusion like equation in 2D, and to do so I decomposed the domain in blocks with MPI using the virtual Cartesian topology.
The decomposed domain is reported
here, where the numbers in the cells represent the cell coordinate in global indices.
When I discretize my equation with finite differences for example, I obtain a block tridiagonal matrix like this, where again the numbers in the matrix are the cell coordinate in the same global indices as before.
As solver I use MUMPS, which requires to input the spars matrix with three vectors for each process containing:
- Global Row indices
- Global Column indices
- Corresponding element entry (the problem coefficient)
In serial it is trivial on how to do this, and in MPI with 1D domain (which leads to a tridiagonal matrix) it is easy as well.
The problem is that I am not able to find a clear sequence of indices to be assigned with do loops on each process, since the position in the computational domain (first image) after the discretization leads to non contiguous elements in the matrix (second image).
I know that graph reordering is performed by libraries such as Parmetis, but from what I understood it does not preserve the original domain decomposition pattern since it reorders at matrix level.
I think this should be trivial to do since it is a very common problem, but I cannot see a clear way to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的分区域基于顺序排序。将其转换为本地订购很棘手。如果您首先在Proc 0上编号所有点会更容易,则在Proc 1上的所有点等。这为您提供了一个具有略有不同结构的矩阵,但是相同的解决方案和很大相同的属性。
Your partitioned domain is based on the sequential ordering. Translating that to local ordering is kinda tricky. It would be easier if you first numbered all points on proc 0, then all points on proc 1, et cetera. That gives you a matrix with a slightly different structure, but the same solution and largely the same properties.
在维克多的建议下,我在“本地”专栏的主要订购后重新排序了矩阵的全局索引。
现在,物理域被映射为:
单击
其中4个左上元素属于该过程,等级为0,左下4个元素,该过程具有等级1等的过程。
在将其移植到Fortran之前,我创建了一个草稿代码来组装矩阵。如果有人遇到同样的问题,我会留在这里。该代码可能会经常简化。
唯一要传递的输入是全局行和列的数量以及行沿行和列的过程数。该代码已使用不同数量的全局行和列以及沿两个方向进行不同数量的过程进行了测试。它应该是灵活的。
但是,请务必检查是否正常工作。
通过删除末端附近的部分,您可以绘制矩阵中每个过程所拥有的元素。
如果绘制了整个矩阵,它将看起来像 this (无线或文本框)
Following the suggestion of Victor, I reordered the global indexing of my matrix following a "local" column major ordering.
Now the physical domain is mapped as:
click
where the 4 top left elements belong to the process with rank 0, the bottom left 4 elements to the process with rank 1 and so on..
I created a draft code to assemble the matrix on Matlab, before porting it on Fortran. I will leave it here if anyone has the same issue. The code can probably be simplified a lot.
The only inputs to be passed are the number of global rows and columns and the number of process along rows and columns. The code has been tested with different number of global rows and columns and different number of process along the two directions. It should be flexible.
However always check if this is working correctly.
By uncommenting the section near the end you can plot the elements owned by each process inside the matrix.
If the overall matrix is plotted it will look something like this (without lines or textboxes)