MPI CART COORDS Variable c Type In/Out Description Name comm MPI Comm Input Communicator handle rank int Input Calling process rank I maxims int Input Number of dimensions n cartesian topology coords int Output Corresponding cartesian coordinates of rank
MPI_CART_COORDS Variable Name C Type In/Out Description comm MPI_Comm Input Communicator handle rank int Input Calling process rank maxdims int Input Number of dimensions in cartesian topology coords int * Output Corresponding cartesian coordinates of rank
MPI CART COORDS MPI Cart create(old comm, ndims, dim size, periods reorder, &new comm);/ creates communicator y if(lam = root)( /only want to do this on one process*/ for(rank=0; rank<p; rank++)t MP Cart coords(new comm, rank, ndims, &coords) printf(%d, %d\n " rank, coords
MPI_CART_COORDS MPI_Cart_create(old_comm, ndims, dim_size, periods, reorder, &new_comm); /* creates communicator */ if(Iam == root) { /* only want to do this on one process */ for (rank=0; rank<p; rank++) { MPI_Cart_coords(new_comm, rank, ndims, &coords); printf("%d, %d\n ",rank, coords); } }
MPI CART COORDS In the above example, a 0,0(0) 0,1(1) Cartesian communicator is created first Repeated applications of 1,0(2 1,1(3) MPI CART COORDS for all process ranks(input) produce the mapping 2,0(4) 2,1(5) table, shown in Figure 8.2 of process ranks and their corresponding Cartesian Figure 8.2. Cartesian Grid coordinates(output)
MPI_CART_COORDS • In the above example, a Cartesian communicator is created first. • Repeated applications of MPI_CART_COORDS for all process ranks (input) produce the mapping table, shown in Figure 8.2, of process ranks and their corresponding Cartesian coordinates (output). 0,0 (0) 0,1 (1) 1,0 (2) 1,1 (3) 2,0 (4) 2,1 (5) Figure 8.2. Cartesian Grid
MPI CART COORDS Note This routine is the reciprocal of MPI Cart ranK Querying for coordinates of ranks in new comm is not robust; querying for an out-of-range rank results in error Definition of mP cart rank Used to translate logical process coordinates to the ranks of the process in point-to-point routines
MPI_CART_COORDS • Note: – This routine is the reciprocal of MPI_CART_RANK. – Querying for coordinates of ranks in new_comm is not robust; querying for an out-of-range rank results in error. • Definition of MPI_CART_RANK – Used to translate logical process coordinates to the ranks of the process in point-to-point routines
MPI CART RANK Definition of mPl cart rank Used to translate logical process coordinates to the ranks of the process in point-to-point routines The mPl cart rank routine returns the corresponding process rank of the Cartesian coordinates of a cartesian communicator int MPI Cart rank( MPl Comm comm, int *coords, int *rank The function returns an int error flag
MPI_CART_RANK • Definition of MPI_CART_RANK – Used to translate logical process coordinates to the ranks of the process in point-to-point routines. • The MPI_CART_RANK routine returns the corresponding process rank of the Cartesian coordinates of a Cartesian communicator. int MPI_Cart_rank( MPI_Comm comm, int *coords, int *rank ) • The function returns an int error flag