CS 420 Design of Algorithms - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

CS 420 Design of Algorithms

Description:

signed short int. MPI_SHORT. signed char. MPI_CHAR. C types. MPI types ... MPI_Send send a message. MPI_Send( void* message, int count, MPI_Datatype datatype, ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 18
Provided by: Kar9307
Learn more at: http://www.csee.wvu.edu
Category:

less

Transcript and Presenter's Notes

Title: CS 420 Design of Algorithms


1
CS 420 Design of Algorithms
  • MPI Data Types
  • Basic Message Passing - sends/receives

2
MPI Data Types
  • MPI has a set of its own data type definitions
  • Most MPI types correspond to C types although
    some are unique to MPI
  • C types may vary by implementation
  • MPI types are consistent across implementations
  • Supports portability in parallel applications

3
MPI types and C types
4
MPI types and C types
5
Other MPI Data Types
  • MPI_BYTE
  • MPI_PACKED
  • May be others depending on the implementation

6
MPI send and receive
  • MPI_Send and MPI_Recv are the most elemental
    forms of MPI data communications
  • Provide the core set of functions
  • MPI_Send and MPI_Recv are blocking communications
  • Processing cannot proceed until the communication
    process is complete.

7
MPI_Send send a message
MPI_Send( void message, int count, MPI_
Datatype datatype, int dest, int tag, M
PI_Comm comm)
8
MPI_Send
MPI_Send(a,1,MPI_FLOAT,myrank1,11,MPI_COMM_WORLD)
sends a single float to the next process in
MPI_COMM_WORLD and attaches a tag of 11.
MPI_Send(vect,100, MPI_FLOAT,5,12,
MPI_COMM_WORLD) sends a vector of 100
floats to process 5 in MPI_COMM_WORLD and uses a
tag of 12.
9
MPI_Recv
int MPI_Recv( void message, int count, MP
I_Datatype datatype, int source, int tag, M
PI_Comm comm, MPI_Status status)
10
MPI_Recv
MPI_Recv(x, 1, MPI_FLOAT, lsource, 11,
MPI_COMM_WORLD, status) picks up a message
with a tag11,from the source lsource in
MPI_COMM_WORLD. The status of the transaction is
stored in status. MPI_Recv(xarray, 100,
MPI_FLOAT, xproc, 12, MPI_COMM_WORLD,
status) picks up a message tagged 12 from the
source xproc in MPI_COMM_WORLD. That status of
the transaction is stored in status.
11
MPI_Recv - wildcards
  • MPI_ANY_SOURCE
  • lets MPI_Recv take a message from any source.
    Use as the source parameter
  • MPI_ANY_TAG
  • lets MPI_Recv take a message regardless of its
    tag.

12
Wildcards
  • No wildcards for MPI_Send
  • No wildcards for communicator
  • Send must specify a tag
  • Recv must specify a matching tag or use a
    wildcard

13
MPI_ANY_SOURCE
  • To receive from any process
  • MPI_Recv(x, 1, MPI_FLOAT, MPI_ANY_SOURCE, 11,
    MPI_COMM_WORLD, status)
  • and if you dont care what the tag is-
  • MPI_Recv(x, 1, MPI_FLOAT, lsource, MPI_ANY_TAG,
    MPI_COMM_WORLD,status)

14
MPI_Status
  • Return variable for the results of the
    communication process.
  • A structure
  • Roughly
  • struct MPI_STATUS
  • MPI_SOURCE source
  • MPI_TAG tag
  • MPI_ERROR errormsg

15
MPI_Status
  • Note no byte count in status variable (how many
    bytes received in the message)
  • MPI_Get_count(
  • MPI_Status status,
  • MPI_Datatype datatype,
  • int count_ptr)

16
MPI Basic Core Functions
  • MPI_Init
  • MPI_Comm_rank
  • MPI_Comm_size
  • MPI_Send
  • MPI_Recv
  • MPI_Finalize

17
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com