intel / beignet

Beignet is an open source implementation of the OpenCL specification - a generic compute oriented API. Here is Beignet Source Code Mirror in github- This is a publish-only repository and all pull requests are ignored. Please follow https://wiki.freedesktop.org/www/Software/Beignet/ for any of your improvements
GNU Lesser General Public License v2.1
95 stars 40 forks source link

Call to `min` is ambiguous (compiler error) #1

Closed dcousens closed 7 years ago

dcousens commented 7 years ago

Problematic kernel code

min((size_t) 1, (unsigned long)2);

CL_PROGRAM_BUILD_LOG

stringInput.cl:168:30: error: call to 'min' is ambiguous
/usr/lib/beignet/include/ocl_integer.h:207:1: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:202:19: note: expanded from macro 'DECL_MIN_MAX_CLAMP'
/usr/lib/beignet/include/ocl_integer.h:211:1: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:202:19: note: expanded from macro 'DECL_MIN_MAX_CLAMP'
/usr/lib/beignet/include/ocl_integer.h:855:21: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:856:21: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:857:21: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:858:21: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:859:22: note: candidate function
/usr/lib/beignet/include/ocl_common.h:28:20: note: candidate function
/usr/lib/beignet/include/ocl_common.h:41:19: note: candidate function
/usr/lib/beignet/include/ocl_common.h:132:21: note: candidate function
... <snip>
/usr/lib/beignet/include/ocl_integer.h:852:20: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:853:20: note: candidate function
/usr/lib/beignet/include/ocl_integer.h:854:21: note: candidate function
stringInput.cl:270:23: warning: incompatible pointer types passing 'const uint32_t *' (aka 'const unsigned int *') to parameter of type 'const uint8_t *' (aka 'const unsigned char *')
stringInput.cl:161:68: note: passing argument to parameter 'message' here

Even if error: call to 'min' is ambiguous is fair warning, that is a ridiculous error message.

The error is isolated to beignet, does not happen on the intel-opencl-runtime or Cuda OpenCL implementations.

dcousens commented 7 years ago

Disregard, this is a mirror repository. Sigh.

champson commented 7 years ago

Hi, min((size_t) 1, (unsigned long)2); This suppose the size_t is 64bits, it is not correct. Beignet's size_t is 32bits by default, so the code is same as: min((uint) 1, (unsigned long)2); Of course, it is ambiguous.

intel-opencl-runtime and Cuda OpenCL don't have error, because the size_t is 64bits.

Similar, if you use:
min((size_t) 1, (uint)2);
It will pass on beignet but fail on intel-opencl-runtime and Cuda OpenCL.
dcousens commented 7 years ago

Thanks for the response @champson, for some reason I thought size_t would be specific to the hardware.