SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
Rohit Banga
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
Divyen Patel
 
MPI Presentation
MPI PresentationMPI Presentation
MPI Presentation
Tayfun Sen
 
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
Jason Shih
 

Was ist angesagt? (20)

Introduction to High Performance Computing
Introduction to High Performance ComputingIntroduction to High Performance Computing
Introduction to High Performance Computing
 
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...
 
What is [Open] MPI?
What is [Open] MPI?What is [Open] MPI?
What is [Open] MPI?
 
Chpt7
Chpt7Chpt7
Chpt7
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
Communication model of parallel platforms
Communication model of parallel platformsCommunication model of parallel platforms
Communication model of parallel platforms
 
Point-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPIPoint-to-Point Communicationsin MPI
Point-to-Point Communicationsin MPI
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interface
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
 
MPI Presentation
MPI PresentationMPI Presentation
MPI Presentation
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
 
Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)
 
Course outline of parallel and distributed computing
Course outline of parallel and distributed computingCourse outline of parallel and distributed computing
Course outline of parallel and distributed computing
 
Introduction to HPC
Introduction to HPCIntroduction to HPC
Introduction to HPC
 
The Message Passing Interface (MPI) in Layman's Terms
The Message Passing Interface (MPI) in Layman's TermsThe Message Passing Interface (MPI) in Layman's Terms
The Message Passing Interface (MPI) in Layman's Terms
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming model
 
Underlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computingUnderlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computing
 
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
 
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
 

Andere mochten auch

High performance computing
High performance computingHigh performance computing
High performance computing
Guy Tel-Zur
 
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
 

Andere mochten auch (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: 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
 
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
 
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
 

Ähnlich wie 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 - C2
Marcirio Chaves
 

Ähnlich wie 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
 
Mpi
Mpi Mpi
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
 
“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
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

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