Funny optimization behavior?

I use PGI fortran 90 on a 64-bit AMD Linux system.

A program that finds fastest paths through a sparse graph is giving
me weird behavior.

I have two different models, one about twice the size as the other.

With no optimization the larger model takes longer to run, as expected.

With O2 both run faster but the larger model very much so; it is now
MUCH quicker than the smaller model!

I get the same behavior on a different machine, Lahey fortran compiler.

If I knew why this happens I could try to exploit it more often.

-info with -O2 lists only a few very minor optimizations, the same for both
programs.

Hi Russell,

The profiler should be able to help you determine what’s going on. Compile your code with “-O0 -Mprof=lines” and run both the large and small data sets. Be sure to save the “pgprof.out” in between each run. Recompile and rerun each data set with “-O2 -Mprof=lines”.

Using PGPROF, you can do a “scalability comparison” (See section 2.2.5 of the PGI Tools Guide) to compare the profiles of the “-O0” and “-O2” run and/or the large and small data set run. This should help identify where the speed-up is occurring. It’s also possible that the small data set is encountering a bottleneck. Note that line numbers may be off between the “-O0” and “-O2” versions since some optimizations cause lines to be rearranged.

Hope this helps,
Mat

Hi,

Since you are using Linux, then you may want to first try -Mprof=time rather than -Mprof=lines. While -Mprof=lines measures time for each source line, it usually takes longer to run than -Mprof=time. -Mprof=time performs sample based profiling. You won’t get time for each source line with it, but you will likely capture the slow parts of your code.

-Mark