<< 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"); }
Got questions? Get instant answers now!

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"
Got questions? Get instant answers now!

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?

Got questions? Get instant answers now!

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, High performance computing. OpenStax CNX. Aug 25, 2010 Download for free at http://cnx.org/content/col11136/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'High performance computing' conversation and receive update notifications?

Ask