MPI高级功能:简化代码与优化性能
1. 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 < nprocz-1) ? rank + nprocx * nprocy : MPI_PROC_NULL;
int ibegin = imax *(xcoord )/nprocx;
in
超级会员免费看
订阅专栏 解锁全文
1593

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



