OpenCL size_t error

编程测试当中遇到这么一个问题:

1,增加kernel时OpenCL编译报错,AMD 平台报错说该source kernel无法生成相应的executable program object;

2,但是同一套代码在intel E3上可以正常运行;

很明显,又是implementation-dependent的问题;

这次问题出在了size_t的实现上,已经实验验证;在这里(LINK)有简单的描述,自己编程当中使用size_t没有遵守OpenCL-restriction,

毕竟对于这种平台相关的类型,coder最好遵循手册要求。。。。

Arguments to __kernel functions in a program cannot be declared with the built-in scalar types bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t. The size in bytes of these types except half are implementation-defined and in addition can also be different for the OpenCL device and the host processor making it difficult to allocate buffer objects to be passed as arguments to a kernel declared as pointer to these types. half is not supported as half can be used as a storage format only and is not a data type on which floating-point arithmetic can be performed.

做个记忆:

size_t can be a 32-bit or a 64-bit unsigned integer, and the OpenCL compiler does not accept variable types that are implementation-dependent.

原文地址:https://www.cnblogs.com/superniaoren/p/4733974.html