I have a buffer that I'm passing to an OpenCL kernel via cl_mem object that I want to interpret as different types depending on the region eg
kernel void do_something(global void * data) {
global double * offset_ptr = data + 20;
global uint * offset2_ptr = data + 40;
offset_ptr[5] = 4.0;
offset2_ptr[2] = 5;
}
My problem is with lines 2 and 3; I get this message from the compiler:
Bitcasts between pointers of different address spaces is not legal.Use AddrSpaceCast instead.
%26 = bitcast i8 addrspace(1)* %19 to i8*
or something similar. I can fix this with
... = (global) data + 20;
but I feel like this is papering over the problem and I'm misunderstanding something fundamental about address spaces. When I introduce another error into the program these same lines then give me this:
warning: incompatible integer to pointer conversion initializing '__global double *__attribute__((address_space(16776963)))' with an expression of type 'unsigned int'
What should I be doing here?