SlideShare une entreprise Scribd logo
1  sur  41
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

Contenu connexe

Tendances

Point-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIPoint-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIHanif Durad
 
High performance computing tutorial, with checklist and tips to optimize clus...
High performance computing tutorial, with checklist and tips to optimize clus...High performance computing tutorial, with checklist and tips to optimize clus...
High performance computing tutorial, with checklist and tips to optimize clus...Pradeep Redddy Raamana
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance ComputingDivyen Patel
 
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 ActuariesAdam DeConinck
 
Introduction to parallel_computing
Introduction to parallel_computingIntroduction to parallel_computing
Introduction to parallel_computingMehul Patel
 
hierarchical bus system
 hierarchical bus system hierarchical bus system
hierarchical bus systemElvis Jonyo
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI IntroductionRohit Banga
 
Parallel computing and its applications
Parallel computing and its applicationsParallel computing and its applications
Parallel computing and its applicationsBurhan Ahmed
 
High performance computing - building blocks, production & perspective
High performance computing - building blocks, production & perspectiveHigh performance computing - building blocks, production & perspective
High performance computing - building blocks, production & perspectiveJason Shih
 
Multiprocessor
MultiprocessorMultiprocessor
MultiprocessorA B Shinde
 
multiprocessors and multicomputers
 multiprocessors and multicomputers multiprocessors and multicomputers
multiprocessors and multicomputersPankaj Kumar Jain
 
Introduction to HPC
Introduction to HPCIntroduction to HPC
Introduction to HPCChris Dwan
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryrapunzel08
 
Multiprocessor
MultiprocessorMultiprocessor
MultiprocessorNeel Patel
 

Tendances (20)

Point-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIPoint-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPI
 
High performance computing tutorial, with checklist and tips to optimize clus...
High performance computing tutorial, with checklist and tips to optimize clus...High performance computing tutorial, with checklist and tips to optimize clus...
High performance computing tutorial, with checklist and tips to optimize clus...
 
Mpi
Mpi Mpi
Mpi
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
 
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
 
Introduction to parallel_computing
Introduction to parallel_computingIntroduction to parallel_computing
Introduction to parallel_computing
 
hierarchical bus system
 hierarchical bus system hierarchical bus system
hierarchical bus system
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
Parallel computing persentation
Parallel computing persentationParallel computing persentation
Parallel computing persentation
 
Parallel processing and pipelining
Parallel processing and pipeliningParallel processing and pipelining
Parallel processing and pipelining
 
Parallel computing and its applications
Parallel computing and its applicationsParallel computing and its applications
Parallel computing and its applications
 
6.distributed shared memory
6.distributed shared memory6.distributed shared memory
6.distributed shared memory
 
High performance computing - building blocks, production & perspective
High performance computing - building blocks, production & perspectiveHigh performance computing - building blocks, production & perspective
High performance computing - building blocks, production & perspective
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
multiprocessors and multicomputers
 multiprocessors and multicomputers multiprocessors and multicomputers
multiprocessors and multicomputers
 
Introduction to HPC
Introduction to HPCIntroduction to HPC
Introduction to HPC
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
High performance computing
High performance computingHigh performance computing
High performance computing
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
 

En vedette

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 HereMartin Hamilton
 
High performance computing
High performance computingHigh performance computing
High performance computingGuy Tel-Zur
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance ComputingDell World
 
Intro to High Performance Computing in the AWS Cloud
Intro to High Performance Computing in the AWS CloudIntro to High Performance Computing in the AWS Cloud
Intro to High Performance Computing in the AWS CloudAmazon Web Services
 
High Performance Statistical Computing
High Performance Statistical ComputingHigh Performance Statistical Computing
High Performance Statistical ComputingMicah 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 EverythingJeff Squyres
 
High performance computing
High performance computingHigh performance computing
High performance computingMaher Alshammari
 
Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14KALRAY
 
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 BOFJeff Squyres
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPIMajong 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 Technologiesinside-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 concrete ppt
High performance concrete pptHigh performance concrete ppt
High performance concrete pptGoogle
 

En vedette (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
 
High performance computing
High performance computingHigh performance computing
High performance computing
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
 
Intro to High Performance Computing in the AWS Cloud
Intro to High Performance Computing in the AWS CloudIntro to High Performance Computing in the AWS Cloud
Intro to High Performance Computing in the AWS Cloud
 
High Performance Statistical Computing
High Performance Statistical ComputingHigh Performance Statistical Computing
High Performance Statistical Computing
 
(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
 
High performance computing
High performance computingHigh performance computing
High performance computing
 
Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14Kalray TURBOCARD2 @ ISC'14
Kalray TURBOCARD2 @ ISC'14
 
High Performance Computing in the Cloud?
High Performance Computing in the Cloud?High Performance Computing in the Cloud?
High Performance Computing in the Cloud?
 
ISBI MPI Tutorial
ISBI MPI TutorialISBI MPI Tutorial
ISBI MPI Tutorial
 
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
 
Message passing interface
Message passing interfaceMessage passing interface
Message passing interface
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
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 ...
 
Using MPI
Using MPIUsing MPI
Using MPI
 
MPI
MPIMPI
MPI
 
High–Performance Computing
High–Performance ComputingHigh–Performance Computing
High–Performance Computing
 
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
 
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...
 
High performance concrete ppt
High performance concrete pptHigh performance concrete ppt
High performance concrete ppt
 

Similaire à High Performance Computing 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 - C2Marcirio 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 HPCIJSRD
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10AbdullahMunir32
 
Intro to MPI
Intro to MPIIntro to MPI
Intro to MPIjbp4444
 
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
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPIyaman dua
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMPDivya 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 communicationHimanshi Kathuria
 
“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...
“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...
“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...lccausp
 
Rgk cluster computing project
Rgk cluster computing projectRgk cluster computing project
Rgk cluster computing projectOstopD
 
Mpi.net running wizard
Mpi.net running wizardMpi.net running wizard
Mpi.net running wizardAhmed Imair
 

Similaire à High Performance Computing using MPI (20)

Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to 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
 
Parallel computing(2)
Parallel computing(2)Parallel computing(2)
Parallel computing(2)
 
Lecture9
Lecture9Lecture9
Lecture9
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
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
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10
 
Intro to MPI
Intro to MPIIntro to MPI
Intro to MPI
 
cs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdfcs556-2nd-tutorial.pdf
cs556-2nd-tutorial.pdf
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Introduction to MPI
Introduction to MPIIntroduction to MPI
Introduction to MPI
 
Programming using MPI and OpenMP
Programming using MPI and OpenMPProgramming using MPI and OpenMP
Programming using MPI and OpenMP
 
More mpi4py
More mpi4pyMore mpi4py
More mpi4py
 
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
 
“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...
“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...
“Programação paralela híbrida com MPI e OpenMP – uma abordagem prática”. Edua...
 
Introduction to GPUs in HPC
Introduction to GPUs in HPCIntroduction to GPUs in HPC
Introduction to GPUs in HPC
 
Mpi.net tutorial
Mpi.net tutorialMpi.net tutorial
Mpi.net tutorial
 
Rgk cluster computing project
Rgk cluster computing projectRgk cluster computing project
Rgk cluster computing project
 
mpi4py.pdf
mpi4py.pdfmpi4py.pdf
mpi4py.pdf
 
Mpi.net running wizard
Mpi.net running wizardMpi.net running wizard
Mpi.net running wizard
 

Dernier

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Dernier (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

High Performance Computing using MPI

  • 1. 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.
  • 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 amahato@iitk.ac.in 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