Someone decided to use the following C code as part of a benchmark to determine the performance of a computer including its memory. It has two potential faults. What are they?


for (i = 0; i < 100; i++){
p = q * s + 12345
x = 0.0;
for (j = 0; j < 60000; j++){
x = x + A[j] * B[j];
}
}


First, note that the expression p = q * s + 12345 is static (i.e, it does not change on each trip round the loop). Consequently, optimizing compiler would re?order the code and calculate this expression only once.

Second, the entire inner loop is independent of the outer loo variable i. Consequently, an optimizing compiler would not repeat this calculation.

Second, loops are problematic. Your compiler may perform automatic loop unrolling (performing two or more iterations per trip).

Note also that array access can lead to problems with the size of cache line and the size of pages in virtual memory systems.

Computer Science & Information Technology

You might also like to view...

The name of a structure is referred to as its

a. data type b. argument c. parameter d. tag e. None of these

Computer Science & Information Technology

________ testing is how did the user feel about the tasks completed

A) Emotional response B) Accuracy C) Recall D) Performance

Computer Science & Information Technology

Critics of copyrights often advocate __________________.

A. copyleft B. NPOV C. trademarks D. none of the above

Computer Science & Information Technology

The ________ Analyzer tool makes suggestions to minimizing the duplication of data.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology