This document discusses implementing a parallel merge sort algorithm using MPI (Message Passing Interface). It describes the background of MPI and how it can be used for communication between processes. It provides details on the dataset used, MPI functions for initialization, communication between processes, and summarizes the results which show a decrease in runtime when increasing the number of processors.
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
“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
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
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
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);
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);
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)
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 )
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.