我刚从OpenCL 1.0升级到1.1.当我调用min()函数时,我得到错误输出:
<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);
Run Code Online (Sandbox Code Playgroud)
对于具有不同类型的更多行,错误输出将继续.
当我试图隔离问题时,get_global_id(2)似乎是问题所在.我认为将get_global_id(2)从一个uint(我相信它返回一个uint)转换为int会解决问题,但事实并非如此.有人知道发生了什么吗?我看了1.0和1.1规格,我仍然感到困惑,为什么会发生这种情况.
OpenCL 1.0和1.1规范定义min具有以下功能签名:
gentype min (gentype x, gentype y)
gentype min (gentype x, sgentype y)
Run Code Online (Sandbox Code Playgroud)
因此,参数类型必须相同,或者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 )
Run Code Online (Sandbox Code Playgroud)
另请注意,get_global_id的返回类型是size_t,其大小可以是32位或64位.
您必须转换表达式结果以选择min的特定重载.
有许多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)
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6135 次 |
| 最近记录: |