tailieunhanh - Parallel Programming: for Multicore and Cluster Systems- P24
Parallel Programming: for Multicore and Cluster Systems- P24: Innovations in hardware architecture, like hyper-threading or multicore processors, mean that parallel computing resources are available for inexpensive desktop computers. In only a few years, many standard software products will be based on concepts of parallel programming implemented on such hardware, and the range of applications will be much broader than that of scientific computing, up to now the main application area for parallel computing | 222 5 Message-Passing Programming MPLRecv recvbuf recvcount recvtype root myrank comm status . For a correct execution of MPI_Scatter each process must specify the same root the same data types and the same number of elements. Similar to MPI_Gather there is a generalized version MPI_Scatterv of MPI_Scatter for which the root process can provide data blocks of different sizes. MPI_Scatterv uses the same parameters as MPI_Scatter with the following two changes The integer parameter sendcount is replaced by the integer array sendcounts where sendcounts i denotes the number of elements sent to process i for i 0 . p - 1. There is an additional parameter displs after sendcounts which is also an integer array with p entries displs i specifies from which position in the send buffer of the root process the data block for process i should be taken. The effect of an MPI_Scatterv operation can also be achieved by point-to-point operations The root process executes p send operations MPI_Send sendbuf displs i extent sendcounts i sendtype i i comm and each process executes the receive operation described above. For a correct execution of MPI_Scatterv the entry sendcounts i specified by the root process for process i must be equal to the value of recvcount specified by process i. In accordance with MPI_Gatherv it is required that the arrays sendcounts and displs are chosen such that no entry of the send buffer is sent to more than one process. This restriction is imposed for symmetry reasons with MPI_Gatherv although this is not essential for a correct behavior. The program in Fig. illustrates the use of a scatter operation. Process 0 distributes MPI_Comm comm int rbuf 100 int my_rank root 0 gsize sbuf displs scounts stride 110 MPI_Comm_raiik comm my_rank if my_rank root MPI_Comm_size comm ftgsize sbuf int malloc gsize stride sizeo int displs int malloc gsize sizeof int scounts int malloc gsize sizeof int for i 0 i gsize i displs i i stride scounts i 100 MPI_Scatterv sbuf .
đang nạp các trang xem trước