Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Parallel Computing Lab Assignment - 2 ( marks = 1 0 ) 1 . Modify the program that just prints a line of output from
Parallel Computing Lab Assignment marks Modify the program that just prints a line of output from each process mpi output.c so that the output is printed in process rank order: process s output first, then process s and so on a Use pointtopoint communication. b Use collective communication such as gather. Copy the source code in your answers file. Launch the Command line and take a Screenshot of the window with the result of the program execution including your name. copy the Screenshot in your answers file Also, provide an explanation showing how the code works. marks What is deadlock in MPI? Explain one scenario showing a Source of Deadlocks in MPI send and receive functions with sample code? mark Ring Problem Write a C program that implements a ring algorithm using MPI. The program calculates the sum of all the processs ranks. The program steps are as follows: All processes initialize MPI. Each process gets its rank and the total number of processes. Each process calculates its left and right neighbours. For example, for processor its left is equal to and its right is equal to Each process initially sends its rank to its right neighbour and receives the rank of its left neighbour and initialize the sum variable to its rank. Then, repeatedly do the following: File: mpioutput.c Purpose: A program in which multiple MPI processes try to print a message. Section pp #include #include int mainvoid int myrank, commsz; MPIInitNULL NULL; MPICommsizeMPICOMMWORLD, &commsz; MPICommrankMPICOMMWORLD, &myrank; printfProc d of d Does anyone have a toothpick? myrank, commsz; MPIFinalize; return ; main a Each process adds the received value from its left neighbour to its sum variable. b Send the received value from the left neighbour to its right neighbour. c Receive a value from its left neighbour. Steps in point are repeated until each process receives its own rank. Each process prints its rank and sum to the console. All processes finalize MPI. Copy the source code in your answers file. Launch the Command line and take a Screenshot of the window with the result of the program execution including your name. copy the Screenshot in your answers file Also, provide an explanation showing how the code works. marks PingPong Problem Write a MPI program to implement a pingpong between two processes. The number of pingpong is given by the user. The program steps are as follows: Initialize MPI. Get the rank and size of the communicator. Check if the number of processes is equal to Get the number of pingpong exchanges from the user. Start the pingpong communication loop Initially pingpong count : If the rank is send the pingpong count to rank and receive the pingpong count from rank If the rank is receive the pingpong count from rank and send the pingpong count to rank Increment the pingpong count. Repeat step until the pingpong count is equal to the number of pingpong exchanges. Finalize MPI. Copy the source code in your answers file. Launch the Command line and take a Screenshot of the window with the result of the program execution including your name. copy the Screenshot in your answers file Also, provide an explanation showing how the code works. marks
Parallel Computing Lab Assignment marks
Modify the program that just prints a line of output from each process mpi
output.c so that the output is printed in process rank order: process s
output first, then process s and so on
a Use pointtopoint communication.
b Use collective communication such as gather.
Copy the source code in your answers file. Launch the Command line and
take a Screenshot of the window with the result of the program
execution including your name. copy the Screenshot in your answers
file Also, provide an explanation showing how the code works.
marks
What is deadlock in MPI? Explain one scenario showing a Source of
Deadlocks in MPI send and receive functions with sample code?
mark
Ring Problem
Write a C program that implements a ring algorithm using MPI. The
program calculates the sum of all the processs ranks.
The program steps are as follows:
All processes initialize MPI.
Each process gets its rank and the total number of processes.
Each process calculates its left and right neighbours. For example, for
processor its left is equal to and its right is equal to
Each process initially sends its rank to its right neighbour and receives the
rank of its left neighbour and initialize the sum variable to its rank.
Then, repeatedly do the following:
File: mpioutput.c
Purpose: A program in which multiple MPI processes try to print a message.
Section pp
#include
#include
int mainvoid
int myrank, commsz;
MPIInitNULL NULL;
MPICommsizeMPICOMMWORLD, &commsz;
MPICommrankMPICOMMWORLD, &myrank;
printfProc d of d Does anyone have a toothpick?
myrank, commsz;
MPIFinalize;
return ;
main
a Each process adds the received value from its left neighbour to its
sum variable.
b Send the received value from the left neighbour to its right
neighbour.
c Receive a value from its left neighbour.
Steps in point are repeated until each process receives its own rank.
Each process prints its rank and sum to the console.
All processes finalize MPI.
Copy the source code in your answers file. Launch the Command line and
take a Screenshot of the window with the result of the program execution
including your name. copy the Screenshot in your answers file Also, provide
an explanation showing how the code works. marks
PingPong Problem
Write a MPI program to implement a pingpong between two processes.
The number of pingpong is given by the user. The program steps are as
follows:
Initialize MPI.
Get the rank and size of the communicator.
Check if the number of processes is equal to
Get the number of pingpong exchanges from the user.
Start the pingpong communication loop Initially pingpong count :
If the rank is send the pingpong count to rank and receive the
pingpong count from rank
If the rank is receive the pingpong count from rank and send the
pingpong count to rank
Increment the pingpong count.
Repeat step until the pingpong count is equal to the number of pingpong exchanges.
Finalize MPI.
Copy the source code in your answers file. Launch the Command line and
take a Screenshot of the window with the result of the program execution
including your name. copy the Screenshot in your answers file Also, provide
an explanation showing how the code works. marks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started