Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-coverage flag and optimization #60

Closed
zbeekman opened this issue Jun 11, 2015 · 8 comments
Closed

-coverage flag and optimization #60

zbeekman opened this issue Jun 11, 2015 · 8 comments

Comments

@zbeekman
Copy link
Contributor

FoBiS.py should be adding -O0 not -O2 when the -coverage flag is used, otherwise inlining will lead to inaccurate coverage reports.

@szaghi
Copy link
Owner

szaghi commented Jun 11, 2015

Absolutely right, tomorrow I will fix this issue, thank you

@szaghi
Copy link
Owner

szaghi commented Jun 12, 2015

Fixed (in v1.6.8).

Now if the -coverage switch is used the user (or default) cflags are checked for eventual optimizations, .i.e. -O[1-9], and, in case, disabled. If no optimization is found, -O0 is forced anyway.

See you.

@szaghi szaghi closed this as completed Jun 12, 2015
@zbeekman
Copy link
Contributor Author

Stefano, thanks for the prompt fix!

Just a quick note: all compilers override options listed earlier with those listed later, so your parsing of cflags is probably unnecessary as long as you make sure the user defined cflags come last of all the arguments, as these should always over ride any flags set by FoBiS.py. At any rate, explicitly parsing the user passed cflags and removing -O0 added by coverage if the user passes a different optimization level will reduce the verbosity of the output and improve the clarity of what is happening, so I think it is a good idea, even though it is not strictly necessary.

Just FYI, I think there are more optimization levels that will escape your regexp: looking at the Intel Fortran Compiler’s man page I see the following additional optimization levels are available:

  • -O: Same as specifying -O2
  • -Os: Enable all optimizations that won’t increase the size of the compiled code
    • -Ofast: Sets very aggressive optimization flags: -O3, -no-prec-div, and -fp-model fast=2
    • -O0: No need to add an additional -O0 if the user explicitly requests it

It may be worthwhile to update the regexp to something like:
-O[0-9,s] to include the -O0 and -Os flags as these are pretty ubiquitous across different compilers. But, as I stated above, things will always work correctly whether or not you parse the user cflags as long as they are the right-most (last) options passed to the compiler.

Hope fatherhood is going well so far. Be sure to let us poor Fortran programmers know when your daughter can say “implicit none” 😄

@szaghi
Copy link
Owner

szaghi commented Jun 12, 2015

Dear Izaak, you are welcome!

You are right in all points, but I like parsing the flags for a better sanitization and clearness...

You are rigth also for the different switch names triggering optimization. Your proposed regex is smart, monday I will use it when I will fix your other issue. However, capturing the switches of many compilers is a boring stuff, I do not intend to make the regex too comlicated for capturing also exotic switch like -no-prec-div. Maybe a workaround could be allow the user to specify such a not so usual (or strongly compiler dependent) switch name. What do you think?

Angelica (my daugther) is now programming a type bound procedure for auto-refilling her baby-bottle with double-malt-milk... however she did not still understood the importance of implicit none statement basing her comunications on implicit types... what the hell is she saying when the output is uuuueeeeeeuuuueeeeeeeeeuuu for more than a hour...??!??

@zbeekman
Copy link
Contributor Author

I’m glad to hear Angelica is well! I’m sure you’re very happy but also very busy!

I think that you should not mess with user specified cflags. These should be provided last so that the user can override anything else being set by FoBiS.py. Most compilers respect that convention and if a user is explicitly passing her own -cflags then she knows what she is doing… and she may be intentionally trying to override what FoBiS.py thinks is the right thing to do. FoBiS.py should pass these user cflags along to the compiler faithfully, and at the end of the compile command. A user may be able to gain insight by passing coverage and cflags ' --O2' if they’re trying to figure out some strange behavior like a compiler bug or want more insight on the difference between the optimized code and the unoptimized code.

If you want to run a regexp against the default or FoBiS.py inserted cflags, something simple like what you have or -O[0-3s]? should work. But please don’t edit user cflags! Life is indeed too short to try to support every single compiler flag

@szaghi
Copy link
Owner

szaghi commented Jun 12, 2015

👍

I agree and Angelica too!

@szaghi
Copy link
Owner

szaghi commented Jun 15, 2015

@zbeekman

I forget to say that now FoBiS.py follows your suggestion: it does not try to parse the cflags, but it simply add -O0 to the coverage flags (rely on the hopefully overriding feature of the compiler). However a warning is printed in case an optimization is found (by means of your regex [0-9,s]).

@zbeekman
Copy link
Contributor Author

sounds good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants