GFORTRAN Optimization Question

In summary, the programmer is trying to compile a program with optimization on their .f source, but the compilation will not work with versions past 5.4. The programmer is suggesting that they use profiling to determine the issue. The problem is that the program will not work on other platforms as well, due to the way Linux memory buffers files are opened. The programmer also suggests that the bug may be due to incorrect input, specifically the type of file that was recently opened.
  • #1
jelanier
67
1
TL;DR Summary
compiling with O level parameters individually does not equal O level
I am trying to troubleshoot why GFORTRAN versions beyond 5.4 will not compile with optimization on some of my .f source.
You can request options included in each level by:
Gfortran -Q -O1 --help=optimizers > listO1.txt (as an example)
When I enter the enabled flags individually and compile, they do not equal the -O1 composite. I know this by compiling and running a program using each example. Huge difference. What am I missing? Is this a major bug?

Thanks on advance

Jim
 
Technology news on Phys.org
  • #2
Do you know how to compile to turn on profiling? You can run gprof for each compiled version.

Why am I suggesting this. Are you opening files - Linux puts recently opened files into memory buffers so version 1 will run more slowly when compared against version 2 (assuming it ran second from the same parent process - e.g., keyboard command line) - because 2 reads from memory. Other OSes do this, too. This is an example of how your timing test is likely to be confounded. Use profiling. And AFAIK the two should be very much the same.

See:: https://docs.oracle.com/cd/E19957-01/805-4940/6j4m1u7q6/index.html
 
  • #3
jim mcnamara said:
Do you know how to compile to turn on profiling? You can run gprof for each compiled version.

Why am I suggesting this. Are you opening files - Linux puts recently opened files into memory buffers so version 1 will run more slowly when compared against version 2 (assuming it ran second from the same parent process - e.g., keyboard command line) - because 2 reads from memory. Other OSes do this, too. This is an example of how your timing test is likely to be confounded. Use profiling. And AFAIK the two should be very much the same.

See:: https://docs.oracle.com/cd/E19957-01/805-4940/6j4m1u7q6/index.html
That isn't it. I run this on Windows minGW and MacOS. Any compiled executable regardless order of execution has huge difference in speed and behavior. The composite Options -O -O2 -O3 will not work the same as when flags are individually added to compile batch.
 
  • #4
http://www.mingw.org/Reporting_Bugs

Try reporting, you can search the bug list first. Especially since you have a cross-platform problem - Mac & Windows, they should respond quickly.

Helpful hint:
We would have been here a lot sooner here if you had provided those last bits of information. Testing & platform. You will have to give EXACT, complete information when reporting a bug. Or it will be ignored. That will include your compile command(s) and OS versions (and windows 10 current update), and library versions. Especially if you are linking against things like LAPACK. That broke optimizations a while back.
 
Last edited:
  • #5
i have since found the culprit and I will report. I took the diff between -Og and -O1 . I then added those flags to -Og to make an equivalent -O1 and it works. So basically calling -O in the batch adds something screwy that kills it. This has been in Gfortran code on all versions starting with v6.x.

Later my friend,

Jim
 

Related to GFORTRAN Optimization Question

1. How can I optimize my GFORTRAN code?

Optimizing GFORTRAN code involves identifying and removing unnecessary computations, using efficient algorithms and data structures, and utilizing compiler optimization options. It is also important to consider the use of parallel processing and vectorization to improve performance.

2. What are some common optimization techniques for GFORTRAN?

Some common optimization techniques for GFORTRAN include loop unrolling, loop fusion, and loop interchange. Additionally, using intrinsic functions and avoiding unnecessary type conversions can also improve performance.

3. How do I know if my GFORTRAN code is optimized?

There are a few ways to determine if your GFORTRAN code is optimized. One way is to use profiling tools to identify bottlenecks and areas for improvement. Additionally, benchmarking your code against different optimization settings can also help determine the most efficient version.

4. Can I use GFORTRAN optimization techniques for other programming languages?

While some optimization techniques may be applicable to other programming languages, such as loop unrolling, others may be specific to GFORTRAN. It is important to research and understand the optimization techniques that are best suited for the programming language you are using.

5. Are there any limitations to GFORTRAN optimization?

While GFORTRAN optimization can greatly improve performance, there are some limitations to consider. For example, not all code can be optimized, and some optimizations may not have a significant impact on performance. Additionally, over-optimization can sometimes lead to unintended consequences and errors.

Similar threads

  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
6
Views
5K
  • Programming and Computer Science
2
Replies
41
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
Replies
10
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
2K
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top