Question: #include //this library is needed for printf function #include //this library is needed for rand() function #include //this library is needed for pause() function #include

 #include //this library is needed for printf function #include //this library

#include //this library is needed for printf function #include //this library is needed for rand() function #include //this library is needed for pause() function #include //this library is needed for clock() function #include //this library is needed for abs()

void init(); void MVM();

#define N 256 //input size float Y[N], X[N],A[N*N],test[N];

#define TIMES_TO_RUN 1 //how many times the function will run

int main() {

//define the timers measuring execution time clock_t start_1, end_1; //ignore this for now

init();

start_1 = clock(); //start the timer

for (int i = 0; i

end_1 = clock(); //end the timer

printf(" clock() method: %ldms ", (end_1 - start_1) / (CLOCKS_PER_SEC / 1000));//print the ex.time

system("pause"); //this command does not let the output window to close

return 0; /ormally, by returning zero, we mean that the program ended successfully. }

void init() {

float e = 0.1234f, p = 0.7264f, r = 0.11f;

//MVM for (unsigned int i = 0; i

for (unsigned int j = 0; j

void MVM() {

for (int i = 0; i

}

1. Attatched is the file mvm.cpp This is a program that multiplies two arrays (mvm() routine) and prints the elapsed execution time. A. Amend the above program so as to print the FLOPs (Floating Point Operations per Second) value achieved by the mvm() routine. The FLOPs value is given by the following formula FLOPS = (2xN2)/Ex. Time, where N is the input size and Ex. Time is the execution time of the mvm() routine [5 Marks]. B. Make a graph of Ex. Time vs N and a graph of FLOPs vs N, where N=[100, 500, 1000, 2000, 4000, 8000, 10000, 12000, 14000, 16000). The FLOPs and Ex. Time values must be shown in the y-axis while the N value must be shown in the x-axis [5 Marks]. C. Explain the two graphs in task B (in no more than 3 lines). For example, why the FLOPS value is decreased as N increases? Why the Ex.Time does not increase in a linear way? [10 Marks] D. Amend this program to allocate all the arrays dynamically, by using malloc() function (10 Marks] E. Write a script in Linux (.sh file) which automates the experimental procedure of step B [10 Marks]. The script should do the following: Print a message such as : This is a script that ... Compile the mvm.cpp program and generate the binary file (executable) Run the executable with the following parameters: N=100 and Iterations=10. TO this end, the N and the Iterations values must be passed as input to the executable Repeat the step above for the other N and Iterations values (do not use a loop)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!