<< Chapter < Page | Chapter >> Page > |
Does your compiler recognize dead code in the program below? How can you be sure? Does the compiler give you a warning?
main()
{int k=1;
if (k == 0)printf ("This statement is never executed.\n");
}
Compile the following code and execute it under various optimization levels.
Try to guess the different types of optimizations that are being performed to improve the performance as the optimization is increased.
REAL*8 A(1000000)
DO I=1,1000000A(I) = 3.1415927
ENDDODO I=1,1000000
A(I) = A(I) * SIN(A(I)) + COS(A(I)) ENDDOPRINT *,"All Done"
Take the following code segment and compile it at various optimization levels. Look at the generated assembly language code (–S option on some compilers) and find the effects of each optimization level on the machine language. Time the program to see the performance at the different optimization levels. If you have access to multiple architectures, look at the code generated using the same optimization levels on different architectures.
REAL*8 A(1000000)
COMMON/BLK/A.... Call Time
DO I=1,1000000A(I) = A(I) + 1.234
ENDDO.... Call Time
END
Why is it necessary to put the array into a common block?
Notification Switch
Would you like to follow the 'High performance computing' conversation and receive update notifications?