SlideShare a Scribd company logo
1 of 22
MPI Communications

Point to Point
Collective Communication
Data Packaging
Point-to-Point Communication
Send and Receive
• MPI_Send/MPI_Recv provide point-to-
  point communication
  – synchronization protocol is not fully specified.
     • what are possibilities?
Send and Receive
Synchronization
• Fully Synchronized (Rendezvous)
  – Send and Receive complete simultaneously
     • whichever code reaches the Send/Receive first waits
  – provides synchronization point (up to network
    delays)
• Buffered
  – Receive must wait until message is received
  – Send completes when message is moved to buffer
    clearing memory of message for reuse
Send and Receive Synchronization
• Asynchronous
  – Sending process may proceed immediately
     • does not need to wait until message is copied to buffer
     • must check for completion before using message
       memory
  – Receiving process may proceed immediately
     • will not have message to use until it is received
     • must check for completion before using message
MPI Send and Receive
• MPI_Send/MPI_Recv are synchronous,
  but buffering is unspecified
  – MPI_Recv suspends until message is received
  – MPI_Send may be fully synchronous or may
    be buffered
     • implementation dependent
• Variations allow synchronous or buffering
  to be specified
Asynchronous Send and Receive
• MPI_Isend() / MPI_Irecv() are
  non-blocking. Control returns to program
  after call is made.
• Syntax is the same as for Send and Recv,
  except a MPI_Request* parameter is added
  to Isend and replaces the MPI_Status* for
  receive.
Detecting Completion
• MPI_Wait(&request, &status)
   – request matches request on Isend or Irecv
  – status returns status equivalent to
           status for Recv when complete
  – Blocks for send until message is buffered or sent so
    message variable is free
  – Blocks for receive until message is received and
    ready
Detecting Completion
• MPI_Test(&request, flag, &status)
  – request, status as for MPI_Wait
  – does not block
  – flag indicates whether message is sent/received
  – enables code which can repeatedly check for communication
    completion
Collective Communications

• One to Many (Broadcast, Scatter)
• Many to One (Reduce, Gather)
• Many to Many (All Reduce, Allgather)
Broadcast
• A selected processor sends to all other
  processors in the communicator
• Any type of message can be sent
• Size of message should be known by all (it
  could be broadcast first)
• Can be optimized within system for any
  given architecture
MPI_Bcast() Syntax
MPI_Bcast(mess, count, MPI_INT,
           root, MPI_COMM_WORLD);
mess    pointer to message buffer
count   number of items sent
MPI_INT type of item sent
        Note: count and type should be the same
              on all processors
root    sending processor
MPI_COMM_WORLD        communicator within which
                      broadcast takes place
MPI_Barrier()
MPI_Barrier(MPI_COMM_WORLD);
MPI_COMM_WORLD  communicator within which
                broadcast takes place

provides for barrier synchronization without message of
  broadcast
Reduce

• All Processors send to a single processor,
  the reverse of broadcast
• Information must be combined at receiver
• Several combining functions available
  – MAX, MIN, SUM, PROD, LAND, BAND,
    LOR, BOR, LXOR, BXOR, MAXLOC,
    MINLOC
MPI_Reduce() syntax
MPI_Reduce(&dataIn, &result, count,
             MPI_DOUBLE, MPI_SUM, root,
             MPI_COMM_WORLD);
dataIn   data sent from each processor
result   stores result of combining operation
count    number of items in each of dataIn, result
MPI_DOUBLE      data type for dataIn, result
MPI_SUM combining operation
root     rank of processor receiving data
MPI_COMM_WORLD         communicator
MPI_Reduce()

• Data and result may be arrays -- combining
  operation applied element-by-element
• Illegal to alias dataIn and result
  – avoids large overhead in function definition
MPI_Scatter()

• Spreads array to all processors
• Source is an array on the sending processor
• Each receiver, including sender, gets a piece of
  the array corresponding to their rank in the
  communicator
MPI_Gather()

• Opposite of Scatter
• Values on all processors (in the communicator)
  are collected into an array on the receiver
• Array locations correspond to ranks of
  processors
Collective Communications,
    underneath the hood
Many to Many Communications

• MPI_Allreduce
  – Syntax like reduce, except no root parameter
  – All nodes get result
• MPI_Allgather
  – Syntax like gather, except no root parameter
  – All nodes get resulting array
• Underneath -- virtual butterfly network
Data packaging
• Needed to combine irregular, non-
  contiguous data into single message
• pack -- unpack, explicitly pack data into a
  buffer, send, unpack data from buffer
• Derived data types, MPI heterogeneous data
  types which can be sent as a message
MPI_Pack() syntax
MPI_Pack(Aptr, count, MPI_DOUBLE,
   buffer, size, &pos, MPI_COMM_WORLD);

Aptr     pointer to data to pack
count    number of items to pack
         type of items
buffer   buffer being packed
size     size of buffer (in bytes)
pos      position in buffer (in bytes), updated
         communicator
MPI_Unpack()
• reverses operation of MPI_Pack()

MPI_Unpack(buffer, size, &pos,
  Aptr, count, MPI_DOUBLE,
  MPI_COMM_WORLD);

More Related Content

What's hot

MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
Rohit Banga
 

What's hot (20)

Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Remote Procedure Call in Distributed System
Remote Procedure Call in Distributed SystemRemote Procedure Call in Distributed System
Remote Procedure Call in Distributed System
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
RPC: Remote procedure call
RPC: Remote procedure callRPC: Remote procedure call
RPC: Remote procedure call
 
message passing
 message passing message passing
message passing
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
 
Transport Layer In Computer Network
Transport Layer In Computer NetworkTransport Layer In Computer Network
Transport Layer In Computer Network
 
Lamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusionLamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusion
 
Point-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIPoint-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPI
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Lec 4 (program and network properties)
Lec 4 (program and network properties)Lec 4 (program and network properties)
Lec 4 (program and network properties)
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
 
The Message Passing Interface (MPI) in Layman's Terms
The Message Passing Interface (MPI) in Layman's TermsThe Message Passing Interface (MPI) in Layman's Terms
The Message Passing Interface (MPI) in Layman's Terms
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented Model
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
 
Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
 
Multi Processors And Multi Computers
 Multi Processors And Multi Computers Multi Processors And Multi Computers
Multi Processors And Multi Computers
 

Similar to Message passing interface

Similar to Message passing interface (20)

Chap6 slides
Chap6 slidesChap6 slides
Chap6 slides
 
My ppt hpc u4
My ppt hpc u4My ppt hpc u4
My ppt hpc u4
 
More mpi4py
More mpi4pyMore mpi4py
More mpi4py
 
Open MPI 2
Open MPI 2Open MPI 2
Open MPI 2
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMP
 
MPI
MPIMPI
MPI
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
 
Lecture9
Lecture9Lecture9
Lecture9
 
Ch03
Ch03Ch03
Ch03
 
Chapter 3 - Processes
Chapter 3 - ProcessesChapter 3 - Processes
Chapter 3 - Processes
 
Move Message Passing Interface Applications to the Next Level
Move Message Passing Interface Applications to the Next LevelMove Message Passing Interface Applications to the Next Level
Move Message Passing Interface Applications to the Next Level
 
Mpi
Mpi Mpi
Mpi
 
Characterization of communication.ppt
Characterization of communication.pptCharacterization of communication.ppt
Characterization of communication.ppt
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
High Performance Computing using MPI
High Performance Computing using MPIHigh Performance Computing using MPI
High Performance Computing using MPI
 
Lecture5
Lecture5Lecture5
Lecture5
 
Cs556 section3
Cs556 section3Cs556 section3
Cs556 section3
 
Cs556 section3
Cs556 section3Cs556 section3
Cs556 section3
 
Chapter 4 communication2
Chapter 4 communication2Chapter 4 communication2
Chapter 4 communication2
 

More from Md. Mahedi Mahfuj

More from Md. Mahedi Mahfuj (20)

Bengali optical character recognition system
Bengali optical character recognition systemBengali optical character recognition system
Bengali optical character recognition system
 
Parallel computing chapter 3
Parallel computing chapter 3Parallel computing chapter 3
Parallel computing chapter 3
 
Parallel computing chapter 2
Parallel computing chapter 2Parallel computing chapter 2
Parallel computing chapter 2
 
Parallel computing(2)
Parallel computing(2)Parallel computing(2)
Parallel computing(2)
 
Parallel computing(1)
Parallel computing(1)Parallel computing(1)
Parallel computing(1)
 
Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architecture
 
Parallel searching
Parallel searchingParallel searching
Parallel searching
 
Clustering manual
Clustering manualClustering manual
Clustering manual
 
Matrix multiplication graph
Matrix multiplication graphMatrix multiplication graph
Matrix multiplication graph
 
Strategy pattern
Strategy patternStrategy pattern
Strategy pattern
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
Database management system chapter16
Database management system chapter16Database management system chapter16
Database management system chapter16
 
Database management system chapter15
Database management system chapter15Database management system chapter15
Database management system chapter15
 
Database management system chapter12
Database management system chapter12Database management system chapter12
Database management system chapter12
 
Strategies in job search process
Strategies in job search processStrategies in job search process
Strategies in job search process
 
Report writing(short)
Report writing(short)Report writing(short)
Report writing(short)
 
Report writing(long)
Report writing(long)Report writing(long)
Report writing(long)
 
Job search_resume
Job search_resumeJob search_resume
Job search_resume
 
Job search_interview
Job search_interviewJob search_interview
Job search_interview
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Message passing interface

  • 1. MPI Communications Point to Point Collective Communication Data Packaging
  • 2. Point-to-Point Communication Send and Receive • MPI_Send/MPI_Recv provide point-to- point communication – synchronization protocol is not fully specified. • what are possibilities?
  • 3. Send and Receive Synchronization • Fully Synchronized (Rendezvous) – Send and Receive complete simultaneously • whichever code reaches the Send/Receive first waits – provides synchronization point (up to network delays) • Buffered – Receive must wait until message is received – Send completes when message is moved to buffer clearing memory of message for reuse
  • 4. Send and Receive Synchronization • Asynchronous – Sending process may proceed immediately • does not need to wait until message is copied to buffer • must check for completion before using message memory – Receiving process may proceed immediately • will not have message to use until it is received • must check for completion before using message
  • 5. MPI Send and Receive • MPI_Send/MPI_Recv are synchronous, but buffering is unspecified – MPI_Recv suspends until message is received – MPI_Send may be fully synchronous or may be buffered • implementation dependent • Variations allow synchronous or buffering to be specified
  • 6. Asynchronous Send and Receive • MPI_Isend() / MPI_Irecv() are non-blocking. Control returns to program after call is made. • Syntax is the same as for Send and Recv, except a MPI_Request* parameter is added to Isend and replaces the MPI_Status* for receive.
  • 7. Detecting Completion • MPI_Wait(&request, &status) – request matches request on Isend or Irecv – status returns status equivalent to status for Recv when complete – Blocks for send until message is buffered or sent so message variable is free – Blocks for receive until message is received and ready
  • 8. Detecting Completion • MPI_Test(&request, flag, &status) – request, status as for MPI_Wait – does not block – flag indicates whether message is sent/received – enables code which can repeatedly check for communication completion
  • 9. Collective Communications • One to Many (Broadcast, Scatter) • Many to One (Reduce, Gather) • Many to Many (All Reduce, Allgather)
  • 10. Broadcast • A selected processor sends to all other processors in the communicator • Any type of message can be sent • Size of message should be known by all (it could be broadcast first) • Can be optimized within system for any given architecture
  • 11. MPI_Bcast() Syntax MPI_Bcast(mess, count, MPI_INT, root, MPI_COMM_WORLD); mess pointer to message buffer count number of items sent MPI_INT type of item sent Note: count and type should be the same on all processors root sending processor MPI_COMM_WORLD communicator within which broadcast takes place
  • 12. MPI_Barrier() MPI_Barrier(MPI_COMM_WORLD); MPI_COMM_WORLD communicator within which broadcast takes place provides for barrier synchronization without message of broadcast
  • 13. Reduce • All Processors send to a single processor, the reverse of broadcast • Information must be combined at receiver • Several combining functions available – MAX, MIN, SUM, PROD, LAND, BAND, LOR, BOR, LXOR, BXOR, MAXLOC, MINLOC
  • 14. MPI_Reduce() syntax MPI_Reduce(&dataIn, &result, count, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD); dataIn data sent from each processor result stores result of combining operation count number of items in each of dataIn, result MPI_DOUBLE data type for dataIn, result MPI_SUM combining operation root rank of processor receiving data MPI_COMM_WORLD communicator
  • 15. MPI_Reduce() • Data and result may be arrays -- combining operation applied element-by-element • Illegal to alias dataIn and result – avoids large overhead in function definition
  • 16. MPI_Scatter() • Spreads array to all processors • Source is an array on the sending processor • Each receiver, including sender, gets a piece of the array corresponding to their rank in the communicator
  • 17. MPI_Gather() • Opposite of Scatter • Values on all processors (in the communicator) are collected into an array on the receiver • Array locations correspond to ranks of processors
  • 18. Collective Communications, underneath the hood
  • 19. Many to Many Communications • MPI_Allreduce – Syntax like reduce, except no root parameter – All nodes get result • MPI_Allgather – Syntax like gather, except no root parameter – All nodes get resulting array • Underneath -- virtual butterfly network
  • 20. Data packaging • Needed to combine irregular, non- contiguous data into single message • pack -- unpack, explicitly pack data into a buffer, send, unpack data from buffer • Derived data types, MPI heterogeneous data types which can be sent as a message
  • 21. MPI_Pack() syntax MPI_Pack(Aptr, count, MPI_DOUBLE, buffer, size, &pos, MPI_COMM_WORLD); Aptr pointer to data to pack count number of items to pack type of items buffer buffer being packed size size of buffer (in bytes) pos position in buffer (in bytes), updated communicator
  • 22. MPI_Unpack() • reverses operation of MPI_Pack() MPI_Unpack(buffer, size, &pos, Aptr, count, MPI_DOUBLE, MPI_COMM_WORLD);