Upload
patricia-edwards
View
213
Download
0
Embed Size (px)
Citation preview
Non-Blocking I/O
CS550Operating Systems
Outline
• Continued discussion of semaphores from the previous lecture notes, as necessary.
• MPI Types• What is non-blocking I/O?• Review of MPI_Irecv and MPI_Isend• Example Code
MPI Types
MPI_CHAR MPI_LONGMPI_SHORT MPI_FLOATMPI_INT MPI_DOUBLE
• Many other types exist• These types are analogous to C primitive types• See the MPI Reference Manual for more
examples
Blocking I/O
• In blocking I/O, when a message is sent, a process waits until it has acknowledgement that the message has been received before it can continue processing.
• Similarly, when a message is requested (a receive method/function is called) the program waits until the message has been received before continuing processing.
Blocking I/O Example
Process1 Process2+------------+ 1.send msg +------------+|MPI_Send | --------> |MPI_Recv ||wait for ack| |wait for msg||ack received| <-------- |ack receipt ||3b.continue | 2.send ack |3a.continue |+------------+ +------------+
Non-Blocking I/O
• Non-blocking I/O allows for messages to be sent or requested for receipt without waiting for an acknowledgement that the message has been received.
• This means that programs may continue processing immediately after sending a message or after requesting that a message be received.
Non-Blocking I/O Example
Process1 Process2+------------+ 1.send msg +-------------+|MPI_Isend | --------> |MPI_Irecv ||2a.continue | |2b.continue || | |3. Do WORK || | |MPI_Wait || | |4.wait on msg|| | |5.work on msg|+------------+ +-------------+
Non-Blocking I/O Example 2
Process1 Process2+------------+ +-------------+| | |MPI_Irecv ||1a.Do WORK | |1b.continue || | |2. Do WORK || | |MPI_Wait || MPI_Isend | 5.send msg |4.wait on msg|| | --------> |6.work on msg|+------------+ +-------------+
MPI Non-blocking I/O Functions
• MPI_Get_count – used to determine the length of a received message
• MPI_Irecv – non-blocking receive• MPI_Isend – non-blocking send• MPI_Wait – waits for one message to be received after
performing a non-blocking send.• MPI_Waitall – waits for all specified messages (e.g. a
list of messages) to be received.• MPI_Wait_some – waits for at least one message out of
a list of messages to be received, then continues processing
Example Code
• See the non-blocking I/O examples from the course webpage