SlideShare uma empresa Scribd logo
1 de 19
Baixar para ler offline
MPI Tutorial
Dhanashree N P
February 24, 2016
Dhanashree N P: MPI Tutorial
MPI - Message Passing Interface
A standard for message passing library
Efficient, Portable, Scalable, Vendor Independent
C, Fortran
Message Passing Parallel Programming Model
MPI-3
Distributed, Shared, Hybrid Memory
Some implementations - OpenMPI, MPICH2, IBM Platform
MPI etc.
Different implementations support different versions and
functionalities of the standard
Use MPI with C for Assignment 2
Dhanashree N P: MPI Tutorial
MPI Routines
MPI Init(), MPI Finalize()
MPI Comm size(), MPI Comm rank()
MPI Get processor name()
MPI Abort(), MPI Get version(), MPI Initialized()
Dhanashree N P: MPI Tutorial
Compilation and Program Execution
mpicc -o test.c test
mpirun -n 4 ./test
Dhanashree N P: MPI Tutorial
Multiple hosts
To run on multiple hosts
mpirun -n 4 -host hostname1,hostname2 ./test
mpirun -n 4 -hostfile filename ./test
(a) etc hosts file
(b) hostfile
Dhanashree N P: MPI Tutorial
Some Points to Note
Only one MPI Init and MPI Finalize in a program
Do not declare functions or variables starting with MPI or
PMPI in the program
Communicators, Groups and Ranks
A communication domain is the set of processes allowed to
communicate with each other.
MPI Comm type variables eg. MPI COMM WORLD
Parameter to all message passing primitives
Each process belongs to many different communication
domains
Rank(task id) of the calling process is a unique integer
identifier in the range 0 to n-1.
Dhanashree N P: MPI Tutorial
Unicast Communication Primitives
Types of Operations
Synchronous, Blocking, Non-blocking, Buffered, Combined
etc.
Blocking v/s Non-blocking
System buffer v/s Application buffer
Order and Fairness
Dhanashree N P: MPI Tutorial
Unicast Communication Primitives
Blocking - MPI Send(), MPI Recv()
MPI Send(buffer,count,type,dest,tag,comm)
MPI Recv(buffer,count,type,source,tag,comm,status)
Non-Blocking- MPI ISend(), MPI IRecv()
MPI Isend(buffer,count,type,dest,tag,comm,request)
MPI Irecv(buffer,count,type,source,tag,comm,request)
buffer - reference to data that has to be sent/received.
count- number of data elements of a particular type.
source - rank of sender, dest - rank of receiver.
tag - MPI ANY TAG or any non-negative integer
comm - by default MPI COMM WORLD
***Make Sure to avoid deadlocks!***
Dhanashree N P: MPI Tutorial
Dhanashree N P: MPI Tutorial
Unicast Communication Routines
Other flavors - Blocking - MPI Ssend(), MPI Bsend(),
MPI Rsend()
Attaching a buffer - size in bytes
MPI Buffer attach (&buffer,size)
MPI Buffer detach (&buffer,size)
Send a message and post a receive before blocking
MPI Sendrecv (&sendbuf,sendcount,sendtype,dest,sendtag,
&recvbuf,recvcount,recvtype,source,recvtag, comm,&status)
Wait functions - MPI Wait, MPI Waitany, MPI Waitall,
MPI Waitsome
Other flavors - Non-Blocking - MPI Issend(), MPI Ibsend(),
MPI Irsend()
Status check functions - MPI Test, MPI Testany, MPI Testall,
MPI Testsome
Dhanashree N P: MPI Tutorial
Collective Communication and Computation Routines
The unicast routines were primarily for communication purposes.
Some of the collective operations support computations. All the
processes that are part of a communicator has to participate in
collective communication.
Three types of collective operations:
Synchronization - wait till all members have reached the
synchronization point
Data movements - broadcast, scatter, gather
Computations - reductions
These can be used with MPI primitive data types.
Dhanashree N P: MPI Tutorial
Collective Communication Routines
MPI Barrier(comm) - Each task executing this is blocked until
all the other tasks of the same group have reached this point.
MPI Bcast(&buffer,count,datatype,root,comm) - The process
with rank ’root’ broadcasts to all other processes in the group
Dhanashree N P: MPI Tutorial
Collective Communication Routines
MPI Scatter(&sendbuf,sendcnt,sendtype,&recvbuf,
recvcnt,recvtype,root,comm ) - The process with rank ’root’
broadcasts to all other processes in the group
MPI Gather(&sendbuf,sendcnt,sendtype,&recvbuf,
recvcnt,recvtype,root,comm ) - Reverse of scatter.
Dhanashree N P: MPI Tutorial
Collective Communication Routines
MPI Allgather(&sendbuf,sendcnt,sendtype,&recvbuf,
recvcnt,recvtype,comm ) - Concatenation of data to all tasks
in a group.
Dhanashree N P: MPI Tutorial
Collective Computation Routines
MPI Reduce(&sendbuf,&recvbuf,count,datatype,op,root,comm)
- Applies a reduction operation on all tasks in the group and
places the result in one task.
MPI Allreduce - collective computation and data movement
operation
MPI MAX, MPI MIN, MPI SUM,MPI PROD, MPI BOR,
MPI BAND etc.
Dhanashree N P: MPI Tutorial
Data Types - MPI Datatype (C Data type)
MPI CHAR (signed char)
MPI SHORT (signed short int)
MPI INT (signed int)
MPI LONG (signed long int)
MPI UNSIGNED CHAR (unsigned char)
MPI UNSIGNED SHORT (unsigned short int)
MPI UNSIGNED LONG (unsigned long int)
MPI UNSIGNED (unsigned int)
MPI FLOAT (float)
MPI DOUBLE (double)
MPI LONG DOUBLE (long double)
MPI BYTE
MPI PACKED
Dhanashree N P: MPI Tutorial
Derived Data Types
The following are used for derived data type creation:
Contiguous
Vector
Indexed
Struct
Dhanashree N P: MPI Tutorial
Derived Data Types - Example using Contiguous
Dhanashree N P: MPI Tutorial
References
Message Passing Interface(MPI) -
https://computing.llnl.gov/tutorials/mpi/
Inter group communications - http://www.mpi-forum.org/
docs/mpi-1.1/mpi-11-html/node114.html
Tutorials - http://mpitutorial.com/tutorials/
Introduction to Parallel Computing by Ananth Grama et al. -
Section 6.3 to Section 6.7
Dhanashree N P: MPI Tutorial

Mais conteúdo relacionado

Mais procurados

Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process CommunicationAdeel Rasheed
 
Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.MITS Gwalior
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Point-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIPoint-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIHanif Durad
 
Message Passing Interface (MPI)-A means of machine communication
Message Passing Interface (MPI)-A means of machine communicationMessage Passing Interface (MPI)-A means of machine communication
Message Passing Interface (MPI)-A means of machine communicationHimanshi Kathuria
 
MPI Presentation
MPI PresentationMPI Presentation
MPI PresentationTayfun Sen
 
What is [Open] MPI?
What is [Open] MPI?What is [Open] MPI?
What is [Open] MPI?Jeff Squyres
 
10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprogramsMunawar Ahmed
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in LinuxTushar B Kute
 
Parallel Programing Model
Parallel Programing ModelParallel Programing Model
Parallel Programing ModelAdlin Jeena
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingguesta40f80
 

Mais procurados (20)

Open MPI
Open MPIOpen MPI
Open MPI
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
message passing
 message passing message passing
message passing
 
MPI
MPIMPI
MPI
 
Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
 
Point-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIPoint-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPI
 
Message Passing Interface (MPI)-A means of machine communication
Message Passing Interface (MPI)-A means of machine communicationMessage Passing Interface (MPI)-A means of machine communication
Message Passing Interface (MPI)-A means of machine communication
 
MPI Presentation
MPI PresentationMPI Presentation
MPI Presentation
 
What is [Open] MPI?
What is [Open] MPI?What is [Open] MPI?
What is [Open] MPI?
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprograms
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Open mp
Open mpOpen mp
Open mp
 
Parallel Programing Model
Parallel Programing ModelParallel Programing Model
Parallel Programing Model
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 
IO buffering
IO bufferingIO buffering
IO buffering
 

Destaque

Destaque (20)

Mpi Java
Mpi JavaMpi Java
Mpi Java
 
message passing interface
message passing interfacemessage passing interface
message passing interface
 
Hello World! with Python
Hello World! with PythonHello World! with Python
Hello World! with Python
 
Dip Unit Test-I
Dip Unit Test-IDip Unit Test-I
Dip Unit Test-I
 
It 4-yr-1-sem-digital image processing
It 4-yr-1-sem-digital image processingIt 4-yr-1-sem-digital image processing
It 4-yr-1-sem-digital image processing
 
Digital image processing unit 1
Digital image processing unit 1Digital image processing unit 1
Digital image processing unit 1
 
Mpi.net tutorial
Mpi.net tutorialMpi.net tutorial
Mpi.net tutorial
 
OGSA
OGSAOGSA
OGSA
 
Globus ppt
Globus pptGlobus ppt
Globus ppt
 
Beowulf cluster
Beowulf clusterBeowulf cluster
Beowulf cluster
 
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
 
Cs6703 grid and cloud computing unit 2
Cs6703 grid and cloud computing unit 2Cs6703 grid and cloud computing unit 2
Cs6703 grid and cloud computing unit 2
 
OpenMP Tutorial for Beginners
OpenMP Tutorial for BeginnersOpenMP Tutorial for Beginners
OpenMP Tutorial for Beginners
 
DIGITAL IMAGE PROCESSING - LECTURE NOTES
DIGITAL IMAGE PROCESSING - LECTURE NOTESDIGITAL IMAGE PROCESSING - LECTURE NOTES
DIGITAL IMAGE PROCESSING - LECTURE NOTES
 
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
 
Previo2- Dispos E/S
Previo2- Dispos E/SPrevio2- Dispos E/S
Previo2- Dispos E/S
 
Lecture 1 for Digital Image Processing (2nd Edition)
Lecture 1 for Digital Image Processing (2nd Edition)Lecture 1 for Digital Image Processing (2nd Edition)
Lecture 1 for Digital Image Processing (2nd Edition)
 
Parallel processing extra
Parallel processing extraParallel processing extra
Parallel processing extra
 
Mpi
Mpi Mpi
Mpi
 
Google cluster architecture
Google cluster architecture Google cluster architecture
Google cluster architecture
 

Semelhante a MPI Tutorial

Collective Communications in MPI
 Collective Communications in MPI Collective Communications in MPI
Collective Communications in MPIHanif Durad
 
Lisandro dalcin-mpi4py
Lisandro dalcin-mpi4pyLisandro dalcin-mpi4py
Lisandro dalcin-mpi4pyA Jorge Garcia
 
Intro to MPI
Intro to MPIIntro to MPI
Intro to MPIjbp4444
 
High Performance Computing using MPI
High Performance Computing using MPIHigh Performance Computing using MPI
High Performance Computing using MPIAnkit Mahato
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10AbdullahMunir32
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPIyaman dua
 
cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfssuserada6a9
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPIAjit Nayak
 
Parallel Programming on the ANDC cluster
Parallel Programming on the ANDC clusterParallel Programming on the ANDC cluster
Parallel Programming on the ANDC clusterSudhang Shankar
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classificationNarayan Kandel
 

Semelhante a MPI Tutorial (20)

Parallel computing(2)
Parallel computing(2)Parallel computing(2)
Parallel computing(2)
 
Collective Communications in MPI
 Collective Communications in MPI Collective Communications in MPI
Collective Communications in MPI
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
 
mpi4py.pdf
mpi4py.pdfmpi4py.pdf
mpi4py.pdf
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
Lisandro dalcin-mpi4py
Lisandro dalcin-mpi4pyLisandro dalcin-mpi4py
Lisandro dalcin-mpi4py
 
MPI
MPIMPI
MPI
 
BASIC_MPI.ppt
BASIC_MPI.pptBASIC_MPI.ppt
BASIC_MPI.ppt
 
Intro to MPI
Intro to MPIIntro to MPI
Intro to MPI
 
High Performance Computing using MPI
High Performance Computing using MPIHigh Performance Computing using MPI
High Performance Computing using MPI
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
 
cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdf
 
More mpi4py
More mpi4pyMore mpi4py
More mpi4py
 
Lecture11
Lecture11Lecture11
Lecture11
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Parallel Programming on the ANDC cluster
Parallel Programming on the ANDC clusterParallel Programming on the ANDC cluster
Parallel Programming on the ANDC cluster
 
hybrid-programming.pptx
hybrid-programming.pptxhybrid-programming.pptx
hybrid-programming.pptx
 
Lecture9
Lecture9Lecture9
Lecture9
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classification
 

Último

ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
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 do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
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
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
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
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Último (20)

ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.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 do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
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
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
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
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 

MPI Tutorial

  • 1. MPI Tutorial Dhanashree N P February 24, 2016 Dhanashree N P: MPI Tutorial
  • 2. MPI - Message Passing Interface A standard for message passing library Efficient, Portable, Scalable, Vendor Independent C, Fortran Message Passing Parallel Programming Model MPI-3 Distributed, Shared, Hybrid Memory Some implementations - OpenMPI, MPICH2, IBM Platform MPI etc. Different implementations support different versions and functionalities of the standard Use MPI with C for Assignment 2 Dhanashree N P: MPI Tutorial
  • 3. MPI Routines MPI Init(), MPI Finalize() MPI Comm size(), MPI Comm rank() MPI Get processor name() MPI Abort(), MPI Get version(), MPI Initialized() Dhanashree N P: MPI Tutorial
  • 4. Compilation and Program Execution mpicc -o test.c test mpirun -n 4 ./test Dhanashree N P: MPI Tutorial
  • 5. Multiple hosts To run on multiple hosts mpirun -n 4 -host hostname1,hostname2 ./test mpirun -n 4 -hostfile filename ./test (a) etc hosts file (b) hostfile Dhanashree N P: MPI Tutorial
  • 6. Some Points to Note Only one MPI Init and MPI Finalize in a program Do not declare functions or variables starting with MPI or PMPI in the program Communicators, Groups and Ranks A communication domain is the set of processes allowed to communicate with each other. MPI Comm type variables eg. MPI COMM WORLD Parameter to all message passing primitives Each process belongs to many different communication domains Rank(task id) of the calling process is a unique integer identifier in the range 0 to n-1. Dhanashree N P: MPI Tutorial
  • 7. Unicast Communication Primitives Types of Operations Synchronous, Blocking, Non-blocking, Buffered, Combined etc. Blocking v/s Non-blocking System buffer v/s Application buffer Order and Fairness Dhanashree N P: MPI Tutorial
  • 8. Unicast Communication Primitives Blocking - MPI Send(), MPI Recv() MPI Send(buffer,count,type,dest,tag,comm) MPI Recv(buffer,count,type,source,tag,comm,status) Non-Blocking- MPI ISend(), MPI IRecv() MPI Isend(buffer,count,type,dest,tag,comm,request) MPI Irecv(buffer,count,type,source,tag,comm,request) buffer - reference to data that has to be sent/received. count- number of data elements of a particular type. source - rank of sender, dest - rank of receiver. tag - MPI ANY TAG or any non-negative integer comm - by default MPI COMM WORLD ***Make Sure to avoid deadlocks!*** Dhanashree N P: MPI Tutorial
  • 9. Dhanashree N P: MPI Tutorial
  • 10. Unicast Communication Routines Other flavors - Blocking - MPI Ssend(), MPI Bsend(), MPI Rsend() Attaching a buffer - size in bytes MPI Buffer attach (&buffer,size) MPI Buffer detach (&buffer,size) Send a message and post a receive before blocking MPI Sendrecv (&sendbuf,sendcount,sendtype,dest,sendtag, &recvbuf,recvcount,recvtype,source,recvtag, comm,&status) Wait functions - MPI Wait, MPI Waitany, MPI Waitall, MPI Waitsome Other flavors - Non-Blocking - MPI Issend(), MPI Ibsend(), MPI Irsend() Status check functions - MPI Test, MPI Testany, MPI Testall, MPI Testsome Dhanashree N P: MPI Tutorial
  • 11. Collective Communication and Computation Routines The unicast routines were primarily for communication purposes. Some of the collective operations support computations. All the processes that are part of a communicator has to participate in collective communication. Three types of collective operations: Synchronization - wait till all members have reached the synchronization point Data movements - broadcast, scatter, gather Computations - reductions These can be used with MPI primitive data types. Dhanashree N P: MPI Tutorial
  • 12. Collective Communication Routines MPI Barrier(comm) - Each task executing this is blocked until all the other tasks of the same group have reached this point. MPI Bcast(&buffer,count,datatype,root,comm) - The process with rank ’root’ broadcasts to all other processes in the group Dhanashree N P: MPI Tutorial
  • 13. Collective Communication Routines MPI Scatter(&sendbuf,sendcnt,sendtype,&recvbuf, recvcnt,recvtype,root,comm ) - The process with rank ’root’ broadcasts to all other processes in the group MPI Gather(&sendbuf,sendcnt,sendtype,&recvbuf, recvcnt,recvtype,root,comm ) - Reverse of scatter. Dhanashree N P: MPI Tutorial
  • 14. Collective Communication Routines MPI Allgather(&sendbuf,sendcnt,sendtype,&recvbuf, recvcnt,recvtype,comm ) - Concatenation of data to all tasks in a group. Dhanashree N P: MPI Tutorial
  • 15. Collective Computation Routines MPI Reduce(&sendbuf,&recvbuf,count,datatype,op,root,comm) - Applies a reduction operation on all tasks in the group and places the result in one task. MPI Allreduce - collective computation and data movement operation MPI MAX, MPI MIN, MPI SUM,MPI PROD, MPI BOR, MPI BAND etc. Dhanashree N P: MPI Tutorial
  • 16. Data Types - MPI Datatype (C Data type) MPI CHAR (signed char) MPI SHORT (signed short int) MPI INT (signed int) MPI LONG (signed long int) MPI UNSIGNED CHAR (unsigned char) MPI UNSIGNED SHORT (unsigned short int) MPI UNSIGNED LONG (unsigned long int) MPI UNSIGNED (unsigned int) MPI FLOAT (float) MPI DOUBLE (double) MPI LONG DOUBLE (long double) MPI BYTE MPI PACKED Dhanashree N P: MPI Tutorial
  • 17. Derived Data Types The following are used for derived data type creation: Contiguous Vector Indexed Struct Dhanashree N P: MPI Tutorial
  • 18. Derived Data Types - Example using Contiguous Dhanashree N P: MPI Tutorial
  • 19. References Message Passing Interface(MPI) - https://computing.llnl.gov/tutorials/mpi/ Inter group communications - http://www.mpi-forum.org/ docs/mpi-1.1/mpi-11-html/node114.html Tutorials - http://mpitutorial.com/tutorials/ Introduction to Parallel Computing by Ananth Grama et al. - Section 6.3 to Section 6.7 Dhanashree N P: MPI Tutorial