0

We have a Fortran code base, that consists of large (over 5K lines) module files. The files grew so much, because of the fear, that the compiler would not be able to consider inlining cross-module function calls.

Is it still a concern with gcc >= 5.0?


We want to know if splitting the code into distinct modules would hinder the performance (as it did in the times, where there was no link-time optimization). Otherwise, we will use #includes, but we prefer to avoid it.

Adam Ryczkowski
  • 7,592
  • 13
  • 42
  • 68
  • 1
    Even if we said "yes it can", that won't necessarily help your case. Can you provide indications of layout, the sort of problems you anticipate hindering such inter-procedure analysis, and so on? – francescalus Jul 26 '18 at 11:53
  • Are you aware of what "pure" means in Fortran terms? If so, are you considering further restrictions on the behaviour of the functions of interest? – francescalus Jul 26 '18 at 11:57
  • That doesn't seem very hard to try. – Marc Glisse Jul 26 '18 at 12:11
  • Yes, it can. Can it inline *your* function? Will it *want* to inline it? Who knows. – Vladimir F Героям слава Jul 26 '18 at 12:55
  • @francescalus Yes, I am writing about pure functions. – Adam Ryczkowski Jul 26 '18 at 13:52
  • @MarcGlisse yes, if I were a Fortran programmer, it would be easy. You would not find professional Fortran programmers in our organization - we are primarily physics who happen to use the Fortran for our simulations. So the cost of trying out are higher that it seem on the first sight. I wrote in hope that someone already knows that - I assume it should be a common knowledge. – Adam Ryczkowski Jul 26 '18 at 13:57
  • 1
    Just try it, t, really. Even if it works for us, it may not work for your function. How much inlining is performance-critical for you anyway? I remember having to disable link time optimizations for a module where inlining was unwanted (not performance related) so it should definitely work. – Vladimir F Героям слава Jul 26 '18 at 14:12
  • 2
    @AdamRyczkowski it might seem at first that the commenters here are not helping. For your question there is no way for outsiders to actually help. The compilers have some freedom in their decisions for optimization and we cannot predict what will happen. You can get some information from gfortran with the flag `-fopt-info` that will tell you about optimizations missed or performed by the compiler. – Pierre de Buyl Jul 26 '18 at 19:13
  • @all Of course, I understand, that the fact if the particular optimization opportunity will happen is up to the compiler. I just want to know, if the compiler would ever *consider* this kind of link-time optimizations, because some 10 years ago it did not, and that is why we keep those monumental one-file-all-code source file. So the first comment actually answered my question. That is all I wanted to know. – Adam Ryczkowski Jul 28 '18 at 16:10

0 Answers0