MPI CART CREATE -1,0(4)-1,1/5) Each of the above two 2D cases may be viewed 0-1(-1)000)01(1)02(1) graphically as a cylinder; the periodic dimension forms the 11()1,0(2)1,1(3)121) circumferential surface while the non-periodic dimension 2-1(-1)2.0{4)2,1(5)22(-1) runs parallel to the cylindrical 30(0)31(1) axIs If both dimensions are periodic, Figure 8.1(b) periods[0]F1, periods[1]=0 the grid resembles a torus. the effects of periodic columns and 1,0(-1)-11(-1) periodic rows are depicted in Figures 8. 1(b)and( c) 0-1(1)000)01(102(0) respectively. The tan-colored cells indicate cyclic boundary 1-1(3)10(2)11(3)12(2) condition in effect 2-1(5)2042.1(5224 30(-1)3,1(-1) Figure 8.1().periods[O]=0; periods[1]=1
MPI_CART_CREATE • Each of the above two 2D cases may be viewed graphically as a cylinder; the periodic dimension forms the circumferential surface while the non-periodic dimension runs parallel to the cylindrical axis. • If both dimensions are periodic, the grid resembles a torus. The effects of periodic columns and periodic rows are depicted in Figures 8.1 (b) and (c), respectively. The tan-colored cells indicate cyclic boundary condition in effect. -1,0 (4) -1,1 (5) 0,-1(-1) 0,0 (0) 0,1 (1) 0,2(-1) 1,-1(-1) 1,0 (2) 1,1 (3) 1,2(-1) 2,-1(-1) 2,0 (4) 2,1 (5) 2,2(-1) 3,0 (0) 3,1 (1) Figure 8.1 (b). periods[0]=1;periods[1]=0 -1,0 (-1) -1,1 (-1) 0,-1(1) 0,0 (0) 0,1 (1) 0,2(0) 1,-1(3) 1,0 (2) 1,1 (3) 1,2(2) 2,-1(5) 2,0 (4) 2,1 (5) 2,2(4) 3,0 (-1) 3,1 (-1) Figure 8.1 (c). periods[0]=0;periods[1]=1
MPI CART CREATE Finally, note that while the processes are arranged logically as a cartesian topology, the processors corresponding to these processes may in fact be scattered physically -even within a shared-memory machine If reorder is set to 1"in C, MPI may reorder the process ranks in the new communicator for potential gain in performance due to, say, the physical proximities of the processes assigned) If reorder is 0 in C, the process rank in the new communicator is identical to its rank in the old communicator
MPI_CART_CREATE • Finally, note that while the processes are arranged logically as a cartesian topology, the processors corresponding to these processes may in fact be scattered physically - even within a shared-memory machine. – If reorder is set to “1” in C, MPI may reorder the process ranks in the new communicator (for potential gain in performance due to, say, the physical proximities of the processes assigned). – If reorder is “0” in C, the process rank in the new communicator is identical to its rank in the old communicator
MPI CART CREATE While having the processes laid out in the Cartesian topology help you write code that's conceivably more readable, many MPl routines recognize only rank number and hence knowing the relationship between ranks and Cartesian coordinates (as shown in the figures above)is the key to exploit the topology for computational advantages. In the following sections, we will discuss two subroutines that provide this information. They are MPI CART COORDS MPI CART RANK
MPI_CART_CREATE • While having the processes laid out in the Cartesian topology help you write code that's conceivably more readable, many MPI routines recognize only rank number and hence knowing the relationship between ranks and Cartesian coordinates (as shown in the figures above) is the key to exploit the topology for computational advantages. In the following sections, we will discuss two subroutines that provide this information. They are – MPI_CART_COORDS – MPI_CART_RANK
MPI CART CREATE Note: MPI CART CREATE is a collective communication function(see Chapter 6-Collective Communications). It must be called by all processes in the group Like other collective communication routines, MPI CART CREATE uses blocking communication However, it is not required to be synchronized among processes in the group and hence is implementation dependent If the total size of the cartesian grid is smaller than available processes, those processes not included in the new communicator will return MP COMM NULl If the total size of the Cartesian grid is larger than available processes, the call results in error
MPI_CART_CREATE • Note: – MPI_CART_CREATE is a collective communication function (see Chapter 6 - Collective Communications). It must be called by all processes in the group. Like other collective communication routines, MPI_CART_CREATE uses blocking communication. However, it is not required to be synchronized among processes in the group and hence is implementation dependent. – If the total size of the Cartesian grid is smaller than available processes, those processes not included in the new communicator will return MPI_COMM_NULL. – If the total size of the Cartesian grid is larger than available processes, the call results in error
MPI CART COORDS Definition of mpl cart coords Used to translate the coordinates of the process from rank, the inverse of MPI CaRt ranK The mP cart coords routine returns the corresponding Cartesian coordinates of a(linear) rank in a cartesian communicator int MPl Cart coords( MPI Comm comm, int rank, int maxims, int*coords The function returns an int error flag
MPI_CART_COORDS • Definition of MPI_CART_COORDS – Used to translate the coordinates of the process from rank, the inverse of MPI_CART_RANK. • The MPI_CART_COORDS routine returns the corresponding Cartesian coordinates of a (linear) rank in a Cartesian communicator. int MPI_Cart_coords( MPI_Comm comm, int rank, int maxdims, int *coords ) • The function returns an int error flag