Added warning about potential ambiguity error with built-in overloading.
Patch by Alexey Bader
Differential D27334
[OpenCL] Ambiguous function call. echuraev on Dec 2 2016, 12:54 AM. Authored by
Details
Added warning about potential ambiguity error with built-in overloading. Patch by Alexey Bader
Diff Detail Event TimelineComment Actions 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?
Comment Actions Motivation: // Non-portable OpenCL 1.2 code __kernel void foo(global float* out) { out[get_global_id(0)] = sin(get_global_id(0)); } This program compiles fine on OpenCL platform w/o doubles support and fails otherwise. This might be not so serious issue for C, since C doesn't support function overloading, whereas OpenCL built-in functions library must overload most of the functions. Comment Actions 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. Comment Actions As much as any other warning it's not always means that there is an error in the code. It just means that developer should inspect the construction triggering a warning. Comment Actions I agree warnings don't always signal a definite issue (even thought it's good to make them as precise as we can). We could try to reword the diagnostic message. However, the biggest issue I have here is that the message can be given in the situations that are unrelated to the problem (i.e. the overload candidates that don't have anything to do with the parameter being diagnosed or don't overload with the double precision). Therefore, it feels like the diagnostic can be confusing in some cases even though they are not very probable ones. Comment Actions @Anastasia, do you have any suggestions how is it better to reword the diagnostic message? Yes, this message can be given in some situations that are unrelated to the problem but in this case it will be a notification for developer that this function call can be potential ambiguous.
Comment Actions I don't actually. But remembering the follow up discussion: Comment Actions Yes, I remember this discussion. But we saw this problem in the real OpenCL code and this warning is able to help developer to understand where his code could be ambiguous. Actually, I don't know the modifying overloading resolution is a better way to go or not. Do you have any suggestions how could we notify developer about this potential problem in better way? Comment Actions So, I think that we have to do some decision about this patch. @Anastasia, What do you think about it? Please see my comment above. What should we do with this patch? Comment Actions I am still not convinced adding the diagnostics in this shape is a good way to go.... |
How does it check that this is a built-in function?