SlideShare a Scribd company logo
1 of 26
Download to read offline
PARALLEL AND DISTRIBUTED COMPUTING
MESSAGE PASSING INTERFACE (MPI)
MPI INTRODUCTION
 The first difference is in the price of communication, time
needed to exchange certain amount of data between
processors
 MPI is a standardized means of exchanging messages between
multiple computers running a parallel program across
distributed memory
MPI (MESSAGE PASSING INTERFACE)
 MPI is not a language but all MPI operations are expressed as
functions or subroutines
 MPI Standard defines the syntax and semantics of operations
 MPI Program consists of autonomous process that are able to
execute their own code in the sense of MIMD
MPI (MESSAGE PASSING INTERFACE)
 MPI provides at least two operations
 send(message) and receive(message)
Message sent by a process can be of either fixed or variable size
Fixed Size: system level implementation is straightforward but make
the task of programming more difficult
Variable size: system level implementation is difficult but makes task
programming more simpler.
MPI (MESSAGE PASSING INTERFACE)
 If process P and Q want to communicate, they send messages
to and receive messages from each other
 So we need a communication link between them
HELLO WORD
#include <stdio.h>
#include <mpi.h>
main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
printf("Hello worldn");
MPI_Finalize();
}
 Header file mpi.h must be included to compile MPI Code.
 MPI-Init() from this point processes can collaborate,
send/receive message until MPI-Finalize()
 finalizing leads to freeing all the resources reserved by MPI.
BASIC DATA TYPES RECOGNIZED BY MPI
MPI DATATYPE HANDLE C DATATYPE
MPI_INT Int
MPI_SHORT Short
MPI_LONG Long
MPI_FLOAT Float
MPI_DOUBLE Double
MPI_CHAR Char
 MPI also provides routines that let the process determine its
process ID, as well as the number of processes that have been
created.
 MPI_Comm_size(): returns total number of processes
 MPI_Comm_rank(): returns process id that called the
function
MPI rank us used to specify a particular process
 It is an integer range from 0 to n
 It is necessary for a process to know it rank.
MPI COMMUNICATOR
 A process group and context together form an MPI
Communicator
 MPI Communicator – holds a group of processes that can
communicate with each other.
 MPI_COMM_WORLD is default communicator that contains
all processes available for use.
SEND AND RECEIVE MPI
 Process A decides to sent message to process B. Process A pack
up all information into buffer and sent. Process A acknowledged
that data has transmitted
SYNTAX OF SEND OPERATION
MPI_SEND (buf, count, datatype, dest, tag,
comm)
MPI_SEND will not complete until a matching MPI-RECV
Identified
 Buf - pointer to send buffer, data to send
 Count - number of data item (non negative)
 Datatype - type of data
 Dest - receiver address
 Tag - message tag
SYNTAX OF RECEIVE OPERATION
 MPI_RECV (buf, count, datatype, dest, tag, comm, status)
MPI_SEND will not complete until a matching MPI-RECV Identified
 Buf - pointer to send buffer, data to send
 Count - number of data item (non negative)
 Datatype - type of data
 Dest - receiver address
 Tag - message tag
 Comm- communicator (handle)
 Status – contains furter information about
MPI PROGRAM: PROCESS 1TO SEND MESSAGETO PROCESS 2
 int main(int argc, char** argv) {
 int process_Rank, size_Of_Cluster, message_Item;
 MPI_Init(&argc, &argv);
 MPI_Comm_size(MPI_COMM_WORLD, &size_Of_Cluster);
 MPI_Comm_rank(MPI_COMM_WORLD, &process_Rank);
 if(process_Rank == 0){
 message_Item = 42;
 MPI_Send(&message_Item, 1, MPI_INT, 1, 1, MPI_COMM_WORLD);
 printf("Message Sent: %dn", message_Item); }
 else if(process_Rank == 1){
 MPI_Recv(&message_Item, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
 printf("Message Received: %dn", message_Item); }
 MPI_Finalize(); }
COLLECTIVE MPI COMMUNICATION
 MPI Collective operations are called by all processes in a
communicator
 Following are some collective MPI Collective Operations
 MPI_BARRIER
 MPI_BCAST
 MPI_SCATTER
 MPI_GATHER
MPI BARRIERS
 Like many other programming utilities, MPI-Barrier is a process
lock that holds each process at a certain line of code until all
processes have reach that line in code.
 MPI_Barrier can be called as such:
 MPI_Barrier(MPI_Comm comm)
MPI_BCAST
 Implements a one-to-all broadcast operation
 Root process sends its data to all other processes
 MPI_BCAST(inbuf, incnt, intype, root, comm)
 Inbuf: consisting of input data
 Incnt: count number of data
 Intype: type of data
MPI_GATHER
 All-to-one operator, also called by all process in the
communicator.
 Gather data from participating processes into a single structure
MPI_SCATTER
 Break a structure into portions and distribute those portions
to other processes
 Inverse of MPI_Gather
 Data is scattered to other processes into equal parts
COLLECTIVE MPI DATA MANIPULATIONS
 MPI Provides a set of operations that performs simple
manipulations on the transferred data
 Manipulation are based on data reduction paradigm that reduce
data into smaller set of data.
COLLECTIVE MPI DATA MANIPULATIONS
 MPI_Max, MPI_Min: return maximum or minimum of data item
 MPI_Sum, MPI_Prod: Return sum or product of all data items
 MPI_LAND, MPI_LOR, MPI_BAND, MPI_BOR: return logical or
bitwise operation across data.
MPI REDUCTION
 The MPI Operation that implements al kind of data reduction is
 MPI_Reduce: Works similar to MPI_Gather followed by
manipulation operation in process root.
MPI REDUCTION
 The MPI Operation that implements al kind of data reduction is
 MPI_AllReduce: Works as MPI_Reduce followed by MPI_Bcast
 Final result has to be available to all process
POINT-TO-POINT COMMUNICATION (PING-PONG)
 PING-PONG Communication is also called as non-blocking
communication
 Involves sending and receiving between two process back-and-
forth MPI Communication
 Ping pong communication starts by using mpiexec command

More Related Content

Similar to Parallel and Distributed Computing Chapter 10

cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfssuserada6a9
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPIyaman dua
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPIAjit Nayak
 
Tutorial on Parallel Computing and Message Passing Model - C2
Tutorial on Parallel Computing and Message Passing Model - C2Tutorial on Parallel Computing and Message Passing Model - C2
Tutorial on Parallel Computing and Message Passing Model - C2Marcirio Chaves
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI Hanif Durad
 
Rgk cluster computing project
Rgk cluster computing projectRgk cluster computing project
Rgk cluster computing projectOstopD
 
Task communication
Task communicationTask communication
Task communication1jayanti
 
Mpi.net running wizard
Mpi.net running wizardMpi.net running wizard
Mpi.net running wizardAhmed Imair
 
2004 map reduce simplied data processing on large clusters (mapreduce)
2004 map reduce simplied data processing on large clusters (mapreduce)2004 map reduce simplied data processing on large clusters (mapreduce)
2004 map reduce simplied data processing on large clusters (mapreduce)anh tuan
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMPDivya Tiwari
 
Tutorial on Parallel Computing and Message Passing Model - C3
Tutorial on Parallel Computing and Message Passing Model - C3Tutorial on Parallel Computing and Message Passing Model - C3
Tutorial on Parallel Computing and Message Passing Model - C3Marcirio Chaves
 

Similar to Parallel and Distributed Computing Chapter 10 (20)

cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdf
 
Mpi
Mpi Mpi
Mpi
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Tutorial on Parallel Computing and Message Passing Model - C2
Tutorial on Parallel Computing and Message Passing Model - C2Tutorial on Parallel Computing and Message Passing Model - C2
Tutorial on Parallel Computing and Message Passing Model - C2
 
MPI
MPIMPI
MPI
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
 
More mpi4py
More mpi4pyMore mpi4py
More mpi4py
 
Rgk cluster computing project
Rgk cluster computing projectRgk cluster computing project
Rgk cluster computing project
 
Distributed System
Distributed System Distributed System
Distributed System
 
Task communication
Task communicationTask communication
Task communication
 
Message passing interface
Message passing interfaceMessage passing interface
Message passing interface
 
Mpi.net running wizard
Mpi.net running wizardMpi.net running wizard
Mpi.net running wizard
 
Lecture9
Lecture9Lecture9
Lecture9
 
Map reduce
Map reduceMap reduce
Map reduce
 
2004 map reduce simplied data processing on large clusters (mapreduce)
2004 map reduce simplied data processing on large clusters (mapreduce)2004 map reduce simplied data processing on large clusters (mapreduce)
2004 map reduce simplied data processing on large clusters (mapreduce)
 
BASIC_MPI.ppt
BASIC_MPI.pptBASIC_MPI.ppt
BASIC_MPI.ppt
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMP
 
Tutorial on Parallel Computing and Message Passing Model - C3
Tutorial on Parallel Computing and Message Passing Model - C3Tutorial on Parallel Computing and Message Passing Model - C3
Tutorial on Parallel Computing and Message Passing Model - C3
 

More from AbdullahMunir32

Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfAbdullahMunir32
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfAbdullahMunir32
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfAbdullahMunir32
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfAbdullahMunir32
 
Mobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfMobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfAbdullahMunir32
 
Mobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfMobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfAbdullahMunir32
 
Mobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdfMobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdfAbdullahMunir32
 
Mobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdfMobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdfAbdullahMunir32
 
Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13AbdullahMunir32
 
Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12AbdullahMunir32
 
Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11AbdullahMunir32
 
Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9AbdullahMunir32
 
Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8AbdullahMunir32
 
Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7AbdullahMunir32
 
Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6AbdullahMunir32
 
Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5AbdullahMunir32
 
Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4AbdullahMunir32
 
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3AbdullahMunir32
 
Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2AbdullahMunir32
 
Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1AbdullahMunir32
 

More from AbdullahMunir32 (20)

Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdf
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Mobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfMobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdf
 
Mobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfMobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdf
 
Mobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdfMobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdf
 
Mobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdfMobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdf
 
Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13
 
Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12
 
Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11
 
Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9
 
Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8
 
Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7
 
Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6
 
Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5
 
Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4
 
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3
 
Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2
 
Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

Parallel and Distributed Computing Chapter 10

  • 1. PARALLEL AND DISTRIBUTED COMPUTING MESSAGE PASSING INTERFACE (MPI)
  • 2. MPI INTRODUCTION  The first difference is in the price of communication, time needed to exchange certain amount of data between processors  MPI is a standardized means of exchanging messages between multiple computers running a parallel program across distributed memory
  • 3. MPI (MESSAGE PASSING INTERFACE)  MPI is not a language but all MPI operations are expressed as functions or subroutines  MPI Standard defines the syntax and semantics of operations  MPI Program consists of autonomous process that are able to execute their own code in the sense of MIMD
  • 4. MPI (MESSAGE PASSING INTERFACE)  MPI provides at least two operations  send(message) and receive(message) Message sent by a process can be of either fixed or variable size Fixed Size: system level implementation is straightforward but make the task of programming more difficult Variable size: system level implementation is difficult but makes task programming more simpler.
  • 5. MPI (MESSAGE PASSING INTERFACE)  If process P and Q want to communicate, they send messages to and receive messages from each other  So we need a communication link between them
  • 6. HELLO WORD #include <stdio.h> #include <mpi.h> main(int argc, char **argv) { MPI_Init(&argc, &argv); printf("Hello worldn"); MPI_Finalize(); }
  • 7.  Header file mpi.h must be included to compile MPI Code.  MPI-Init() from this point processes can collaborate, send/receive message until MPI-Finalize()  finalizing leads to freeing all the resources reserved by MPI.
  • 8. BASIC DATA TYPES RECOGNIZED BY MPI MPI DATATYPE HANDLE C DATATYPE MPI_INT Int MPI_SHORT Short MPI_LONG Long MPI_FLOAT Float MPI_DOUBLE Double MPI_CHAR Char
  • 9.  MPI also provides routines that let the process determine its process ID, as well as the number of processes that have been created.
  • 10.
  • 11.  MPI_Comm_size(): returns total number of processes  MPI_Comm_rank(): returns process id that called the function MPI rank us used to specify a particular process  It is an integer range from 0 to n  It is necessary for a process to know it rank.
  • 12. MPI COMMUNICATOR  A process group and context together form an MPI Communicator  MPI Communicator – holds a group of processes that can communicate with each other.  MPI_COMM_WORLD is default communicator that contains all processes available for use.
  • 13. SEND AND RECEIVE MPI  Process A decides to sent message to process B. Process A pack up all information into buffer and sent. Process A acknowledged that data has transmitted
  • 14. SYNTAX OF SEND OPERATION MPI_SEND (buf, count, datatype, dest, tag, comm) MPI_SEND will not complete until a matching MPI-RECV Identified  Buf - pointer to send buffer, data to send  Count - number of data item (non negative)  Datatype - type of data  Dest - receiver address  Tag - message tag
  • 15. SYNTAX OF RECEIVE OPERATION  MPI_RECV (buf, count, datatype, dest, tag, comm, status) MPI_SEND will not complete until a matching MPI-RECV Identified  Buf - pointer to send buffer, data to send  Count - number of data item (non negative)  Datatype - type of data  Dest - receiver address  Tag - message tag  Comm- communicator (handle)  Status – contains furter information about
  • 16. MPI PROGRAM: PROCESS 1TO SEND MESSAGETO PROCESS 2  int main(int argc, char** argv) {  int process_Rank, size_Of_Cluster, message_Item;  MPI_Init(&argc, &argv);  MPI_Comm_size(MPI_COMM_WORLD, &size_Of_Cluster);  MPI_Comm_rank(MPI_COMM_WORLD, &process_Rank);  if(process_Rank == 0){  message_Item = 42;  MPI_Send(&message_Item, 1, MPI_INT, 1, 1, MPI_COMM_WORLD);  printf("Message Sent: %dn", message_Item); }  else if(process_Rank == 1){  MPI_Recv(&message_Item, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);  printf("Message Received: %dn", message_Item); }  MPI_Finalize(); }
  • 17. COLLECTIVE MPI COMMUNICATION  MPI Collective operations are called by all processes in a communicator  Following are some collective MPI Collective Operations  MPI_BARRIER  MPI_BCAST  MPI_SCATTER  MPI_GATHER
  • 18. MPI BARRIERS  Like many other programming utilities, MPI-Barrier is a process lock that holds each process at a certain line of code until all processes have reach that line in code.  MPI_Barrier can be called as such:  MPI_Barrier(MPI_Comm comm)
  • 19. MPI_BCAST  Implements a one-to-all broadcast operation  Root process sends its data to all other processes  MPI_BCAST(inbuf, incnt, intype, root, comm)  Inbuf: consisting of input data  Incnt: count number of data  Intype: type of data
  • 20. MPI_GATHER  All-to-one operator, also called by all process in the communicator.  Gather data from participating processes into a single structure
  • 21. MPI_SCATTER  Break a structure into portions and distribute those portions to other processes  Inverse of MPI_Gather  Data is scattered to other processes into equal parts
  • 22. COLLECTIVE MPI DATA MANIPULATIONS  MPI Provides a set of operations that performs simple manipulations on the transferred data  Manipulation are based on data reduction paradigm that reduce data into smaller set of data.
  • 23. COLLECTIVE MPI DATA MANIPULATIONS  MPI_Max, MPI_Min: return maximum or minimum of data item  MPI_Sum, MPI_Prod: Return sum or product of all data items  MPI_LAND, MPI_LOR, MPI_BAND, MPI_BOR: return logical or bitwise operation across data.
  • 24. MPI REDUCTION  The MPI Operation that implements al kind of data reduction is  MPI_Reduce: Works similar to MPI_Gather followed by manipulation operation in process root.
  • 25. MPI REDUCTION  The MPI Operation that implements al kind of data reduction is  MPI_AllReduce: Works as MPI_Reduce followed by MPI_Bcast  Final result has to be available to all process
  • 26. POINT-TO-POINT COMMUNICATION (PING-PONG)  PING-PONG Communication is also called as non-blocking communication  Involves sending and receiving between two process back-and- forth MPI Communication  Ping pong communication starts by using mpiexec command