SlideShare a Scribd company logo
High
                 Performance
                  Computing
                            Ankit Mahato
                         amahato@iitk.ac.in
                         fb.com/ankitmahato
                              IIT Kanpur




Note: These are not the actual lecture slides but the ones you may
find useful for IHPC, Techkriti’13.
Lots at stake !!
What is HPC?


It is the art of developing supercomputers and software to run on
supercomputers. A main area of this discipline is developing parallel
processing algorithms and software: programs that can be divided into
little pieces so that each piece can be executed simultaneously by separate
processors.
Why HPC?

To simulate a bio-molecule of 10000 atoms
Non-bond energy term ~ 10^8 operations
For 1 microsecond simulation ~ 10^9 steps ~ 10^17 operations
On a 1 GFLOPS machine (10^9 operations per second) it takes 10^8 secs
   (About 3 years 2 months)
Need to do large no of simulations for even larger molecules

PARAM Yuva – 5 x 10^14 – 3 min 20 sec
Titan – 5.7 seconds
Amdahl's Law

Code = Serial Part + Part which can be parallelized
The potential program speedup is defined by the fraction of
code that can be parallelized
Amdahl's Law



Can you get a speed up of 5 times using quad core processor?
HPC Architecture
HPC architecture typically consist of massive number of computing
nodes (typically 1000s) highly interconnected by a specialized low
latency network fabric which use MPI for data exchange.
Nodes = cores + memory
Computation is divided into tasks distributing these tasks across the
nodes and they need to synchronize and exchange information several
times a second.
Communication Overheads


Latency
Startup time for each message transaction 1 μs

Bandwidth
The rate at which the messages are transmitted across the nodes /
processors 10 Gbits /sec.

You can’t go faster than these limits.
MPI

M P I = Message Passing Interface

It is an industry-wide standard protocol for passing messages between parallel
processors.

MPI is a specification for the developers and users of message passing
libraries. By itself, it is NOT a library - but rather the specification of what
such a library should be.

Small: Require only six library functions to write any parallel code
Large: There are more than 200 functions in MPI-2
MPI

Programming Model

Originally, MPI was designed for distributed memory architectures, which
were becoming increasingly popular at that time.

As architecture trends changed, shared memory SMPs were combined over
networks creating hybrid distributed memory / shared memory systems. MPI
implementors adapted their libraries to handle both types of underlying
memory architectures seamlessly.

It means you can use MPI even on your laptops.
Why MPI ?


Today, MPI runs on virtually any hardware platform:
• Distributed Memory
• Shared Memory
• Hybrid



A MPI program is basically a C, fortran or Python program that uses
the MPI library, SO DON’T BE SCARED.
MPI
MPI

Communicator: a set of
processes that have a valid rank
of source or destination fields.
The predefined communicator is
MPI_COMM_WORLD, and we
will be using this communicator
all the time.

MPI_COMM_WORLD is a
default communicator consisting
all processes. Furthermore, a
programmer can also define a
new communicator, which has a
smaller number of processes
than MPI_COMM_WORLD
does.
MPI

Processes: For this module, we
just need to know that
processes belong to the
MPI_COMM_WORLD. If there
are p processes, then each
process is defined by its rank,
which starts from 0 to p - 1. The
master has the rank 0.

For example, in this process
there are 10 processes
MPI

Use SSH client (Putty) to login into any of these
Multi - Processor Compute Servers with processors
varying from 4 to 15.

akash1.cc.iitk.ac.in
akash2.cc.iitk.ac.in
aatish.cc.iitk.ac.in
falaq.cc.iitk.ac.in


On your PC you can download mpich2 or openmpi.
MPI

Include Header File

C:
#include "mpi.h"

Fortran:
include 'mpif.h'

Python:
from mpi4py import MPI
(not available in CC server you can set it up on your lab workstation)
MPI


Smallest MPI library should provide these 6 functions:

MPI_Init - Initialize the MPI execution environment
MPI_Comm_size - Determines the size of the group associated with a
communictor
MPI_Comm_rank - Determines the rank of the calling process in the
communicator
MPI_Send - Performs a basic send
MPI_Recv - Basic receive
MPI_Finalize - Terminates MPI execution environment
MPI

Format of MPI Calls:
C and Python names are case sensitive.

Fortran names are not.
Example:
CALL MPI_XXXXX(parameter,..., ierr) is equivalent to
call mpi_xxxxx(parameter,..., ierr)

Programs must not declare variables or functions with names
beginning with the prefix MPI_ or PMPI_ for C & Fortran.
.
For Python ‘from mpi4py import MPI’ already ensures that you don’t
make the above mistake.
MPI

C:
rc = MPI_Xxxxx(parameter, ... )
Returned as "rc“. MPI_SUCCESS if successful

Fortran:
CALL MPI_XXXXX(parameter,..., ierr)
Returned as "ierr" parameter. MPI_SUCCESS if successful

Python:
rc = MPI.COMM_WORLD.xxxx(parameter,…)
MPI

                           MPI_Init
Initializes the MPI execution environment. This function must
be called in every MPI program, must be called before any
other MPI functions and must be called only once in an MPI
program.
For C programs, MPI_Init may be used to pass the command
line arguments to all processes, although this is not required
by the standard and is implementation dependent.

MPI_Init (&argc,&argv)
MPI_INIT (ierr)

For python no initialization is required.
MPI

                 MPI_Comm_size
Returns the total number of MPI processes in the specified
communicator, such as MPI_COMM_WORLD. If the
communicator is MPI_COMM_WORLD, then it represents the
number of MPI tasks available to your application.

MPI_Comm_size (comm,&size)
MPI_COMM_SIZE (comm,size,ierr)
Where comm is MPI_COMM_WORLD

For python
MPI.COMM_WORLD.size is the total number of MPI
processes. MPI.COMM_WORLD.Get_size() also returns the
same.
MPI
                        MPI_Comm_rank
Returns the rank of the calling MPI process within the specified
communicator. Initially, each process will be assigned a unique integer
rank between 0 and number of tasks - 1 within the communicator
MPI_COMM_WORLD. This rank is often referred to as a task ID. If a
process becomes associated with other communicators, it will have a
unique rank within each of these as well.

MPI_Comm_rank (comm,&rank)
MPI_COMM_RANK (comm,rank,ierr)
Where comm is MPI_COMM_WORLD

For python
MPI.COMM_WORLD.rank is the total number of MPI processes.
MPI.COMM_WORLD.Get_rank() also returns the same.
MPI
                        MPI_Comm_rank
Returns the rank of the calling MPI process within the specified
communicator. Initially, each process will be assigned a unique integer
rank between 0 and number of tasks - 1 within the communicator
MPI_COMM_WORLD. This rank is often referred to as a task ID. If a
process becomes associated with other communicators, it will have a
unique rank within each of these as well.

MPI_Comm_rank (comm,&rank)
MPI_COMM_RANK (comm,rank,ierr)
Where comm is MPI_COMM_WORLD

For python
MPI.COMM_WORLD.rank is the total number of MPI processes.
MPI.COMM_WORLD.Get_rank() also returns the same.
MPI




   MPI Hello World Program

https://gist.github.com/4459911
MPI

In MPI blocking message passing routines are more commonly used.

A blocking MPI call means that the program execution will be
suspended until the message buffer is safe to use. The MPI standards
specify that a blocking SEND or RECV does not return until the send
buffer is safe to reuse (for MPI_SEND), or the receive buffer is ready to
use (for PI_RECV).

The statement after MPI_SEND can safely modify the memory location
of the array a because the return from MPI_SEND indicates either a
successful completion of the SEND process, or that the buffer
containing a has been copied to a safe place. In either case, a's buffer
can be safely reused.
Also, the return of MPI_RECV indicates that the buffer containing the
array b is full and is ready to use, so the code segment after
MPI_RECV can safely use b.
MPI

                             MPI_Send
Basic blocking send operation. Routine returns only after the application
buffer in the sending task is free for reuse.
Note that this routine may be implemented differently on different
systems. The MPI standard permits the use of a system buffer but does
not require it.

MPI_Send (&buf,count,datatype,dest,tag,comm)
MPI_SEND (buf,count,datatype,dest,tag,comm,ierr)
comm.send(buf,dest,tag)
MPI

                           MPI_Send
MPI_Send(void* message, int count, MPI_Datatype datatype,
             int destination, int tag, MPI_Comm comm)

-   message: initial address of the message
-   count: number of entries to send
-   datatype: type of each entry
-   destination: rank of the receiving process
-   tag: message tag is a way to identify the type of a message
-   comm: communicator (MPI_COMM_WORLD)
MPI

MPI Datatypes
MPI

                             MPI_Recv
Receive a message and block until the requested data is available in the
application buffer in the receiving task.
MPI_Recv (&buf,count,datatype,source,tag,comm,&status)
MPI_RECV (buf,count,datatype,source,tag,comm,status,ierr)


MPI_Recv(void* message, int count, MPI_Datatype datatype, int source,
              int tag, MPI_Comm comm, MPI_Status *status)

-   source: rank of the sending process
-   status: return status
MPI

                        MPI_Finalize

Terminates MPI execution environment

Note: All processes must call this routine before exit. The number of
processes running after this routine is called is undefined; it is
best not to perform anything more than a return after calling
MPI_Finalize.
MPI


                     MPI Hello World 2:

This MPI program illustrates the use of MPI_Send and MPI_Recv
functions. Basically, the master sends a message, “Hello, world”, to
the process whose rank is 1, and then after having received the
message, the process prints the message along with its rank.

                 https://gist.github.com/4459944
MPI

               Collective communication
Collective communication is a communication that must have all
processes involved in the scope of a communicator. We will be
using MPI_COMM_WORLD as our communicator; therefore, the
collective communication will include all processes.
MPI


MPI_Barrier(comm)

This function creates a barrier synchronization in a
commmunicator(MPI_COMM_WORLD). Each task waits at
MPI_Barrier call until all other tasks in the communicator reach the
same MPI_Barrier call.
MPI

MPI_Bcast(&message, int count, MPI_Datatype datatype,
                           int root, comm)

This function displays the message to all other processes in
MPI_COMM_WORLD from the process whose rank is root.
MPI

MPI_Reduce(&message,
&receivemessage,
int count,
MPI_Datatype datatype,
MPI_Op op, int root, comm)

This function applies a reduction
operation on all tasks in
MPI_COMM_WORLD and reduces
results from each process into one
value. MPI_Op includes for example,
MPI_MAX, MPI_MIN, MPI_PROD,
and MPI_SUM, etc.
MPI
MPI_Scatter(&message, int count, MPI_Datatype,
&receivemessage, int count, MPI_Datatype, int root, comm)

MPI_Gather(&message, int count, MPI_Datatype,
&receivemessage, int count, MPI_Datatype, int root, comm)
MPI




           Pi Code

https://gist.github.com/4460013
Thank You




   Ankit Mahato
amahato@iitk.ac.in
fb.com/ankitmahato
     IIT Kanpur
Check out our G+ Page
https://plus.google.com/105183351397774464774/posts
Join our community

      Share your feelings after you run the first MPI code and have discussions.


https://plus.google.com/communities/105106273529839635622
High Performance Computing using MPI
Ad

More Related Content

What's hot (20)

High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
Divyen Patel
 
Parallelism
ParallelismParallelism
Parallelism
Md Raseduzzaman
 
Introduction to High Performance Computing
Introduction to High Performance ComputingIntroduction to High Performance Computing
Introduction to High Performance Computing
Umarudin Zaenuri
 
Multi Processors And Multi Computers
 Multi Processors And Multi Computers Multi Processors And Multi Computers
Multi Processors And Multi Computers
Nemwos
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
Hanif Durad
 
Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
Akhila Prabhakaran
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
Vajira Thambawita
 
Parallel and distributed Computing
Parallel and distributed Computing Parallel and distributed Computing
Parallel and distributed Computing
MIANSHOAIB10
 
High performance computing
High performance computingHigh performance computing
High performance computing
punjab engineering college, chandigarh
 
Process management in os
Process management in osProcess management in os
Process management in os
Sumant Diwakar
 
parallel programming models
 parallel programming models parallel programming models
parallel programming models
Swetha S
 
Introduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingIntroduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed Computing
Sayed Chhattan Shah
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
Heterogeneous computing
Heterogeneous computingHeterogeneous computing
Heterogeneous computing
Rashid Ansari
 
Tutorial on Parallel Computing and Message Passing Model - C1
Tutorial on Parallel Computing and Message Passing Model - C1Tutorial on Parallel Computing and Message Passing Model - C1
Tutorial on Parallel Computing and Message Passing Model - C1
Marcirio Chaves
 
Parallel Programing Model
Parallel Programing ModelParallel Programing Model
Parallel Programing Model
Adlin Jeena
 
MPI Presentation
MPI PresentationMPI Presentation
MPI Presentation
Tayfun Sen
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threads
cscarcas
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linux
Siddique Ibrahim
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
Krasimir Berov (Красимир Беров)
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
Divyen Patel
 
Introduction to High Performance Computing
Introduction to High Performance ComputingIntroduction to High Performance Computing
Introduction to High Performance Computing
Umarudin Zaenuri
 
Multi Processors And Multi Computers
 Multi Processors And Multi Computers Multi Processors And Multi Computers
Multi Processors And Multi Computers
Nemwos
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
Hanif Durad
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
Vajira Thambawita
 
Parallel and distributed Computing
Parallel and distributed Computing Parallel and distributed Computing
Parallel and distributed Computing
MIANSHOAIB10
 
Process management in os
Process management in osProcess management in os
Process management in os
Sumant Diwakar
 
parallel programming models
 parallel programming models parallel programming models
parallel programming models
Swetha S
 
Introduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingIntroduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed Computing
Sayed Chhattan Shah
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
Heterogeneous computing
Heterogeneous computingHeterogeneous computing
Heterogeneous computing
Rashid Ansari
 
Tutorial on Parallel Computing and Message Passing Model - C1
Tutorial on Parallel Computing and Message Passing Model - C1Tutorial on Parallel Computing and Message Passing Model - C1
Tutorial on Parallel Computing and Message Passing Model - C1
Marcirio Chaves
 
Parallel Programing Model
Parallel Programing ModelParallel Programing Model
Parallel Programing Model
Adlin Jeena
 
MPI Presentation
MPI PresentationMPI Presentation
MPI Presentation
Tayfun Sen
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threads
cscarcas
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linux
Siddique Ibrahim
 

Viewers also liked (20)

High Performance Computing - The Future is Here
High Performance Computing - The Future is HereHigh Performance Computing - The Future is Here
High Performance Computing - The Future is Here
Martin Hamilton
 
High Performance Computing: an Introduction for the Society of Actuaries
High Performance Computing: an Introduction for the Society of ActuariesHigh Performance Computing: an Introduction for the Society of Actuaries
High Performance Computing: an Introduction for the Society of Actuaries
Adam DeConinck
 
High performance computing
High performance computingHigh performance computing
High performance computing
Guy Tel-Zur
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
Dell World
 
High Performance Statistical Computing
High Performance Statistical ComputingHigh Performance Statistical Computing
High Performance Statistical Computing
Micah Altman
 
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
Jeff Squyres
 
High performance computing
High performance computingHigh performance computing
High performance computing
Maher Alshammari
 
Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14
KALRAY
 
High Performance Computing in the Cloud?
High Performance Computing in the Cloud?High Performance Computing in the Cloud?
High Performance Computing in the Cloud?
Ian Lumb
 
ISBI MPI Tutorial
ISBI MPI TutorialISBI MPI Tutorial
ISBI MPI Tutorial
Daniel Blezek
 
Open MPI State of the Union X SC'16 BOF
Open MPI State of the Union X SC'16 BOFOpen MPI State of the Union X SC'16 BOF
Open MPI State of the Union X SC'16 BOF
Jeff Squyres
 
Message passing interface
Message passing interfaceMessage passing interface
Message passing interface
Md. Mahedi Mahfuj
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
Rohit Banga
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
Majong DevJfu
 
Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...
Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...
Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...
Geoffrey Fox
 
Using MPI
Using MPIUsing MPI
Using MPI
Kazuki Ohta
 
MPI
MPIMPI
MPI
Rohit Banga
 
High–Performance Computing
High–Performance ComputingHigh–Performance Computing
High–Performance Computing
BRAC University Computer Club
 
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC TechnologiesAccelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
inside-BigData.com
 
Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...
Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...
Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...
Industrial Partnerships Office
 
High Performance Computing - The Future is Here
High Performance Computing - The Future is HereHigh Performance Computing - The Future is Here
High Performance Computing - The Future is Here
Martin Hamilton
 
High Performance Computing: an Introduction for the Society of Actuaries
High Performance Computing: an Introduction for the Society of ActuariesHigh Performance Computing: an Introduction for the Society of Actuaries
High Performance Computing: an Introduction for the Society of Actuaries
Adam DeConinck
 
High performance computing
High performance computingHigh performance computing
High performance computing
Guy Tel-Zur
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
Dell World
 
High Performance Statistical Computing
High Performance Statistical ComputingHigh Performance Statistical Computing
High Performance Statistical Computing
Micah Altman
 
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
Jeff Squyres
 
High performance computing
High performance computingHigh performance computing
High performance computing
Maher Alshammari
 
Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14
KALRAY
 
High Performance Computing in the Cloud?
High Performance Computing in the Cloud?High Performance Computing in the Cloud?
High Performance Computing in the Cloud?
Ian Lumb
 
Open MPI State of the Union X SC'16 BOF
Open MPI State of the Union X SC'16 BOFOpen MPI State of the Union X SC'16 BOF
Open MPI State of the Union X SC'16 BOF
Jeff Squyres
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
Rohit Banga
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
Majong DevJfu
 
Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...
Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...
Multi-faceted Classification of Big Data Use Cases and Proposed Architecture ...
Geoffrey Fox
 
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC TechnologiesAccelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
inside-BigData.com
 
Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...
Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...
Delivering Transformational Solutions to Industry by Dr. Frederick Streitz, D...
Industrial Partnerships Office
 
Ad

Similar to High Performance Computing using MPI (20)

Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
Akhila Prabhakaran
 
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
Marcirio Chaves
 
Parallel computing(2)
Parallel computing(2)Parallel computing(2)
Parallel computing(2)
Md. Mahedi Mahfuj
 
Lecture9
Lecture9Lecture9
Lecture9
tt_aljobory
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
GopalPatidar13
 
Advanced Scalable Decomposition Method with MPICH Environment for HPC
Advanced Scalable Decomposition Method with MPICH Environment for HPCAdvanced Scalable Decomposition Method with MPICH Environment for HPC
Advanced Scalable Decomposition Method with MPICH Environment for HPC
IJSRD
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10
AbdullahMunir32
 
Intro to MPI
Intro to MPIIntro to MPI
Intro to MPI
jbp4444
 
cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdf
ssuserada6a9
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
Ajit Nayak
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
yaman dua
 
Mpi
Mpi Mpi
Mpi
Bertha Vega
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMP
Divya Tiwari
 
More mpi4py
More mpi4pyMore mpi4py
More mpi4py
A Jorge Garcia
 
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
Himanshi Kathuria
 
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
 
VSO ConvertXto HD Free CRACKS Download .
VSO ConvertXto HD Free CRACKS Download .VSO ConvertXto HD Free CRACKS Download .
VSO ConvertXto HD Free CRACKS Download .
dshut956
 
Download Letasoft Sound Booster Crack Free Full Activated
Download Letasoft Sound Booster Crack Free Full ActivatedDownload Letasoft Sound Booster Crack Free Full Activated
Download Letasoft Sound Booster Crack Free Full Activated
jennieloksh
 
Wondershare Filmora Crack 2025 For Windows Free
Wondershare Filmora Crack 2025 For Windows FreeWondershare Filmora Crack 2025 For Windows Free
Wondershare Filmora Crack 2025 For Windows Free
abbaskanju3
 
Wondershare Filmora Crack Free Download
Wondershare Filmora  Crack Free DownloadWondershare Filmora  Crack Free Download
Wondershare Filmora Crack Free Download
zqeevcqb3t
 
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
Marcirio Chaves
 
Advanced Scalable Decomposition Method with MPICH Environment for HPC
Advanced Scalable Decomposition Method with MPICH Environment for HPCAdvanced Scalable Decomposition Method with MPICH Environment for HPC
Advanced Scalable Decomposition Method with MPICH Environment for HPC
IJSRD
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10
AbdullahMunir32
 
Intro to MPI
Intro to MPIIntro to MPI
Intro to MPI
jbp4444
 
cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdf
ssuserada6a9
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
Ajit Nayak
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
yaman dua
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMP
Divya Tiwari
 
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
Himanshi Kathuria
 
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
 
VSO ConvertXto HD Free CRACKS Download .
VSO ConvertXto HD Free CRACKS Download .VSO ConvertXto HD Free CRACKS Download .
VSO ConvertXto HD Free CRACKS Download .
dshut956
 
Download Letasoft Sound Booster Crack Free Full Activated
Download Letasoft Sound Booster Crack Free Full ActivatedDownload Letasoft Sound Booster Crack Free Full Activated
Download Letasoft Sound Booster Crack Free Full Activated
jennieloksh
 
Wondershare Filmora Crack 2025 For Windows Free
Wondershare Filmora Crack 2025 For Windows FreeWondershare Filmora Crack 2025 For Windows Free
Wondershare Filmora Crack 2025 For Windows Free
abbaskanju3
 
Wondershare Filmora Crack Free Download
Wondershare Filmora  Crack Free DownloadWondershare Filmora  Crack Free Download
Wondershare Filmora Crack Free Download
zqeevcqb3t
 
Ad

Recently uploaded (20)

How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 

High Performance Computing using MPI

  • 1. High Performance Computing Ankit Mahato [email protected] fb.com/ankitmahato IIT Kanpur Note: These are not the actual lecture slides but the ones you may find useful for IHPC, Techkriti’13.
  • 3. What is HPC? It is the art of developing supercomputers and software to run on supercomputers. A main area of this discipline is developing parallel processing algorithms and software: programs that can be divided into little pieces so that each piece can be executed simultaneously by separate processors.
  • 4. Why HPC? To simulate a bio-molecule of 10000 atoms Non-bond energy term ~ 10^8 operations For 1 microsecond simulation ~ 10^9 steps ~ 10^17 operations On a 1 GFLOPS machine (10^9 operations per second) it takes 10^8 secs (About 3 years 2 months) Need to do large no of simulations for even larger molecules PARAM Yuva – 5 x 10^14 – 3 min 20 sec Titan – 5.7 seconds
  • 5. Amdahl's Law Code = Serial Part + Part which can be parallelized The potential program speedup is defined by the fraction of code that can be parallelized
  • 6. Amdahl's Law Can you get a speed up of 5 times using quad core processor?
  • 7. HPC Architecture HPC architecture typically consist of massive number of computing nodes (typically 1000s) highly interconnected by a specialized low latency network fabric which use MPI for data exchange. Nodes = cores + memory Computation is divided into tasks distributing these tasks across the nodes and they need to synchronize and exchange information several times a second.
  • 8. Communication Overheads Latency Startup time for each message transaction 1 μs Bandwidth The rate at which the messages are transmitted across the nodes / processors 10 Gbits /sec. You can’t go faster than these limits.
  • 9. MPI M P I = Message Passing Interface It is an industry-wide standard protocol for passing messages between parallel processors. MPI is a specification for the developers and users of message passing libraries. By itself, it is NOT a library - but rather the specification of what such a library should be. Small: Require only six library functions to write any parallel code Large: There are more than 200 functions in MPI-2
  • 10. MPI Programming Model Originally, MPI was designed for distributed memory architectures, which were becoming increasingly popular at that time. As architecture trends changed, shared memory SMPs were combined over networks creating hybrid distributed memory / shared memory systems. MPI implementors adapted their libraries to handle both types of underlying memory architectures seamlessly. It means you can use MPI even on your laptops.
  • 11. Why MPI ? Today, MPI runs on virtually any hardware platform: • Distributed Memory • Shared Memory • Hybrid A MPI program is basically a C, fortran or Python program that uses the MPI library, SO DON’T BE SCARED.
  • 12. MPI
  • 13. MPI Communicator: a set of processes that have a valid rank of source or destination fields. The predefined communicator is MPI_COMM_WORLD, and we will be using this communicator all the time. MPI_COMM_WORLD is a default communicator consisting all processes. Furthermore, a programmer can also define a new communicator, which has a smaller number of processes than MPI_COMM_WORLD does.
  • 14. MPI Processes: For this module, we just need to know that processes belong to the MPI_COMM_WORLD. If there are p processes, then each process is defined by its rank, which starts from 0 to p - 1. The master has the rank 0. For example, in this process there are 10 processes
  • 15. MPI Use SSH client (Putty) to login into any of these Multi - Processor Compute Servers with processors varying from 4 to 15. akash1.cc.iitk.ac.in akash2.cc.iitk.ac.in aatish.cc.iitk.ac.in falaq.cc.iitk.ac.in On your PC you can download mpich2 or openmpi.
  • 16. MPI Include Header File C: #include "mpi.h" Fortran: include 'mpif.h' Python: from mpi4py import MPI (not available in CC server you can set it up on your lab workstation)
  • 17. MPI Smallest MPI library should provide these 6 functions: MPI_Init - Initialize the MPI execution environment MPI_Comm_size - Determines the size of the group associated with a communictor MPI_Comm_rank - Determines the rank of the calling process in the communicator MPI_Send - Performs a basic send MPI_Recv - Basic receive MPI_Finalize - Terminates MPI execution environment
  • 18. MPI Format of MPI Calls: C and Python names are case sensitive. Fortran names are not. Example: CALL MPI_XXXXX(parameter,..., ierr) is equivalent to call mpi_xxxxx(parameter,..., ierr) Programs must not declare variables or functions with names beginning with the prefix MPI_ or PMPI_ for C & Fortran. . For Python ‘from mpi4py import MPI’ already ensures that you don’t make the above mistake.
  • 19. MPI C: rc = MPI_Xxxxx(parameter, ... ) Returned as "rc“. MPI_SUCCESS if successful Fortran: CALL MPI_XXXXX(parameter,..., ierr) Returned as "ierr" parameter. MPI_SUCCESS if successful Python: rc = MPI.COMM_WORLD.xxxx(parameter,…)
  • 20. MPI MPI_Init Initializes the MPI execution environment. This function must be called in every MPI program, must be called before any other MPI functions and must be called only once in an MPI program. For C programs, MPI_Init may be used to pass the command line arguments to all processes, although this is not required by the standard and is implementation dependent. MPI_Init (&argc,&argv) MPI_INIT (ierr) For python no initialization is required.
  • 21. MPI MPI_Comm_size Returns the total number of MPI processes in the specified communicator, such as MPI_COMM_WORLD. If the communicator is MPI_COMM_WORLD, then it represents the number of MPI tasks available to your application. MPI_Comm_size (comm,&size) MPI_COMM_SIZE (comm,size,ierr) Where comm is MPI_COMM_WORLD For python MPI.COMM_WORLD.size is the total number of MPI processes. MPI.COMM_WORLD.Get_size() also returns the same.
  • 22. MPI MPI_Comm_rank Returns the rank of the calling MPI process within the specified communicator. Initially, each process will be assigned a unique integer rank between 0 and number of tasks - 1 within the communicator MPI_COMM_WORLD. This rank is often referred to as a task ID. If a process becomes associated with other communicators, it will have a unique rank within each of these as well. MPI_Comm_rank (comm,&rank) MPI_COMM_RANK (comm,rank,ierr) Where comm is MPI_COMM_WORLD For python MPI.COMM_WORLD.rank is the total number of MPI processes. MPI.COMM_WORLD.Get_rank() also returns the same.
  • 23. MPI MPI_Comm_rank Returns the rank of the calling MPI process within the specified communicator. Initially, each process will be assigned a unique integer rank between 0 and number of tasks - 1 within the communicator MPI_COMM_WORLD. This rank is often referred to as a task ID. If a process becomes associated with other communicators, it will have a unique rank within each of these as well. MPI_Comm_rank (comm,&rank) MPI_COMM_RANK (comm,rank,ierr) Where comm is MPI_COMM_WORLD For python MPI.COMM_WORLD.rank is the total number of MPI processes. MPI.COMM_WORLD.Get_rank() also returns the same.
  • 24. MPI MPI Hello World Program https://gist.github.com/4459911
  • 25. MPI In MPI blocking message passing routines are more commonly used. A blocking MPI call means that the program execution will be suspended until the message buffer is safe to use. The MPI standards specify that a blocking SEND or RECV does not return until the send buffer is safe to reuse (for MPI_SEND), or the receive buffer is ready to use (for PI_RECV). The statement after MPI_SEND can safely modify the memory location of the array a because the return from MPI_SEND indicates either a successful completion of the SEND process, or that the buffer containing a has been copied to a safe place. In either case, a's buffer can be safely reused. Also, the return of MPI_RECV indicates that the buffer containing the array b is full and is ready to use, so the code segment after MPI_RECV can safely use b.
  • 26. MPI MPI_Send Basic blocking send operation. Routine returns only after the application buffer in the sending task is free for reuse. Note that this routine may be implemented differently on different systems. The MPI standard permits the use of a system buffer but does not require it. MPI_Send (&buf,count,datatype,dest,tag,comm) MPI_SEND (buf,count,datatype,dest,tag,comm,ierr) comm.send(buf,dest,tag)
  • 27. MPI MPI_Send MPI_Send(void* message, int count, MPI_Datatype datatype, int destination, int tag, MPI_Comm comm) - message: initial address of the message - count: number of entries to send - datatype: type of each entry - destination: rank of the receiving process - tag: message tag is a way to identify the type of a message - comm: communicator (MPI_COMM_WORLD)
  • 29. MPI MPI_Recv Receive a message and block until the requested data is available in the application buffer in the receiving task. MPI_Recv (&buf,count,datatype,source,tag,comm,&status) MPI_RECV (buf,count,datatype,source,tag,comm,status,ierr) MPI_Recv(void* message, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) - source: rank of the sending process - status: return status
  • 30. MPI MPI_Finalize Terminates MPI execution environment Note: All processes must call this routine before exit. The number of processes running after this routine is called is undefined; it is best not to perform anything more than a return after calling MPI_Finalize.
  • 31. MPI MPI Hello World 2: This MPI program illustrates the use of MPI_Send and MPI_Recv functions. Basically, the master sends a message, “Hello, world”, to the process whose rank is 1, and then after having received the message, the process prints the message along with its rank. https://gist.github.com/4459944
  • 32. MPI Collective communication Collective communication is a communication that must have all processes involved in the scope of a communicator. We will be using MPI_COMM_WORLD as our communicator; therefore, the collective communication will include all processes.
  • 33. MPI MPI_Barrier(comm) This function creates a barrier synchronization in a commmunicator(MPI_COMM_WORLD). Each task waits at MPI_Barrier call until all other tasks in the communicator reach the same MPI_Barrier call.
  • 34. MPI MPI_Bcast(&message, int count, MPI_Datatype datatype, int root, comm) This function displays the message to all other processes in MPI_COMM_WORLD from the process whose rank is root.
  • 35. MPI MPI_Reduce(&message, &receivemessage, int count, MPI_Datatype datatype, MPI_Op op, int root, comm) This function applies a reduction operation on all tasks in MPI_COMM_WORLD and reduces results from each process into one value. MPI_Op includes for example, MPI_MAX, MPI_MIN, MPI_PROD, and MPI_SUM, etc.
  • 36. MPI MPI_Scatter(&message, int count, MPI_Datatype, &receivemessage, int count, MPI_Datatype, int root, comm) MPI_Gather(&message, int count, MPI_Datatype, &receivemessage, int count, MPI_Datatype, int root, comm)
  • 37. MPI Pi Code https://gist.github.com/4460013
  • 38. Thank You Ankit Mahato [email protected] fb.com/ankitmahato IIT Kanpur
  • 39. Check out our G+ Page https://plus.google.com/105183351397774464774/posts
  • 40. Join our community Share your feelings after you run the first MPI code and have discussions. https://plus.google.com/communities/105106273529839635622