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

Your console program should print out ( using formatted printf commands ) 1) you

ID: 3703760 • Letter: Y

Question

Your console program should print out ( using formatted printf commands )

1) your name

2) Processor name

3) Processor Clock frequency

4) the vector/array dimension

5) # of accuracy loops,

6) total measured execution time,

7) evaluated execution time to the entire array,

8) evaluated execution time per array element,

9) evaluated execution time per arithmetic operation,

10) evaluated cycles per arithmetic Op,

11) evaluated Ops per cycle, and

12) evaluated double precision operations per second

Write a C programming language console program of the vector multiply-add "axpy" algorithm for double precision floating data types: i-(ax) ylil a) Execution should be scalable and be Your C program should be single threaded, and sequential. able to handle the number of vector elements, N, from 1 to 1,000,000. Set the vector/array dimension using a DEFINE statement. Use a random number generator which every time the program is executed fills the random data into the scalar and vector elements with random double precision floating point values ranging from 1 to 100 The console window should execute and remain open until manually closed. Comment your code to explain what it is doing. You should use the time.h header file library, and either the "time_t or clock t timer functions to capture the start and end execution times for your benchmark. You will need to use an outer accuracy improvement loop in your program. Adjust the total number of iterations of your inner and outer accuracy improvement loops so that total execution time is approximately constant as you vary the dimensions of your x, y and z arrays from 1 to 1,000,000.

Explanation / Answer

#include<stdio.h>

#include<time.h>

#include<stdlib.h>

#include<math.h>

#define MAX 50000 double random_generate()

{

return 1.0+((double)rand()/RAND_MAX)*100; //double precision random number between 1 to 100//

}

int main()

{ clock_t total_t; total_t = clock(); //total execution time double x[MAX];//

vectors x,y,z; double y[MAX]; double z[MAX];

int i; int a = 10;

double total_time = 0.0;

double total_array_time = 0.0;

double total_arithmatic_time = 0.0;

double total_elm_time = 0.0;

clock_t array_t;

clock_t arth_time;

clock_t elm_time;

array_t = clock();

for(i=0;i<MAX;i++)

{

elm_time = clock();

x[i] = random_generate();

y[i] = random_generate();

arth_time = clock();

z[i] = a*x[i];

z[i] = z[i] + y[i];

arth_time = clock() - arth_time;

total_arithmatic_time += ((double)arth_time)/CLOCKS_PER_SEC; in seconds //

elm_time = clock() - elm_time; total_elm_time += ((double)elm_time)/CLOCKS_PER_SEC; // in seconds

}

array_t = clock() - array_t; total_array_time = ((double)array_t)/CLOCKS_PER_SEC;

total_t = clock() - total_t; total_time = ((double)total_t)/CLOCKS_PER_SEC; // in seconds//

printf("Processor : i3 ");

printf("Processor Clock Frequency : 2.00GHz ");

printf("Total Execution Time = %lf ",total_time);

printf("Total Array Time = %lf ",total_array_time);

printf("Total Time PER Arthimatic Ops = %lf ",total_arithmatic_time/MAX);

printf("Total time per Array Element = %lf ",total_elm_time/MAX);

return 0;

}

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