Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need the chart filled out C programming sum_full.c file: /* * Sum of a*X[N] */ #include #include #include #include #include /* read timer in second

Need the chart filled out

C programming

sum_full.c file:

/* * Sum of a*X[N] */ #include  #include  #include  #include  #include  /* read timer in second */ double read_timer() { struct timeb tm; ftime(&tm); return (double) tm.time + (double) tm.millitm / 1000.0; } /* read timer in ms */ double read_timer_ms() { struct timeb tm; ftime(&tm); return (double) tm.time * 1000.0 + (double) tm.millitm; } #define REAL float #define VECTOR_LENGTH 102400 /* initialize a vector with random floating point numbers */ void init(REAL A[], int N) { int i; for (i = 0; i  (default %d) ", N); } else N = atoi(argv[1]); REAL *X = (REAL*)malloc(sizeof(REAL)*N); REAL *Y = (REAL*)malloc(sizeof(REAL)*N); srand48((1 image text in transcribedimage text in transcribed
4. Compile the sum_full.c file step-by-step using -E, -S, -c option and then finally link to create executable. Again each step performs the corresponding compilation operation which is shown by the "gcc --help" command. You can check for more details about those steps from a ). Check the intermediate compilation output and do not move on the next step unless previous step is successful. -E -S -C -0 Preprocess only; do not compile, assemble or link Compile only; do not assemble or link Compile and assemble, but do not link Place the output into vi sum_full.c gcc-E sum_full.c-o sum_full.i gcc -S sum_full.i gcc-C sum_full.s gcc sum_full.o -o sum "gcc-save-temps sum_full.c-o sum" can do all the steps at once and also produce all the intermediate files. But in this exercise, you should use the flag to compile step by step. 5. Execute the sum and time it: ./sum 100000 time ./sum 10000000 for MOON 6. Execute the sum program with perf command. (Check more perf command) perf stat ./sum 100000 7. Use perf command to collect execution profile of sum_full.c program. After collecting execution profile, which includes number of cycles, number of instructions and CPU frequency, calculate the number of cycles and instructions for the loop of the sum method itself. Then calculate the CPI and CPU time (ms) using the formula we learned during the class (check slides from or textbook 1.6). Fill in the following table using the information you collect or calculate. The CPU time (ms) outputted by the program itself is the Runtime (ms) column of the program output. For the following table columns, The CPU Time you calculate is the modeled execution time and the 2 CPU Time output from the program is the actual measured time. By comparing these two columns, you should be ablet o see the difference between modeled time and measured time. Important, for perf, cycles and instructions collected from perf output of ./sum 0 are the baseline numbers. To derive the cycles and instructions of sum call itself, e.g. ./sum 1000, cycles and instructions of perf output of ./sum 1000 execution should be subtracted by the corresponding baseline number. Size #Cycles # Instructions CPI CPU Freq CPU Time (ms) for sum CPU time (ms) (Clock Rate) loop (#cycles/Clock Rate outputted by the (GHz) and convert it to ms) program itself 0 100 1000 10000 100000 1000000 10000000 4. Compile the sum_full.c file step-by-step using -E, -S, -c option and then finally link to create executable. Again each step performs the corresponding compilation operation which is shown by the "gcc --help" command. You can check for more details about those steps from a ). Check the intermediate compilation output and do not move on the next step unless previous step is successful. -E -S -C -0 Preprocess only; do not compile, assemble or link Compile only; do not assemble or link Compile and assemble, but do not link Place the output into vi sum_full.c gcc-E sum_full.c-o sum_full.i gcc -S sum_full.i gcc-C sum_full.s gcc sum_full.o -o sum "gcc-save-temps sum_full.c-o sum" can do all the steps at once and also produce all the intermediate files. But in this exercise, you should use the flag to compile step by step. 5. Execute the sum and time it: ./sum 100000 time ./sum 10000000 for MOON 6. Execute the sum program with perf command. (Check more perf command) perf stat ./sum 100000 7. Use perf command to collect execution profile of sum_full.c program. After collecting execution profile, which includes number of cycles, number of instructions and CPU frequency, calculate the number of cycles and instructions for the loop of the sum method itself. Then calculate the CPI and CPU time (ms) using the formula we learned during the class (check slides from or textbook 1.6). Fill in the following table using the information you collect or calculate. The CPU time (ms) outputted by the program itself is the Runtime (ms) column of the program output. For the following table columns, The CPU Time you calculate is the modeled execution time and the 2 CPU Time output from the program is the actual measured time. By comparing these two columns, you should be ablet o see the difference between modeled time and measured time. Important, for perf, cycles and instructions collected from perf output of ./sum 0 are the baseline numbers. To derive the cycles and instructions of sum call itself, e.g. ./sum 1000, cycles and instructions of perf output of ./sum 1000 execution should be subtracted by the corresponding baseline number. Size #Cycles # Instructions CPI CPU Freq CPU Time (ms) for sum CPU time (ms) (Clock Rate) loop (#cycles/Clock Rate outputted by the (GHz) and convert it to ms) program itself 0 100 1000 10000 100000 1000000 10000000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions