High performance computing print out \"Hello Worid\" The purpose of this lab is
ID: 3730730 • Letter: H
Question
High performance computing print out "Hello Worid" The purpose of this lab is to familiarize you with the Cloud 9 environment and show a simple comparison of sequential c++, OpenMP, and MP programs. 1. Log onto Cloud 9 and create a folder Labl. In the directory write and run a program that prints Hello World about 1000 times. Write a second program using OpenMP which writes HelloWorld OpenMP about 1000 time. Write a third program using MPI which writes Hello World MPI about 1000 times. . Time each of the 3 programs by running each program at least 20 times and recording the wall clock time, calculate the average and standard deviation of your 20 timing values. 2. Tabulate the number of cores (processors) your program used and average times and standard deviation for the 3 different programs Compare the resulting average times. Is this what you expected? . . . 3. What is the Speedup Factor, Sip), of your 2 parallel programs? S(p) = ts/tp. where t, is execution time on a single processor, and t, is execution time on a multiprocessor. 4. Discuss your resultsExplanation / Answer
SEQUENTIAL:
#include <iostream>
#include <time.h>
using namespace std;
int main() {
clock_t t;
t = clock();
for(int i=0;i<1000;i++)
cout<<"Hello World!!"<<endl;
t = clock() - t;
cout<<"Time Takn: "<<t<<"Clock Ticks and"<<(((float)t)/CLOCKS_PER_SEC)<<"seconds"<<endl;
}
OPENMP:
#include <iostream>
#include <time.h>
#include <omp.h>
using namespace std;
int main() {
clock_t t;
t = clock();
#pragma omp parallel for
for(int i=0;i<1000;i++)
cout<<"Hello World OpenMP!!"<<endl;
t = clock() - t;
cout<<"Time Takn: "<<t<<"Clock Ticks and"<<(((float)t)/CLOCKS_PER_SEC)<<"seconds"<<endl;
}
MPI:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
clock_t t;
t = clock();
// Initialize the MPI environment
MPI_Init(NULL, NULL);
// number of processes
int num_process;
MPI_Comm_size(MPI_COMM_WORLD, &num_process);
// rank of the process
int rank_process;
MPI_Comm_rank(MPI_COMM_WORLD, &rank_process);
// name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);
for(int i=0;i<1000;i++)
printf("Hello World MPI!! processor %s, rank %d"
" out of %d processors ",
processor_name, rank_process, num_process);
// Finalize the MPI environment.
MPI_Finalize();
t = clock() - t;
cout<<"Time Takn: "<<t<<"Clock Ticks and"<<(((float)t)/CLOCKS_PER_SEC)<<"seconds"<<endl;
}
NOTE: To run MPI program, export MPIRUN and MPI_HOST and run run.py script. Pass c++ source file as input to run.py
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.