A fortran timing issue I cannot understand

后端 未结 1 1177
遇见更好的自我
遇见更好的自我 2020-12-21 23:29

I wrote (for my class in Numerical Methods for Theoretical Physics) a very simple program for a Random Walk in dimension 2. Here it is:

program random_walk

         


        
相关标签:
1条回答
  • 2020-12-22 00:08

    This is quite a typical thing to observe. People hit this when they create artificial computations which only test performance and do not create a useful result. When the result is not printed, the compiler can recognize that it does not need the result for the program output and may completely omit the computation.

    To examine it you can add the -fdump-tree-optimized flag to get a special source form called GIMPLE and you can compare the output for those two variants of the source code. It writes the output to a file called yourfilename.f90.something.optimized. I can indeed see a big part missing. Basically the whole r2 array and the operations with it are optimized out. You can also compare the generated assembly if you know that better.

    0 讨论(0)
提交回复
热议问题