Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to design and write a C program utilizing MPI to efficiently process a s

ID: 3602045 • Letter: Y

Question

You are to design and write a C program utilizing MPI to efficiently process a sequence Chroma key Green-screen frames like we did in Homework #8 to create a video of the "Loch Ness monster." To start the homework, download and extract hw10.zip from the eLearning system, and copy the hw10 directory to briareus.physics.uni.edu using a secure ftp client (winSCP, FileZilla, scp, etc.). The hw10 folder contains · 99 pictures (nessie001.ppm. , nessie099,ppm) showing the "Loch Ness monster" moving across a green-screen background (The .ppm format is used here for its simplicity-http://www.fileformat.info format pbmegff htm) * a picture of "Loch Ness" called swans.ppm that's to be used as the new background picture replacing the green- screen background in the "nessie" pictures to generate 99 new pictures: frame001.ppm, ..., frame099.ppm a sequential version of the program seqChromakey.cwhich takes about 18.5 seconds (on fermil.cs.uni.edu) to produce

Explanation / Answer

program hello_world
include '/usr/include/mpif.h'
integer ierr

call MPI_INIT ( ierr )
print *, "Hello world"
call MPI_FINALIZE ( ierr )

stop
end
program hello_world
include '/usr/include/mpif.h'
integer ierr, num_procs, my_id

call MPI_INIT ( ierr )

c find out MY process ID, and how many processes were started.

call MPI_COMM_RANK (MPI_COMM_WORLD, my_id, ierr)
call MPI_COMM_SIZE (MPI_COMM_WORLD, num_procs, ierr)

print *, "Hello world! I'm process ", my_id, " out of ",
& num_procs, " processes."

call MPI_FINALIZE ( ierr )

stop
end
When we run t

program hello_world
include '/usr/include/mpif.h'
integer ierr, num_procs, my_id

call MPI_INIT ( ierr )

c find out MY process ID, and how many processes were started.

call MPI_COMM_RANK (MPI_COMM_WORLD, my_id, ierr)
call MPI_COMM_SIZE (MPI_COMM_WORLD, num_procs, ierr)

print *, "Hello world! I'm process ", my_id, " out of ",
& num_procs, " processes."

call MPI_FINALIZE ( ierr )

stop
end
When we run t
parameter (max_rows = 10000000)
real vector(max_rows)

print *, "please enter the number of numbers to sum:"
read *, num_rows
if ( num_rows .gt. max_rows) stop "Too many numbers."

c initialize a vector.

do I = 1, num_rows
vector(i) = float(i)
end do

c compute sum.

sum = 0.0
do i = 1, num_rows
sum = sum + vector(i)
end do

print *, "The grand total is: ", sum

stop
end

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
sum=0;
for(k=0;k<n;k++)
sum+=a[i*n+k]*b[k*n+j];
c[j+n*i] = sum;
}
}
#pragma omp parallel for num_threads(nThreads) shared(a,b,c,n) private(temp,i,j,k) // using OMP pragma for parallel
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
sum=0;
for(k=0;k<n;k++)
sum+=a[i*n+k]*b[k*n+j];
c[j+n*i] = sum;
}
}
#include <iostream>
#include "mpi.h"
int main(int argc, char **argv)
{
int rank, size, tag, rc, i;
MPI_Status status;
char message[20];
rc = MPI_Init(&argc, &argv);
rc = MPI_Comm_size(MPI_COMM_WORLD, &size);
rc = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
tag=7;
if (rank==0) {
strcpy(message, "Hello, world");
for (int i=1;i<size;++i)
rc = MPI_SEND(message, 13, MPI_CHAR, i, tag, MPI_COMM_WORLD);
}
else
rc = MPI_RECV(message, 13, MPI_CHAR, 0, tag, MPI_COMM_WORLD,
&status);
std::cout<<"node "<<rank<<": "<<message<<std::endl;
rc = MPI_Finalize();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote