cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shingoxlf
Journeyman III

question pointer in OpenCL kernel

Hi, I was trying to use pointer in test_kernel1 as in the code, however, it gives me an error in building the program

 

 

but if i change the cod to test_kernel2 , it works:

 

can anyone tell me why kernel1 doesn't work? It works in CUDA.

 

__kernel void test_kernel1(__global double *data) { int a = get_global_id(0); double *pt; pt = data+a; *pt += a+1; return; } __kernel void test_kernel2(__global double *data) { int a = get_global_id(0); double pt; pt = *(data+a); pt += a+1; *(data+1)=pt; return; }

0 Likes
1 Reply
antzrhere
Adept III

You should be declaring your pointer as __global data type as you cannot asign pointers to different memory spaces. This should work instead (although I haven't tested it):

__kernel void test_kernel(__global double *data) { int a = get_global_id(0); __global double *pt; pt = (__global double*)&data; *pt += a+1; return; }

0 Likes