0% found this document useful (0 votes)
5 views3 pages

PDC La B4

Uploaded by

X I S I R
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)
5 views3 pages

PDC La B4

Uploaded by

X I S I R
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
You are on page 1/ 3

DIGITAL ASSIGNMENT-4

PARALLEL AND DISTRIBUTED COMPUTING


CSE4001
ELA

NAME: SHISIR PANDEY


REGNO:20BCE2873

SUBMISSION DATE: 2/26/2023


1. Write a C program to handle message passing in the MPI application
interface, which allows processes to communicate with one another.
Create two processes that will pass the number ‘23’ from one to the
other.
CODE:
#include <stdio.h>

#include <mpi.h>

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

printf("SHISIR PANDEY 20BCE2873\n");

int process_Rank, size_Of_Cluster, message_Item;

MPI_Init(&argc, &argv);

MPI_Comm_size(MPI_COMM_WORLD, &size_Of_Cluster);

MPI_Comm_rank(MPI_COMM_WORLD, &process_Rank);

if(process_Rank == 0){

message_Item = 23;

MPI_Send(&message_Item, 1, MPI_INT, 1, 1, MPI_COMM_WORLD);

printf("Message Sent: %d\n", message_Item);

else if(process_Rank == 1){

MPI_Recv(&message_Item, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

printf("Message Received: %d\n", message_Item);

MPI_Finalize();

return 0;

}
IMPLEMENTATION:

OUTPUT:

You might also like