-
Notifications
You must be signed in to change notification settings - Fork 0
Too aggressive default optimization? #1321
Comments
Underflow warnings may not necessarily be cause for concern, though I suppose it depends on where they occur in the code. I'll add this as a topic for discussion on the 15 May telecon. |
Thanks Michael, I was going to add it as well. My bigger concern was the change with optimization number. I've seen -O3 described as unsafe, which also is cause potentially for concern. |
Guys, the description of -O3 as unsafe is kinda like a consumer warning generally and more of a CYA for the compiler vendor. I have found instances of too-aggressive optimizations very rare and compiler vendors normally include those sorts of optimizations as separate flags for those who feel they can trade accuracy for performance. Reducing to -O2 usually leaves too much performance on the table, so would not advocate for a general reduction. @akturner , I'm happy to look at the routine is question and see if I can suss out the problem and see if a coding/algorithm modification can fix. In the worst case, we can reduce the optimization level for that routine only if it truly is causing a problem. |
There are the lines causing the initial denorm and underflow warnings. |
All of these have the form: This will still lead to underflows in the intermediate exp evaluation that are nominally replaced by exp_min. This leaves you at the mercy of the compiler's implementation/management the underflow itself. A more robust approach would be to limit the argument to exp, e.g.: |
@philipwjones : Yes, thats what I've done. Yet still an underflow warning persists just with -O3. And goes away with print statement around your suggested modifications. See here for my corrections: https://github.com/akturner/MPAS/tree/cice/ieee_exceptions |
@akturner - sorry I misunderstood - thought the lines you were pointing me to were the fixes. For which compiler/machine is this happening? I'll see if it's an actual bug or whether they're just trying to avoid a memory op. In the meantime, you can try the confuse-a-compiler trick and reorder the statements so that tmpexp isn't adjacent to the exp evaluation. Or maybe see whether it's ts that's getting large (and limit that) or whether it's the other factors that are pushing it too large. |
@philipwjones: No worries - don't think I was clear! This is happening on OSX and with gfortran. I will try your suggestions. |
@akturner With gfortran, you can try using the flags |
@mgduda: Thanks! |
@akturner , try it on Wolf. Or you can try running within lldb on your mac like |
The sea ice core has had for a while denormalization and underflow warnings. I have located the places these warning are generated (in the column physics package) and fixed them. In doing so I discovered some disturbing behaviour. A underflow warning remains but only with -O3 optimization, not -O[0-2]. Also putting print statements around the fixed code regions removes the warnings for -O3. I'm concerned that using -O3 as our default optimization is too aggressive. This level of optimization is often described as unsafe and I wonder whether we should change to -O2.
The text was updated successfully, but these errors were encountered: