I just used the reference clang implementation of OpenCL C++ to compile the source at page 13 of the specs:
#include <opencl_def>
#include <opencl_memory>
#include <opencl_vector_load_store>
half bar(half a) { //ok: half built-in type passed by value
half b = a; //ok: copying half data type
b += 10.0; // not allowed: arithmetic operation
// vload should be used or cl_khr_fp16 support enabled
float f = cl::vload_half<1>(0, &b); // ok
return a; //ok: return half built-in type
}
kernel void foo(cl::global_ptr<half> pg) { //ok: a global pointer
// passed from the host
int offset = 1;
half *ptr = pg.get() + offset; //ok: half pointer arithmetic
half b = bar(*ptr); //ok: dereferencing half pointer
if(b < *ptr) { //not allowed: it is only supported if cl_khr_fp16
// extension is enabled
}
}
The specs say that there is a line with half
mutation, which is not valid and thus I was expecting the compilation to fail. Sadly it compiled without any complaint.
Am I understanding something wrong?