MPI CART RANK Variable c Type In/Out Description Name comm MPI Comm Input Cartesian Communicator handle coords int Input Array of size ndims specifying Cartesian coordinates nk ran Output Process rank of process specified by y its cartesian coordinates coords
MPI_CART_RANK Variable Name C Type In/Out Description comm MPI_Comm Input Cartesian Communicator handle coords int * Input Array of size ndims specifying Cartesian coordinates rank int Output Process rank of process specified by its Cartesian coordinates, coords
MPI CART RANK MiP Cart create(old comm, ndis, dim size, periods, reorder &new comm) if(lam = root) /only want to do this on one process*/ Ge for(i=0; i<nv; i++)t for(=0; j<mv;j++)t coords[0]=i coords[1]=j; MPI Cart rank(new comm, coords, &rank) printf( %d, %d, %d\n", coords[O), coords[1], rank)
MPI_CART_RANK MPI_Cart_create(old_comm, ndims, dim_size, periods, reorder, &new_comm); if(Iam == root) { /* only want to do this on one process */ for (i=0; i<nv; i++) { for (j=0; j<mv; j++) { coords[0] = i; coords[1] = j; MPI_Cart_rank(new_comm, coords, &rank); printf("%d, %d, %d\n",coords[0],coords[1],rank); } } }
MPI CART RANK Once a cartesian communicator has been established, repeated 0,0(0) 0,1(1) applications of MPI CART RANK for all possible values of the Cartesian coordinates produce a correlation table of the cartesian 1,0(2 1,1(3) coordinates and their corresponding process ranks Shown in Figure 8. 3 below is the resulting Cartesian topology(grid) 2,0(4) 2,1(5) where the index pair i,j"represent row l"and column".The number in parentheses represents the rank number associated with the cartesian coordinates Fiqure 8.3. Cartesian Grid
MPI_CART_RANK • Once a Cartesian communicator has been established, repeated applications of MPI_CART_RANK for all possible values of the Cartesian coordinates produce a correlation table of the Cartesian coordinates and their corresponding process ranks. • Shown in Figure 8.3 below is the resulting Cartesian topology (grid) where the index pair "i,j" represent row "i" and column "j". The number in parentheses represents the rank number associated with the Cartesian coordinates. 0,0 (0) 0,1 (1) 1,0 (2) 1,1 (3) 2,0 (4) 2,1 (5) Figure 8.3. Cartesian Grid
MPI CART RANK Note: This routine is the reciprocal of MPI CART coords Querying for rank number of out-of-range coordinates along the dimension in which periodicity is not enabled is not safe (i.e, results in error)
MPI_CART_RANK • Note: – This routine is the reciprocal of MPI_CART_COORDS. – Querying for rank number of out-of-range coordinates along the dimension in which periodicity is not enabled is not safe (i.e., results in error)
MPI CART SUB Definition of mPl cart sub Used to partition a communicator group into subgroups when MPI CART CREATE has been used to create a Cartesian topology The MPI CaRT SUb routine creates new communicators for subgrids of up to(N-1)dimensions from an N-dimensional Cartesian grid Often after we have created a cartesian grid we wish to further group elements of this grid into subgrids of lower dimensions. Typical operations requiring subgrids include reduction operations such as the computation of row sums, column extremums For instance the subgrids of a 2d Cartesian grid are 1d grids of the individual rows or columns. Similarly, for a 3D Cartesian grid, the subgrids can either be 2D or 1D int MPI Cart sub( MPl Comm old comm, int *belongs, MPI Comm new comm The function returns an int error flag
MPI_CART_SUB • Definition of MPI_CART_SUB – Used to partition a communicator group into subgroups when MPI_CART_CREATE has been used to create a Cartesian topology. • The MPI_CART_SUB routine creates new communicators for subgrids of up to (N-1) dimensions from an N-dimensional Cartesian grid. • Often, after we have created a Cartesian grid, we wish to further group elements of this grid into subgrids of lower dimensions. Typical operations requiring subgrids include reduction operations such as the computation of row sums, column extremums. – For instance, the subgrids of a 2D Cartesian grid are 1D grids of the individual rows or columns. Similarly, for a 3D Cartesian grid, the subgrids can either be 2D or 1D. int MPI_Cart_sub( MPI_Comm old_comm, int *belongs, MPI_Comm *new_comm ) • The function returns an int error flag