<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On 5 Dec 2016 9:42 am, "Anastasia Stulova via Phabricator via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Anastasia added a comment.<br>
<div class="quoted-text"><br>
In <a href="https://reviews.llvm.org/D27334#612858" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D27334#612858</a>, @bader wrote:<br>
<br>
> In <a href="https://reviews.llvm.org/D27334#611703" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D27334#611703</a>, @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</div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">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?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">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.<br></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Do you have a real example? If someone passes an integer to 'sin', I think there's a better warning we can give them :)</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">
>  The goal of this warning is to let OpenCL developer know about potential issues with code portability.<br>
<br>
<br>
</div>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.<br>
<div class="elided-text"><br>
<br>
<a href="https://reviews.llvm.org/D27334" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D27334</a><br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</div></blockquote></div><br></div></div></div>