- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I just noticed that the Intel C++ compiler doesn't honor a #pragma float_control(precise, on) request when it's not in the global namespace. For example, the following code triggers the
"warning #1670: this pragma may only appear between declarations in the global scope or before any statements or declarations in a block scope"
for both pragma declarations and the compiler ignores the pragma (I've tested this).
BTW, I find the documentation of the floating-point optimization levels somewhat lacking. For example, describing the value safety of the fast=1,2 modes as "unsafe" and "very unsafe" isn't really informative. More details about the kind of optimizations that are applied on the different levels would be really helpful.
Stephan
I just noticed that the Intel C++ compiler doesn't honor a #pragma float_control(precise, on) request when it's not in the global namespace. For example, the following code triggers the
"warning #1670: this pragma may only appear between declarations in the global scope or before any statements or declarations in a block scope"
for both pragma declarations and the compiler ignores the pragma (I've tested this).
[cpp]namespace myname {I wonder:
#pragma float_control(precise, on, push)
double test(double x) {
// do some computation where float associativity matters and return result
}
#pragma float_control(pop)
} // namespace
[/cpp]
- Are namespaces no block scopes?
- Is this an Intel bug, since Visual Studio doesn't have a problem with this pragma inside a namespace?
- Can the optimizer be trusted to honor the float_control(precise) request if a function gets inlined?
BTW, I find the documentation of the floating-point optimization levels somewhat lacking. For example, describing the value safety of the fast=1,2 modes as "unsafe" and "very unsafe" isn't really informative. More details about the kind of optimizations that are applied on the different levels would be really helpful.
Stephan
Link Copied
12 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - stephan_
describing the value safety of the fast=1,2 modes as "unsafe" and "very unsafe" isn't really informative. More details about the kind of optimizations that are applied on the different levels would be really helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the info, Tim.
I'm still hoping someone from Intel might comment on the main questions of my post.
I'm still hoping someone from Intel might comment on the main questions of my post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - stephan_
Thanks for the info, Tim.
I'm still hoping someone from Intel might comment on the main questions of my post.
I'm still hoping someone from Intel might comment on the main questions of my post.
Hi Stephan,
To your questions:
1. Are namespaces no block scopes?
Namespaces are not block scopes as you cannot put a statement in a namespace that you can ina block scope.
2. Is this an Intel bug, since Visual Studio doesn't have a problem with this pragma inside a namespace?
Looks like this is an Intel bug, as the warning coming out is appropriate for C (no namespace), but not for C++.
I'll file a tracker on this with the developers.
3. Can the optimizer be trusted to honor the float_control(precise) request if a function gets inlined?
I'll get back to you on this one after some investigation, thanks.
-regards,
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Kittur Ganesh (Intel)
Hi Stephan,
To your questions:
1. Are namespaces no block scopes?
Namespaces are not block scopes as you cannot put a statement in a namespace that you can ina block scope.
2. Is this an Intel bug, since Visual Studio doesn't have a problem with this pragma inside a namespace?
Looks like this is an Intel bug, as the warning coming out is appropriate for C (no namespace), but not for C++.
I'll file a tracker on this with the developers.
3. Can the optimizer be trusted to honor the float_control(precise) request if a function gets inlined?
I'll get back to you on this one after some investigation, thanks.
-regards,
Kittur
Hi Stephan,
I did verify with our key developers on the last question. The answer is yes. You can trust the optimizer to honor the float_control(precise) request if the function gets inlined.Hope that helps.
-regards,
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kittur, thanks a lot for answering all my questions!
Stephan
Stephan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - stephan_
Kittur, thanks a lot for answering all my questions!
Stephan
Stephan
Pleasure Stephan. I'll also upate you as soon as a fix is in for that warning message/C++, appreciate much.
-regards,
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kittur, you are probably aware of this, but maybe not every reader: It's not just a spurious warning, the compiler actually won't honor the float_control(precise) request if it is in a namespace scope. One might argue that this warning message should better be an error message, in particular because the miscompiled code can be hard to detect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - stephan_
Kittur, you are probably aware of this, but maybe not every reader: It's not just a spurious warning, the compiler actually won't honor the float_control(precise) request if it is in a namespace scope. One might argue that this warning message should better be an error message, in particular because the miscompiled code can be hard to detect.
Yes I agree Stephan, thanks. Appreciate the clarification, so readers can now understand that it's just not the warning that needs to be fixed.
-regards,
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kittur Ganesh (Intel) wrote:I'm using Composer XE 2013 and I still have this issue. The main problem is that this code is located in a 3rd party library, thus I can't really change it. Is it safe to ignore this warning ?
Quoting - Kittur Ganesh (Intel)2. Is this an Intel bug, since Visual Studio doesn't have a problem with this pragma inside a namespace?
Looks like this is an Intel bug, as the warning coming out is appropriate for C (no namespace), but not for C++.
I'll file a tracker on this with the developers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>...3.Can the optimizer be trusted to honor the float_control(precise) request if a function gets inlined?
I'd like to make a comment related to a change of a Floating Point Model.
The #pragma directive 'float_control(...)' controls the Floating Point Model at a compile time and it affects calculations at run-time. My question is: Wouldn't be better to control the Floating Point Model at run-time only using a set of CRT-functions, like _control87 or _controlfp?
>>...Is it safe to ignore this warning?
You need to verify results of your calculations for all cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The original post referred to use of #pragma float_control to turn on and off observance of language rules on associativity at compile time. This choice could not be made at run time unless both versions of the code were present.
Besides, changing x87 run-time settings doesn't solve many problems in the present day when most applications are built with SSE instructions.
In my experience, the only reason for returning to the default non-enforcement of associativity is to gain the reduction optimizations, which can also be done in the majority of cases by #pragma simd reduction().
I recognize that from time to time there is a desire to have the compiler ignore parentheses and perform algebraic simplification to speed up execution. The compiler tends not to do this consistently; to me it is also a problem that it is inconsistent with the Microsoft and gnu compilers. In the gnu compilers, there are separate options for associative math and observance of parentheses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>...Intel C++ compiler doesn't honor a #pragma float_control(precise, on) request when it's not in the global namespace...
MSDN doesn't say anything about namespaces but says that 'float_control' pragma 'Specifies floating-point behavior for a function'
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page