[cfe-dev] [OpenCL patch] Half type as native when OpenCL's cl_khr_fp16 extension is enabled
Anton.Lokhmotov at arm.com
Tue Jul 24 03:03:43 PDT 2012
> It looks like we have four possibilities. Is this right?
> 1. half is completely unsupported (C, C++ default)
> 2. half is storage-only, support half* but no operations on half
> (OpenCL without cl_khr_fp16)
> 3. half is storage-only, operations on half automatically promoted to
> float (__fp16 NEON)
> 4. half is completely supported (OpenCL with cl_khr_fp16)
> HalfTypeNative (or PromoteHalfToFloat) would differentiate between the
> last two cases in CodeGen; the first two cases are irrelevant in
> CodeGen because in those cases it should be impossible to pass a half
> type to EmitScalarConversion.
We found a problem with our solution addressing your previous comment .
One of the OpenCL conformance tests attempts to do something like this:
__global half * buffer;
/* float data = */ 1.0f,
/* size_t offset = */ 0,
/* __global half *p = */ &buffer[index]
Disallowing 'buffer[index]' as in  results in:
error: dereferencing half pointer ('half *') is not allowed.
While the conformance tests are not sacred, it can be argued that the
composition of '&' and '' should result in half*, so should not be
rejected. Unfortunately, we found no obvious way to implement this in
Clang, so leave this case as TODO.
Please review the updated patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 18452 bytes
Desc: not available
More information about the cfe-dev