MPI: Understanding the Message Passing Interface for Parallel Programming, Slides of Parallel Computing and Programming

Mpi, or message passing interface, is a standard library for message-passing that enables the development of portable message-passing programs using c or fortran. An overview of the mpi standard, its core routines, and their usage for starting and terminating the mpi library, querying information, and sending and receiving messages. It also includes an example mpi program.

Typology: Slides

2011/2012

Uploaded on 07/23/2012

paramita
paramita 🇮🇳

4.6

(16)

120 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MPI: the Message Passing Interface
MPI defines a standard library for message-passing
that can be used to develop portable message-
passing programs using either C or Fortran.
The MPI standard defines both the syntax as well as
the semantics of a core set of library routines.
Vendor implementations of MPI are available on
almost all commercial parallel computers.
It is possible to write (min) fully-functional message-
passing programs by using only the six routines.
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download MPI: Understanding the Message Passing Interface for Parallel Programming and more Slides Parallel Computing and Programming in PDF only on Docsity!

MPI: the Message Passing Interface •^

MPI defines a standard library for message-passingthat can be used to develop portable message-passing programs using either C or Fortran.

-^

The MPI standard defines both the syntax as well asthe semantics of a core set of library routines.

-^

Vendor implementations of MPI are available onalmost all commercial parallel computers.

-^

It is possible to write (min) fully-functional message-passing programs by using only the six routines.

MPI: the Message Passing Interface

The minimal set of MPI routines.

MPI_Init

Initializes MPI.

MPI_Finalize

Terminates MPI.

MPI_Comm_size

Determines the number of processes.

MPI_Comm_rank

Determines the label of calling process.

MPI_Send

Sends a message.

MPI_Recv

Receives a message.

Communicators

•^

A communicator defines a

communication

domain

  • a set of processes that are allowed

to communicate with each other.

-^

Information about communication domains isstored in variables of type MPI_Comm.

-^

Communicators are used as arguments to allmessage transfer MPI routines.

-^

A process can belong to many different(possibly overlapping) communicationdomains.

-^

MPI defines a default communicator calledMPI_COMM_WORLD which includes all theprocesses.

Querying Information

-^

The

MPI_Comm_size

MPI_Comm_rank

functions are used to determine the number ofprocesses & the label of the calling process,respectively.

-^

The calling sequences of these routines are asfollows: int MPI_Comm_size(MPI_Comm comm, int *size)int MPI_Comm_rank(MPI_Comm comm, int *rank)

-^

The rank of a process is an integer that rangesfrom zero up to the size of the communicatorminus one.

MPI Datatypes

MPI Datatype

C Datatype

MPI_CHAR

signed char

MPI_SHORT

signed short int

MPI_INT

signed int

MPI_LONG

signed long int

MPI_UNSIGNED_CHAR

unsigned char

MPI_UNSIGNED_SHORT

unsigned short int

MPI_UNSIGNED

unsigned int

MPI_UNSIGNED_LONG

unsigned long int

MPI_FLOAT

float

MPI_DOUBLE

double

MPI_LONG_DOUBLE

long double

MPI_BYTEMPI_PACKED

MPI provides equivalent datatypes for all C datatypes. This is done for portability reasons.The datatype MPI_BYTE corresponds to a byte (8 bits) and MPI_PACKED correspondsto a collection of data items that has been created by packing non-contiguous data.

MPI Sending and Receiving Messages

•^

The basic functions for sending and receiving messages inMPI are the MPI_Send and MPI_Recv, respectively.

-^

The calling sequences of these routines are as follows: int MPI_Send (void *buf, int count, MPI_Datatype datatype,

int dest, int tag, MPI_Comm comm)

int MPI_Recv (void *buf, int count, MPI_Datatype datatype,

int source, int tag, MPI_Comm comm,

MPI_Status *status)

Sending and Receiving Messages

•^

On the receiving end, the status variable can be usedto get information about the

MPI_Recv

operation.

•^

The corresponding data structure contains:

typedef struct MPI_Status {

int MPI_SOURCE;int MPI_TAG;int MPI_ERROR; };

•^

The MPI_Get_count function returns the precise countof data items received.

**int MPI_Get_count(MPI_Status status,MPI_Datatype datatype, int count)

Example MPI-Program: Adding N-numbers

using p-processors

(N > p , N mod p = 0)