0% found this document useful (0 votes)
7 views1 page

MPI Programming Model

MPI (Message Passing Interface) is a parallel programming model designed for communication between processes in distributed memory systems, featuring explicit communication and scalability. The program structure includes functions like MPI_Init, MPI_Send, and MPI_Recv, with an example code demonstrating its use. While MPI offers advantages such as efficiency and suitability for high-performance computing, it also presents challenges in programming and debugging.

Uploaded by

kiruthika1991
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

MPI Programming Model

MPI (Message Passing Interface) is a parallel programming model designed for communication between processes in distributed memory systems, featuring explicit communication and scalability. The program structure includes functions like MPI_Init, MPI_Send, and MPI_Recv, with an example code demonstrating its use. While MPI offers advantages such as efficiency and suitability for high-performance computing, it also presents challenges in programming and debugging.

Uploaded by

kiruthika1991
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MPI Programming Model

Definition: MPI (Message Passing Interface) is a parallel programming model used for
communication between processes in distributed memory systems.

Diagram:

+-------------+ +-------------+
| Process 0 | | Process 1 |
| Local Mem | | Local Mem |
+------+------+ +------+------+
| |
| Message Passing |
| <-----------------> |
| |
+------+------+ +------+------+
| Process 2 | | Process 3 |
| Local Mem | | Local Mem |
+-------------+ +-------------+

Features: Distributed memory, explicit communication, scalability, portability, and parallel


execution.

Program Structure:

MPI_Init();
MPI_Comm_rank();
MPI_Comm_size();
MPI_Send();
MPI_Recv();
MPI_Finalize();

Example Code:

#include <mpi.h>
#include <stdio.h>

int main(int argc, char *argv[]) {


int rank, data;

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

if (rank == 0) {
data = 100;
MPI_Send(&data, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
} else if (rank == 1) {
MPI_Recv(&data, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}

MPI_Finalize();
return 0;
}

Advantages: Efficient, scalable, and suitable for high-performance computing.

Disadvantages: Complex programming and debugging.

You might also like