学习资料 《并行算法实践》 (陈国良 等)
学习笔记
虚拟进程拓扑概念
在许多应用程序中,进程的线性排列不能充分地反映进程间在逻辑上的通信模型(通常由问题几何和所用的算法决定),进程经常排列成二维或三维网格形式的拓扑模型,而且,通常用一个图来描述逻辑进程排列, 这种逻辑进程排列称为“虚拟拓扑”。拓扑是组内通信域上的额外、可选的属性,它不能附加在组间通信域上(inter-communicator)上。
虚拟进程拓扑有两种类型:具有规则的网格形状的笛卡儿拓扑 和 具有任意形状的图拓扑。
(NOTE: 这里根据规则与否,分成笛卡儿拓扑 和 图拓扑 两种,这里的笛卡儿拓扑,联想到的是 笛卡儿坐标)
笛卡儿拓扑和图拓扑调用的简单对比如下,这里的主要操作为:创建、得到维度、得到拓扑信息、物理映射。
---------------------------------------------------------------------------------------------------------------------------
操作 笛卡儿拓扑 图拓扑
创建 MPI_CART_CREATE MPI_GRAPH_CREATE
得到维数 MPI_CARTDIM_GET MPI_GRAPHDIMS_GET
得到拓扑信息 MPI_CART_GET MPI_GRAPH_GET
物理映射 MPI_CART_MAP MPI_GRAPH_MAP
------------------------------------------------------------------------------------------------------------------------------
主要函数
笛卡儿拓扑
int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims, int *periods, int reorder, MPI_Comm *comm_cart)
int MPI_Cart_get( MPI_Comm comm, int maxdims, int *dims, int *periods, int *coords)
int MPI_Cart_rank( MPI_Comm comm, int *coords, int *rank)
int MPI_Cartdim_get( MPI_Comm comm, int *ndims)
int MPI_Cart_shift( MPI_Comm comm, int direction, int disp, int *rank_source, int *rank_dest)
int MPI_Cart_coords( MPI_Comm comm, int rank, int maxdims, in *coords)
int MPI_Cart_sub( MPI_Comm comm, int *remain_dims, MPI_Comm *newcomm)
int MPI_Cart_map(MPI_Comm comm, int ndims , int *dims, int *periods,int *newrank)
图拓扑
int MPI_Graph_create(MPI_Comm comm_old, int nnodes, int *index, int *edges, int reorder, MPI_Comm *comm_graph)
int MPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges)
int MPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int *index, int *edges)
int MPI_Graph_neighbors_count( MPI_Comm comm, int rank, int *nneighbors)
int MPI_Graph_neighbors_count( MPI_Comm comm, int rank, int maxneighbors, int *neighbors)
int MPI_Graph_map(MPI_Comm comm, int nodes, int *index, int *edges, int *newrank)
浙公网安备 33010602011771号