MPI 高级功能:简化代码与优化性能
1. 3D 网格设置
在并行计算中,对于 3D 网格的处理是常见的需求。以下代码展示了如何设置 3D 网格的进程坐标、计算邻居进程以及每个进程的起始和结束索引及大小:
int xcoord = rank%nprocx;
int ycoord = rank/nprocx%nprocy;
int zcoord = rank/(nprocx*nprocy);
int nleft = (xcoord > 0 ) ?
rank - 1 : MPI_PROC_NULL;
int nrght = (xcoord < nprocx-1) ?
rank + 1 : MPI_PROC_NULL;
int nbot = (ycoord > 0 ) ?
rank - nprocx : MPI_PROC_NULL;
int ntop = (ycoord < nprocy-1) ?
rank + nprocx : MPI_PROC_NULL;
int nfrnt = (zcoord > 0 ) ?
rank - nprocx * nprocy : MPI_PROC_NULL;
int nback = (zcoord < n
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



