6.5.4 拓扑查寻函数

BACKWARD FORWARD


如果一个拓扑已同前面的函数之一一起定义, 那么可以通过查寻函数查看拓扑信息。它们都是局域调用。

MPI_TOPO_TEST(comm, status)

int MPI_Topo_test(MPI_Comm comm, int *status)

MPI_TOPO_TEST(COMM, STATUS, IERROR)

函数MPI_TOPO_TEST返回所赋给通信子的拓扑类型。

输出值STATUS是下面之一:

MPI_GRAPHDIMS_GET(comm, nnodes, nedges)

int MPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges)

MPI_GRAPHDIMS_GET(COMM NNODES, NEDGES, IERROR)

函数MPI_GRAPHDIMS_GET和MPI_GRAPH_GET返回图拓扑信息, 这个信息与由MPI_GRAPH_CREATE产生的通信子相联系。

由MPI_GRAPHDIMS_GET所提供的信息用于建立维向量INDEX和EDGES以正确地调用MPI_GRAPH_GET。

MPI_GRAPH_GET(comm, maxindex, maxedges, index, edges)

int MPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int *index, int *edges)

MPI_GRAPH_GET(COMM, MAXINDEX, MAXEDGES, INDEX, EDGES, IERROR)

MPI_CARTDIM_GET(comm, ndims)

int MPI_Cartdim_get(MPI_Comm comm, int *ndims)

MPI_CARTDIM_GET(COMM, NDIMS, IERROR)

函数MPI_CARTDIM_GET和MPI_CART_GET返回笛卡尔拓扑信息, 这个信息与由MPI_CART_CREATE产生的通信子相联系。

MPI_CART_GET(comm, maxdims, dims, periods, coords)

int MPI_Cart_get(MPI_Comm comm, int maxdims, int *dims, int *periods, int *coords)

MPI_CART_GET(COMM, MAXDIMS, DIMS, PERIODS, COORDS, IERROR)

MPI_CART_RANK(comm, coords, rank)

int MPI_Cart_rank(MPI_Comm comm, int *coords, int *rank)

MPI_CART_RANK(COMM, COORDS, RANK, IERROR)

对于与笛卡尔结构同组的进程, 函数MPI_CART_RANK将逻辑进程坐标翻译成用于点对点例程的进程标识数。

对于periods(i)= true 的第i 维, 如果坐标coords(i)超出范围,即,coords(i)〈 0 或者 coords(i)≥dims(i),那么它会自动切换回间隔0≤coords(i)〈 dims(i)。 对于非周期维,超出范围的坐标是错误的。

MPI_CART_COORDS(comm, rank, maxdims, coords)

int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int *coords)

MPI_CART_COORDS(COMM, RANK, MAXDIMS, COORDS, IERROR)

MPI-CART-COORDS提供反向映射,标识数到坐标的转换。

MPI_GRAPH_NEIGHBORS_COUNT(comm, rank, nneighbors)

int MPI_Graph_neighbors_count(MPI_Comm comm, int rank, int *nneighbors)

MPI_GRAPH_NEIGHBORS_COUNT(COMM, RANK, NNEIGHBORS, IERROR)

MPI-GRAPH-NEIGHBORS-COUNT和MPI-GRAPH-NEIGHBORS提供通用的图拓扑的连接信息。

MPI_GRAPH_NEIGHBORS(comm, rank, maxneighbors, neighbors)

int MPI_Graph_neighbors_count(MPI_Comm comm, int rank, int maxneighbors, int *neighbors)

MPI_GRAPH_NEIGHBORS(COMM, RANK, MAXNEIGHBORS, NEIGHBORS, IERROR)

例6.3 假设comm是一个带有混洗交换拓扑的通信子。组有2n个成员。每一进程标号为,其中而且有三个邻居:exchangeshuffle()=unshuffle。图相连表解释如下,n=3

假设通信子comm存在与其相连的拓扑。下面的代码片断在三种邻居类型中循环,并且每一个执行合适的交换。

C asssume: each process has stored a real number A。

C extract neighborhood information

C perform exchange permutation


Copyright: NPACT BACKWARD FORWARD