In OpenCL 1.1, my min () function call is ambiguous, and I cannot understand why

I just upgraded from OpenCL 1.0 to 1.1. When I call the min () function, I get an error:

    <program source>:45:44: error: call to 'min' is ambiguous
            int nFramesThisKernelIngests = min(nFramesToIngest  - nAvg*nPP*get_global_id(2), nAvg*nPP);

<built-in>:3569:27: note: candidate function
double16 __OVERLOADABLE__ min(double16, double16);                                               
                           ^
<built-in>:3568:26: note: candidate function
double8 __OVERLOADABLE__ min(double8, double8);   

The error output continues for more lines with different types.

When I tried to isolate the problem, the get_global_id (2) problem is the problem. I thought casting get_global_id (2) into an int from uint (I believe that it will return uint) will solve the problem, but it is not. Does anyone know what is going on? I looked at the specifications 1.0 and 1.1, and I'm still confused why this is happening.

+3
source share
2 answers

The OpenCL 1.0 and 1.1 specifications define min for the following function signatures:

gentype min (gentype x, gentype y) 
gentype min (gentype x, sgentype y)

, 1 , , .

int4 a,b;
int c; 
min(a,b); // All arguments have the same type
min(a,c); // 2nd element may be scalar, matching the 
          // element type of the 1st argument ( a vector type )

, get_global_id size_t, 32 64 .

, .

min ( ), .

min(float  a, float  b);
min(float2 a, float2 b);
min(float2 a, float  b);
min(float3 a, float3 b);
min(float3 a, float  b);
min(float4 a, float4 b);
... // and vector sizes 4,8,16
min(double a, double b); // With an OpenCL 64bit floating point extension enabled
min(double2 a, double b); // With an OpenCL 64bit floating point extension enabled
... // and integral scalar and vector types (char, schar, short, ushort, int, etc)

...
+6

OpenCL, , , min double8 double16. , , , min - , . fmin.

EDIT: ?

<built-in>:xxxx:yy: note: candidate function
int __OVERLOADABLE__ min(int, int);

JAB : int:

int nFramesThisKernelIngests = (int) min(
    (int) (nFramesToIngest - nAvg * nPP * get_global_id(2)),
    (int) (nAvg * nPP));

, (, , , , YMMV).

+1

Source: https://habr.com/ru/post/1768447/


All Articles