1 / 14

MPI_Gatherv

MPI_Gatherv. CISC372 Fall 2006 Andrew Toy Tom Lynch Bill Meehan. Before. Before. After. Syntax of MPI_Gatherv. int MPI_Gatherv ( void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, int *recvcnts, int *displs, MPI_Datatype recvtype, int root, MPI_Comm comm ).

lawrencia
Download Presentation

MPI_Gatherv

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MPI_Gatherv CISC372 Fall 2006 Andrew Toy Tom Lynch Bill Meehan

  2. Before

  3. Before

  4. After

  5. Syntax of MPI_Gatherv int MPI_Gatherv ( void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, int *recvcnts, int *displs, MPI_Datatype recvtype, int root, MPI_Comm comm )

  6. Input Parameters • sendbuf starting address of send buffer (choice) • sendcount number of elements in send buffer (integer) • sendtype data type of send buffer elements (handle) • recvcounts integer array (of length group size) containing the number of elements that are received from each process (significant only at root) • displs integer array (of length group size). Entry i specifies the displacement relative to recvbuf at which to place the incoming data from process i (significant only at root) • recvtype data type of recv buffer elements (significant only at root) (handle) • root rank of receiving process (integer) • comm communicator (handle)

  7. Output Parameter • recvbuf address of receive buffer (choice, significant only at root)

  8. Notes • Node specified by the “root” parameter determines which node does the actual “gathering” • The “displs” parameter dictates the displacement from the recvbuf where the first item being sent from process i will be stored • Otherwise, MPI_Gatherv operates as a combination of MPI_Send and MPI_Recv with the capability of receiving different amounts of data from each process

  9. When to use Gatherv • MPI_Gatherv is used for when data is in varying lengths and in any order. • Memory does not have to be in any type of order on the root machine. • The root can receive information in any order.

  10. When to use Gatherv • Gatherv could be used if you are searching for all nodes of an array that have a characteristic and you want an array of nodes returned. • Gatherv could have been used in the UNO demonstration if you not only wanted the count of cards that were a color, you actually wanted the card returned.

  11. When to use Gatherv • Gatherv is used to get information that might not be in order or in the same size. • If data length that is sent back in size Gatherv should be used.

  12. #include <stdio.h>#include <mpi.h> main(int argc, char **argv) {int node, size;int send_buffer[6];int recv_buffer[6];int i, j;int rcnt[4] = {0, 1, 2, 3};int displs[4] = {0, 0, 1, 3};    MPI_Init(&argc,&argv);MPI_Comm_rank(MPI_COMM_WORLD, &node);MPI_Comm_size(MPI_COMM_WORLD, &size);    for(i = 0; i< node; i++)  send_buffer[i] = node;    MPI_Gatherv(send_buffer, node, MPI_INT, recv_buffer, rcnt, displs,                MPI_INT, 0, MPI_COMM_WORLD);    if(node ==0){   for(i = 0; i<6; i++)      printf("[%d]", recv_buffer[i]);     printf("\n");    fflush(stdout);}    MPI_Finalize();  }

  13. Sample Run: porsche[32] [~/pp/]> mpirun -np 4 gatherv [1][2][2][3][3][3]

  14. The End

More Related