How do the times you got with the clock function compare


Problem

Programmers should be familiar with message passing interface and how to distinguish between distributed memory and message passing systems.

Point-to-point communication time of a specific system can be found using the ping-pong method. One process P0, is made to send a message to another process, say P1. Immediately upon receiving the message, P1 sends a message back to P0. The time involved in this message communication is recorded at P0. Then this time is divided by two to obtain an estimate of the time of one-way communication.

Describe a program in OpenMP or CUDA that explores message passing interface and how a distributed memory system would also improve the ping-pong method. Refer to the Sample MPI Program below. Measure the communication times. You can time a ping-pong program using the C clock function on your system. Then answer the following:

i. How long does the code have to run before the clock gives a nonzero run-time?
ii. How do the times you got with the clock function compare to times taken with OpenMP or CUDA timing API? Explain your answer.

#include "mpi.h"
int main (int argc, char *argv[])
{
int pad = 0, dimx = 480 + pad, dimy =480, dimz = 400, noreps = 100;
int pid = -1, np = -1;
MPI_Init (&argc, &argv);
MPI_comm_rank (MPI_COMM_WORLD, &pid);
MPI_Comm_size (MPI_COMM_WORLD, &np);
if (np < 3)
{
if pid == 0)
{
printf ("Needed 3 or more processes.n");
MPI_Abort (MPI_COMM_WORLD, 1);
return 1;
}
}
if (pid < np - 1)
{
compute_process(dimx, dimy, dimz/(np - 1), nreps);
}
else
{
data_server( dimx, dimy, dimz, nreps);
}
MPI_Finalize();
}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: How do the times you got with the clock function compare
Reference No:- TGS03332994

Expected delivery within 24 Hours