<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks Scott. I’m fixing my patches a little and I’m going to upload it for review and hopefully will get some more information from the community in that format.
I agree it would be cool to have more sophisticated levels for optimizations, but I don’t have a patch that implements those, so I’m planning to submit the patch with option levels as described.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Scott Manley [mailto:rscottmanley@gmail.com]
<br>
<b>Sent:</b> Wednesday, May 29, 2019 3:16 PM<br>
<b>To:</b> Blower, Melanie <melanie.blower@intel.com><br>
<b>Cc:</b> cfe-dev@lists.llvm.org; llvm-dev@lists.llvm.org; scottm <scottm@cray.com><br>
<b>Subject:</b> Re: [llvm-dev] [RFC] Add support for options -fp-model= and -fp-speculation= : specify floating point behavior<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">+1 from Cray. <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If we are talking about "having a single option to control most basic FP options" in general, I'd also like to see a finer granularity for -fp-model=fast, like Intel's own fast=[1|2]. Perhaps they just become their own options? I don't
have a full list of proposed optimizations (and/or other existing flags) that would be tied for each of the finer grained levels, but at a high level, for example:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><br>
- precise (as described)<o:p></o:p></p>
<div>
<p class="MsoNormal"> - strict (as described)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - optimize (something between precise and fast)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - fast (as described)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - aggressive (even more aggressive FP optimization than fast)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - except/except- (as described)<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This would maintain reasonable command line compatibility but also allow for easier tuning (and debugging) of codes that are numerically sensitive at a global user level.<o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, May 29, 2019 at 10:37 AM Blower, Melanie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
Intel would like to contribute a patch to implement support for these Intel- and Microsoft -fp options. This message is to describe the options and request feedback from the community.<br>
-fp-model=[precise|strict|fast|except[-]] and<br>
-fp-speculation=[fast|strict|safe]<br>
<br>
This contribution would dovetail with the llvm patch "Teach the IRBuilder about constrained fadd and friends" which is under review here,
<a href="https://reviews.llvm.org/D53157/new/" target="_blank">https://reviews.llvm.org/D53157/new/</a>. I have a patch ready to review that works with D53157. The motivation for providing these is that having a single option to control most basic FP options
is better and easier to understand for users.<br>
<br>
The option settings -fp-model=[precise|strict|fast|except] are supported by both ICC and CL. The fp-speculation option is supported only by ICC. The CL and ICC -fp-model option is documented on these pages:
<br>
<a href="https://docs.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=vs-2019" target="_blank">
https://docs.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=vs-2019</a><br>
<a href="https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-fp-model-fp" target="_blank">
https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-fp-model-fp</a><br>
<br>
Currently, clang's default behavior corresponds to -fp-model=precise. Clang/llvm support for -fp-model=[strict|except] is being developed in the D53157 patch, and there is current llvm support for the fast settings by using the fast math flags llvm::FastMathFlags.
Note: the clang-cl wrapper to support Microsoft options has simplified support for these options by mapping /fp-model=except to ftrapping-math, fp-mdel=fast to ffast-math, fp-model=precise and fp-model=strict to fno-fast-math (see clang/Driver/CLCompatOptions.td).<br>
<br>
According to the online options documentation, you can combine except[-] with [precise|strict|fast], but combining both fast and except is not a valid setting (the Driver will emit an error).
<br>
precise - Disables optimizations that are not value-safe on floating-point data, although FP contraction is enabled.<br>
strict - Enables precise and except, disables contractions (FMA), and enables pragma stdc fenv_access. <br>
fast - Equivalent to -ffast-math<br>
except/except- - Determines whether strict floating-point exception semantics are honored.<br>
<br>
The ICC option -fp-speculation is described here,<br>
<a href="https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-fp-speculation-qfp-speculation" target="_blank">
https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-fp-speculation-qfp-speculation</a><br>
These are the meanings of the fp-speculation settings:<br>
fast - Tells the compiler to speculate on floating-point operations. This is equivalent to "fpexcept.ignore" in the constrained intrinsics review D53157.<br>
strict - Tells the compiler to disable speculation on floating-point operations. This is equivalent to "fpexcept.strict" in the constrained intrinsics review D53157.<br>
safe - Tells the compiler to disable speculation if there is a possibility that the speculation may cause a floating-point exception. This is equivalent to "fpexcept.maytrap" in the constrained intrinsics review D53157.<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>