<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: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:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:2.0cm 42.5pt 2.0cm 3.0cm;}
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="RU" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">On 5 Dec 2016 9:42 am, "Anastasia Stulova via Phabricator via cfe-commits" <</span><a href="mailto:cfe-commits@lists.llvm.org"><span lang="EN-US">cfe-commits@lists.llvm.org</span></a><span lang="EN-US">> wrote:<o:p></o:p></span></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">Anastasia added a comment.<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><br>
In </span><a href="https://reviews.llvm.org/D27334#612858" target="_blank"><span lang="EN-US">https://reviews.llvm.org/D27334#612858</span></a><span lang="EN-US">, @bader wrote:<br>
<br>
> In </span><a href="https://reviews.llvm.org/D27334#611703" target="_blank"><span lang="EN-US">https://reviews.llvm.org/D27334#611703</span></a><span lang="EN-US">, @Anastasia wrote:<br>
><br>
> > This change seems to modify normal C behavior again. Is there any strong motivation for doing this and if yes could it be done generically with C?<br>
><br>
><br>
> Motivation:<br>
><br>
>   // Non-portable OpenCL 1.2 code<br>
>   __kernel void foo(global float* out) {<br>
>     out[get_global_id(0)] = sin(get_global_id(0));<br>
>   }<br>
><br>
><br>
> This program compiles fine on OpenCL platform w/o doubles support<o:p></o:p></span></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Perhaps that is the problem (that there are two modes that do different things)? Could we make the double overload be present but unselectable to diagnose this problem in that mode too?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span lang="EN-US">and fails otherwise.<br>
>  If OpenCL driver supports doubles it provides at least two versions of 'sin' built-in math function and compiler will not be able to choose the right one for 'size_t' argument.<o:p></o:p></span></p>
</div>
</blockquote>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Do you have a real example? If someone passes an integer to 'sin', I think there's a better warning we can give them :)<o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">[AB] As far as I remember the code that I got used some OpenCL math built-in function and passed some integer constant like pow(x, 2).<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><b><i><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">To fix this case is developer can pass ‘float’ literal ‘2.f’ or use ‘pown’ built-in math function which accepts integers as second parameter.<o:p></o:p></span></i></b></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US">>  The goal of this warning is to let OpenCL developer know about potential issues with code portability.<br>
<br>
<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US">I would argue this improves the portability much as it can also be misleading in some situations (because it refers to a potentially hypothetical problem). For example there can be builtin functions that only have a float
 parameter (without a double version of it). This is for example the case with read_image functions that take a float coordinate value between 0 and 1. Unfortunately this warning won't be triggered on read_image functions because there is an overload candidate
 with an int type of the same parameter too. But we can't exclude this situations to appear in the future or from some vendor extensions or even custom OpenCL code.<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><br>
<br>
</span><a href="https://reviews.llvm.org/D27334" target="_blank"><span lang="EN-US">https://reviews.llvm.org/D27334</span></a><span lang="EN-US"><br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
</span><a href="mailto:cfe-commits@lists.llvm.org"><span lang="EN-US">cfe-commits@lists.llvm.org</span></a><span lang="EN-US"><br>
</span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank"><span lang="EN-US">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</span></a><span lang="EN-US"><o:p></o:p></span></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
</div>
<p><br>--------------------------------------------------------------------<br>Joint Stock Company Intel A/O<br>Registered legal address: Krylatsky Hills Business Park, <br>17 Krylatskaya Str., Bldg 4, Moscow 121614, <br>Russian Federation</p><p>This e-mail and any attachments may contain confidential material for<br>the sole use of the intended recipient(s). Any review or distribution<br>by others is strictly prohibited. If you are not the intended<br>recipient, please contact the sender and delete all copies.</p>
</body>
</html>