我有一个缓冲区,我通过 cl_mem 对象传递给 OpenCL 内核,我想根据区域将其解释为不同的类型,例如
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;
}
我的问题是第 2 行和第 3 行;我从编译器收到这条消息:
Bitcasts between pointers of different address spaces is not legal.Use AddrSpaceCast instead.
%26 = bitcast i8 addrspace(1)* %19 to i8*
或类似的东西。我可以用
... = (global) data + 20;
但我觉得这是在掩盖问题,我误解了地址空间的一些基本内容。当我在程序中引入另一个错误时,这些相同的行然后给我这个:
warning: incompatible integer to pointer conversion initializing '__global double *__attribute__((address_space(16776963)))' with an expression of type 'unsigned int'
我应该在这里做什么?