MPI - MESSAGE PASSING INTERFACE
An approach for parallel algorithms
COMPUTER SCIENCE DEPARTMENT
PROF. AKHTAR RASOOL
UNDERTHE GUIDANCE OF
TABLE OF CONTENT
Parallel Merge Sort using MPI
Introduction
Background
MPI
Code implementation
Result
About Us
Goal and Vision
Target
Programming language
Cluster
MPI library
Dataset
What is MPI
Data type and syntax
Communication Mode
Features
Merge sort implementation
Flow of code
Process flow
Single processor
Multiprocessor
Summery
About Us
Our Team
Nishaant Sharma
131112226
Kartik
131112265
Mohit Raghuvanshi
131112232
Prabhash Prakash
131112241
“Analysis of RunningTime complexity of Sorting
Algorithm (Merge Sort) on parallel processing
environment (preferably on a cluster with various
processors) and single node Using MPI”
Goal 05
Installation Implementation Result
Install mpich2 on Ubantu Implement merge sort algorithm
parallel
Change in time when we increse
in the number of processor
VISION
Write your relevant text here
06
Background
Programming language
Base of project
 good knowledge of “C” for implementing code
C for implementing the algorithm
 Python for generating the data set
Faker library in python
11
Background
Cluster
Master and Slave Node
 Master Node
 Slave Node
11
Background
MPI
Message passing interface
 MPI is a proposed standard message-passing
interface. It is a library Specification, not a language.
The programs that users can write in Fortran 77 andC
are compiled with Ordinary compilers and linked with
the MPI library.
11
Dataset
Python Script
For generating dataset
We use faker module for generating the dataset of census.
Some basic api of faker
 fake.name() for generating fake name
fake.email() for generating fake email
fake.ean(length=13) for unique id of 13 digit
fake.job() for creating fake job
Many other api
11
Dataset
Python Script
For generating dataset
Dataset attribute
Id
Name
Phone Number
Salary
Email
11
Dataset preview
12
What is MPI
MPI
Message Passing Interface
A message-passing library specifications:
Extended message-passing model
Not a language or compiler specification
Not a specific implementation or product
For parallel computers, clusters, and heterogeneous networks.
Designed to permit the development of parallel software libraries.
Designed to provide access to advanced parallel hardware for
End users
Library writers
Tool developers
13
Communication Modes
Based on the type of send:
Synchronous: Completes once the
acknowledgement is received by the sender.
Buffered send: completes immediately, unless if an
error occurs.
Standard send: completes once the message has
been sent, which may or may not imply that the
message has arrived at its destination.
Ready send: completes immediately, if the receiver
is ready for the message it will get it, otherwise the
message is dropped silently.
DataTypes
The following data types are supported by MPI:
Predefined data types that are corresponding to
data types from the programming language.
Arrays.
Sub blocks of a matrix
User defined data structure.
A set of predefined data types
API of MPI
#include “mpi.h” provides basic MPI definitions and types.
MPI_Init starts MPI
MPI_Finalize exits MPI
Note that all non-MPI routines are local; thus “printf” run on each
process
MPI_INIT
Initializing MPI
The initialization routine MPI_INIT is the first MPI routine
called.
MPI_INIT is called once.
int MPI_INIT( int *argc, char **argv );
MPI_Finalize
After a program has finished using the MPI library, it must call
MPI_Finalize in order to clean up all MPI state. Once this routine
is called, no MPI routine may be called.
MPI_finalize is genrally last command in the program.
MPI_finalize()
MPI_Comm_rank
It updates the rank of processes in the variable
world_rank. Determines the rank of the calling process in the
communicator
int MPI_Comm_rank(MPI_COMM_WORLD,
&wordld_rank);
MPI_Comm_size
Determines the size of the group associated with a
communicator.
int MPI_Comm_size(MPI_COMM comm, int
*size);
MPI_Scatter
Sends data from one process to all other processes in a
communicator.
. int MPI_Scatter(const void *sendbuf, int
sendcount, MPI_Datatype sendtype,void
*recvbuf, int recvcount, MPI_Datatype
recvtype, int root, MPI_Comm comm);
MPI_Scatter
MPI_Gather
MPI_Gather is opposite of MPI_Scatter, it gather all the data from
other processes to single (Master) process.
. int MPI_Gather(const void *sendbuf,
intsendcount, MPI_Datatype sendtype, void
*recvbuf, int recvcount, MPI_Datatype
recvtype, int root, MPI_Comm comm)
MPI_Gather
MPI_Bcast
Broadcasts a message from the process with rank "root" to all
other processes of the communicator.
int MPI_Bcast( void *buffer, int count,
MPI_Datatype datatype, int root, MPI_Comm
comm )
MPI_Bcast
Parallel Merge Sort Algorithm
Result
No. of Process Time elapsed in reading
input file(ms)
Time elapsed to sort
the data(ms)
Time in writing
output file(ms)
1 3982.326 8528.112 5839.587
2 4050.897 6878.000 5401.234
4 8145.740 12073.895 11083.125
5 10178.689 14361.952 13087.155
Conclusion
In this project we focused on using MPI as a
message passing interface implementation on
LINUX platform. The effect of parallel processes
number and also the number of cores on the
performance of parallel merge sort algorithms has
been theoretically and experimentally studied.
ThankYou

MPI message passing interface

  • 1.
    MPI - MESSAGEPASSING INTERFACE An approach for parallel algorithms COMPUTER SCIENCE DEPARTMENT PROF. AKHTAR RASOOL UNDERTHE GUIDANCE OF
  • 2.
    TABLE OF CONTENT ParallelMerge Sort using MPI Introduction Background MPI Code implementation Result About Us Goal and Vision Target Programming language Cluster MPI library Dataset What is MPI Data type and syntax Communication Mode Features Merge sort implementation Flow of code Process flow Single processor Multiprocessor Summery
  • 3.
  • 4.
    Our Team Nishaant Sharma 131112226 Kartik 131112265 MohitRaghuvanshi 131112232 Prabhash Prakash 131112241
  • 5.
    “Analysis of RunningTimecomplexity of Sorting Algorithm (Merge Sort) on parallel processing environment (preferably on a cluster with various processors) and single node Using MPI” Goal 05
  • 6.
    Installation Implementation Result Installmpich2 on Ubantu Implement merge sort algorithm parallel Change in time when we increse in the number of processor VISION Write your relevant text here 06
  • 7.
    Background Programming language Base ofproject  good knowledge of “C” for implementing code C for implementing the algorithm  Python for generating the data set Faker library in python 11
  • 8.
    Background Cluster Master and SlaveNode  Master Node  Slave Node 11
  • 9.
    Background MPI Message passing interface MPI is a proposed standard message-passing interface. It is a library Specification, not a language. The programs that users can write in Fortran 77 andC are compiled with Ordinary compilers and linked with the MPI library. 11
  • 10.
    Dataset Python Script For generatingdataset We use faker module for generating the dataset of census. Some basic api of faker  fake.name() for generating fake name fake.email() for generating fake email fake.ean(length=13) for unique id of 13 digit fake.job() for creating fake job Many other api 11
  • 11.
    Dataset Python Script For generatingdataset Dataset attribute Id Name Phone Number Salary Email 11
  • 12.
  • 13.
    What is MPI MPI MessagePassing Interface A message-passing library specifications: Extended message-passing model Not a language or compiler specification Not a specific implementation or product For parallel computers, clusters, and heterogeneous networks. Designed to permit the development of parallel software libraries. Designed to provide access to advanced parallel hardware for End users Library writers Tool developers 13
  • 14.
    Communication Modes Based onthe type of send: Synchronous: Completes once the acknowledgement is received by the sender. Buffered send: completes immediately, unless if an error occurs. Standard send: completes once the message has been sent, which may or may not imply that the message has arrived at its destination. Ready send: completes immediately, if the receiver is ready for the message it will get it, otherwise the message is dropped silently.
  • 15.
    DataTypes The following datatypes are supported by MPI: Predefined data types that are corresponding to data types from the programming language. Arrays. Sub blocks of a matrix User defined data structure. A set of predefined data types
  • 16.
    API of MPI #include“mpi.h” provides basic MPI definitions and types. MPI_Init starts MPI MPI_Finalize exits MPI Note that all non-MPI routines are local; thus “printf” run on each process
  • 17.
    MPI_INIT Initializing MPI The initializationroutine MPI_INIT is the first MPI routine called. MPI_INIT is called once. int MPI_INIT( int *argc, char **argv );
  • 18.
    MPI_Finalize After a programhas finished using the MPI library, it must call MPI_Finalize in order to clean up all MPI state. Once this routine is called, no MPI routine may be called. MPI_finalize is genrally last command in the program. MPI_finalize()
  • 19.
    MPI_Comm_rank It updates therank of processes in the variable world_rank. Determines the rank of the calling process in the communicator int MPI_Comm_rank(MPI_COMM_WORLD, &wordld_rank);
  • 20.
    MPI_Comm_size Determines the sizeof the group associated with a communicator. int MPI_Comm_size(MPI_COMM comm, int *size);
  • 21.
    MPI_Scatter Sends data fromone process to all other processes in a communicator. . int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
  • 22.
  • 23.
    MPI_Gather MPI_Gather is oppositeof MPI_Scatter, it gather all the data from other processes to single (Master) process. . int MPI_Gather(const void *sendbuf, intsendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
  • 24.
  • 25.
    MPI_Bcast Broadcasts a messagefrom the process with rank "root" to all other processes of the communicator. int MPI_Bcast( void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )
  • 26.
  • 27.
  • 28.
    Result No. of ProcessTime elapsed in reading input file(ms) Time elapsed to sort the data(ms) Time in writing output file(ms) 1 3982.326 8528.112 5839.587 2 4050.897 6878.000 5401.234 4 8145.740 12073.895 11083.125 5 10178.689 14361.952 13087.155
  • 29.
    Conclusion In this projectwe focused on using MPI as a message passing interface implementation on LINUX platform. The effect of parallel processes number and also the number of cores on the performance of parallel merge sort algorithms has been theoretically and experimentally studied.
  • 30.