1 Reply Latest reply on Oct 16, 2011 3:37 PM by antzrhere

    question pointer in OpenCL kernel

    shingoxlf

      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; }

        • question pointer in OpenCL kernel
          antzrhere

          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[a]; *pt += a+1; return; }