<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;}
@font-face
        {font-family:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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:"Book Antiqua",serif;
        font-variant:normal !important;
        color:windowtext;
        text-transform:none;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;
        vertical-align:baseline;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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-IE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>Hi Hubert,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>I only just realised that I left your comment unanswered, things got busy and it fell through a crack.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>Yes, you are absolutely right; when I refer to ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>short float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ I am thinking of it as being a discrete type where ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ can represent all the values that ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>short float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ can, ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ can represent all the values ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ can, and ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>long double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ can represent all the values that ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ can.  But this does not dictate or imply any particular implementation, unlike ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>_Float16</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’.  Indeed, all four types could have an identical implementation and representation, though from the perspective of the type system they are discrete.  The types ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>_Float<i>N</i></span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ are quite different as they are explicit about the representation.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>Having such an additional type would provide a little flexibility on the small end of Floating-Point.  Our target has native FPU support for 32-bit and 16-bit, while 64-bit is using an software library.  Because ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ floating-point arithmetic in C is performed after promotion to ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’, we have chosen to represent both ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ and ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ as IEEE 32-bit, and ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>long double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ as IEEE 64-bit.  And I chose for consistency with the usual arithmetic rules, to introduce a new type ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>short float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ which in my implementation I have bound to IEEE 16-bit, but it could be bound to any representation for some given target.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>But true integration of such a type would need to be formally specified, and how it interacts with overloading, usual arithmetic conversions and other aspects of C and C++ would need to be properly determined before it could be considered in any way a candidate for Standardisation.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>LLVM and CLang already have infrastructure for supporting the ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>half</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ data-type for OpenCL, and though OpenCL has strict definitions for the types ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>half</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’, ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ and ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’, the definition of ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>half</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ works quite well for our purposes, so I chose to bind the syntax ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>short float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ to LLVM and CLang’s implementation of OpenCL’s ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>half</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’.  I didn’t want to reserve the keyword ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>half</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ in C or C++, and ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>__fp16</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ isn’t quite the same thing.  In practice this works quite well, and the code generation is really good.  Of course, there is the inconsistency that ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>short float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ is not promoted to ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ to perform arithmetic which is at variance with how ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>float</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ is handled (though I do promote it to ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>double</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’ for passing as an argument to variadic functions such as ‘</span><span style='font-family:"Courier New";mso-fareast-language:EN-US'>printf</span><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>’).<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>All the best,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>            MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Hubert Tong [mailto:hubert.reinterpretcast@gmail.com] <br><b>Sent:</b> 10 May 2017 22:23<br><b>To:</b> Martin J. O'Riordan <martin.oriordan@movidius.com><br><b>Cc:</b> Hal Finkel <hfinkel@anl.gov>; Sjoerd Meijer <Sjoerd.Meijer@arm.com>; clang developer list <cfe-dev@lists.llvm.org><br><b>Subject:</b> Re: [cfe-dev] [RFC] implementation of _Float16<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><div><div><p class=MsoNormal>On Wed, May 10, 2017 at 9:13 AM, Martin J. O'Riordan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal><span style='font-family:"Book Antiqua",serif'>More controversially we also added a “synonym” for this using ‘short float’ rather than ‘_Float16’ (or OpenCL’s ‘half’), and created a parallel set of the ISO C library functions using ‘s’ to suffix the usual names (e.g. ‘tan’, ‘tanf’, ‘tanl’ plus ‘tans’).</span><o:p></o:p></p></div></div></blockquote></div><p class=MsoNormal style='margin-bottom:12.0pt'>Perhaps a bit of a tangent here with regards to language semantics. I am going to guess that, in general, short float is not necessarily the same format as _Float16. So it follows that if both are present, then _Float16 and short float are types which are not compatible (e.g., for _Generic) with each other. This would be consistent with _Float32 and "plain" float.<o:p></o:p></p></div><div><p class=MsoNormal>-- HT<o:p></o:p></p></div></div></div></body></html>