Repository: opencv
Issue: ocl compile error on imgproc/remap
Labels: bug,category: imgproc,category: ocl

### System Information

OpenCV version: 4.x
Operating System / Platform: Windows 10.0.19041.0
Compiler & compiler version: Visual Studio 16 2019, MSVC 19.29
GPU: NVIDIA GeForce GTX 950

### Detailed description

When call ocl remap, the compile of kernel will fails with messages:

```
[       OK ] OCL_ImgprocWarp/RemapRelative.Mat/369 (3 ms)
[ RUN      ] OCL_ImgprocWarp/RemapRelative.Mat/370, where GetParam() = (CV_64F, Channels(1), INTER_LINEAR, BORDER_CONSTANT, false)
OpenCL program build log: imgproc/remap
Status -11: CL_BUILD_PROGRAM_FAILURE
-D INTER_LINEAR -D BORDER_CONSTANT -D T=double -D ROWS_PER_WI=1 -D WARP_RELATIVE=0 -D WT=double -D CONVERT_TO_T=noconvert -D CONVERT_TO_WT=noconvert -D CONVERT_TO_WT2=convert_double2 -D WT2=double2 -D T=double -D T1=double -D CN=1 -D ST=double -D SRC_DEPTH=6
<kernel>:371:8: error: call to 'fma' is ambiguous
xsum = fma(CONVERT_TO_WT(loadpix(srcptr + mad24(xp, TSIZE, src_index))), coeffs_x[xp], xsum);
       ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^
<kernel>:378:8: error: call to 'fma' is ambiguous
xsum = fma(sx + xp >= 0 && sx + xp < src_cols ?
       ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^
<kernel>:381:7: error: call to 'fma' is ambiguous
sum = fma(xsum, coeffs_y[yp], sum);
      ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^
<kernel>:384:7: error: call to 'fma' is ambiguous
sum = fma(scalar, coeffs_y[yp], sum);
      ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^

OpenCL program build log: imgproc/remap
Status -11: CL_BUILD_PROGRAM_FAILURE
-D INTER_LINEAR -D BORDER_CONSTANT -D T=double -D ROWS_PER_WI=1 -D WARP_RELATIVE=1 -D WT=double -D CONVERT_TO_T=noconvert -D CONVERT_TO_WT=noconvert -D CONVERT_TO_WT2=convert_double2 -D WT2=double2 -D T=double -D T1=double -D CN=1 -D ST=double -D SRC_DEPTH=6
<kernel>:371:8: error: call to 'fma' is ambiguous
xsum = fma(CONVERT_TO_WT(loadpix(srcptr + mad24(xp, TSIZE, src_index))), coeffs_x[xp], xsum);
       ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^
<kernel>:378:8: error: call to 'fma' is ambiguous
xsum = fma(sx + xp >= 0 && sx + xp < src_cols ?
       ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^
<kernel>:381:7: error: call to 'fma' is ambiguous
sum = fma(xsum, coeffs_y[yp], sum);
      ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          ^
<kernel>:384:7: error: call to 'fma' is ambiguous
sum = fma(scalar, coeffs_y[yp], sum);
      ^~~
cl_kernel.h:3873:24: note: candidate function
float __OVERLOADABLE__ fma(float, float, float);
                       ^
cl_kernel.h:3874:25: note: candidate function
double __OVERLOADABLE__ fma(double, double, double);
                        ^
cl_kernel.h:3876:25: note: candidate function
float2 __OVERLOADABLE__ fma(float2, float2, float2);
                        ^
cl_kernel.h:3878:25: note: candidate function
float3 __OVERLOADABLE__ fma(float3, float3, float3);
                        ^
cl_kernel.h:3880:25: note: candidate function
float4 __OVERLOADABLE__ fma(float4, float4, float4);
                        ^
cl_kernel.h:3881:25: note: candidate function
float8 __OVERLOADABLE__ fma(float8, float8, float8);
                        ^
cl_kernel.h:3882:26: note: candidate function
float16 __OVERLOADABLE__ fma(float16, float16, float16);
                         ^
cl_kernel.h:3884:26: note: candidate function
double2 __OVERLOADABLE__ fma(double2, double2, double2);
                         ^
cl_kernel.h:3886:26: note: candidate function
double3 __OVERLOADABLE__ fma(double3, double3, double3);
                         ^
cl_kernel.h:3888:26: note: candidate function
double4 __OVERLOADABLE__ fma(double4, double4, double4);
                         ^
cl_kernel.h:3889:26: note: candidate function
double8 __OVERLOADABLE__ fma(double8, double8, double8);
                         ^
cl_kernel.h:3890:27: note: candidate function
double16 __OVERLOADABLE__ fma(double16, double16, double16);
                          
```

### Steps to reproduce

Just compile the branch `4.x`, and run `opencv_test_imgproc`, pay attention to test `OCL_ImgprocWarp/RemapRelative.Mat`.

The line number (371:8) is wrong (I don't know why). Search `fma(CONVERT_TO_WT(loadpix(srcptr + mad24(xp, TSIZE, src_index))), coeffs_x[xp], xsum);` in `remap.cl`, you will find it around line 467.

Reason: `WT` is `double`, `coeffs_x` is `float`, `xsum` is `double`, so ocl runtime complains about no matched function.

If ocl failed, OpenCV will use CPU version, so the test just gives a `OK`. May be we need a switch, and should disable the `ocl -> cpu` fallback when do test.

P.S. I don't try to find all such errors.

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [x] There is reproducer code and related data files (videos, images, onnx, etc)