1 / 17

Collectives

Collectives. Reduce Scatter Gather Many more. Prototype of MPI_Reduce(). int MPI_Reduce ( void *operand, /* addr of 1st reduction element */ void *result, /* addr of 1st reduction result */ int count,

wightman
Download Presentation

Collectives

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. Collectives • Reduce • Scatter • Gather • Many more

  2. Prototype of MPI_Reduce() int MPI_Reduce ( void *operand, /* addr of 1st reduction element */ void *result, /* addr of 1st reduction result */ int count, /* reductions to perform */ MPI_Datatype type, /* type of elements */ MPI_Op operator, /* reduction operator */ int root, /* process getting result(s) */ MPI_Comm comm /* communicator */ )

  3. MPI_Datatype Options • MPI_CHAR • MPI_DOUBLE • MPI_FLOAT • MPI_INT • MPI_LONG • MPI_LONG_DOUBLE • MPI_SHORT • MPI_UNSIGNED_CHAR • MPI_UNSIGNED • MPI_UNSIGNED_LONG • MPI_UNSIGNED_SHORT

  4. MPI_Op Options • MPI_BAND • MPI_BOR • MPI_BXOR • MPI_LAND • MPI_LOR • MPI_LXOR • MPI_MAX • MPI_MAXLOC • MPI_MIN • MPI_MINLOC • MPI_PROD • MPI_SUM

  5. Only process 0 will get the result Our Call to MPI_Reduce() MPI_Reduce (&count, &global_count, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if (!id) printf ("There are %d different solutions\n", global_count);

  6. MPI_Allgatherv

  7. MPI_Allgatherv int MPI_Allgatherv ( void *send_buffer, int send_cnt, MPI_Datatype send_type, void *receive_buffer, int *receive_cnt, int *receive_disp, MPI_Datatype receive_type, MPI_Comm communicator)

  8. MPI_Allgatherv in Action

  9. File Reading a Block-Column Matrix

  10. MPI_Scatterv

  11. Header for MPI_Scatterv int MPI_Scatterv ( void *send_buffer, int *send_cnt, int *send_disp, MPI_Datatype send_type, void *receive_buffer, int receive_cnt, MPI_Datatype receive_type, int root, MPI_Comm communicator)

  12. Printing a Block-Column Matrix • Data motion opposite to that we did when reading the matrix • Replace “scatter” with “gather” • Use “v” variant because different processes contribute different numbers of elements

  13. Function MPI_Gatherv

  14. Header for MPI_Gatherv int MPI_Gatherv ( void *send_buffer, int send_cnt, MPI_Datatype send_type, void *receive_buffer, int *receive_cnt, int *receive_disp, MPI_Datatype receive_type, int root, MPI_Comm communicator)

  15. Function MPI_Alltoallv

  16. Header for MPI_Alltoallv int MPI_Gatherv ( void *send_buffer, int *send_cnt, int *send_disp, MPI_Datatype send_type, void *receive_buffer, int *receive_cnt, int *receive_disp, MPI_Datatype receive_type, MPI_Comm communicator)

  17. create_mixed_xfer_arrays builds these Count/Displacement Arrays • MPI_Alltoallv requires two pairs of count/displacement arrays • First pair for values being sent • send_cnt: number of elements • send_disp: index of first element • Second pair for values being received • recv_cnt: number of elements • recv_disp: index of first element

More Related