0
votes

Does anybody know the state of half precision floating point support in OpenCL as implemented by Apple.

According to OpenCL 1.1 spec The following statement should enable half2:

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

but when I come to build the kernel the compiler throws a message such as

error: variable has incomplete type 'half4' (aka 'struct __Reserved_Name__Do_

The following thread ask a similar question : OpenCL half4 type Apple OS X But this thread is old. Can anyone please tell me if the half precision is supported by apple recently?

2

2 Answers

0
votes

When you want to know if a extension is supported by a specific implementation (regardless if it's Apple's or another), just use the function

cl_int clGetPlatformInfo(cl_platform_id platform, 
                         cl_platform_info param_name,
                         size_t param_value_size,
                         void *param_value,
                         size_t *param_value_size_ret)

passing the value CL_PLATFORM_EXTENSIONS for the param_name argument.
it'll return a space-separated list of extension names.
Note that this list must returns the extensions "supported by all devices associated with this platform".

So it means that even if the platform supports the cl_khr_fp16 extension but not your device, it won't appear in the list. To know the extension available on your device use

clGetDeviceInfo(...)

with the value CL_DEVICE_EXTENSIONS for the param_name argument.

0
votes

For a generic answer to OpenCL extension querying see CaptainObvious' answer above (https://stackoverflow.com/a/17425167/5394228).

I asked Apple Developer Support about this and they say that half support is available in Metal and there are no plans to add new functionality to OpenCL now. (they answered Nov 2017)