Sheeep

Data transfer to Kernel

Discussion created by Sheeep on Jan 21, 2010
Latest reply on Jun 3, 2010 by cjang

I have a problem. I want to calculate a Inversion of an mxn Matrix.

So I want to transfer a int** to cl kernel. I tried host code:

    int **a = (int**)malloc(2*sizeof(int*));
    a[0]=(int*)malloc(5*sizeof(int));

    and:
     cl::Buffer    CL1=cl::Buffer(context,CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR,sizeof(int)*2 ,a,&error);

 

In the Kernel I tried to run:

 

__kernel void add(__global const int *a,__global int *c){

          c[0]=a[0][0];

}

but I get an NDKernelRange error.

I also tried __global const int **a with the same error.

How can I transfer a int** or a int[][] to CL Device?

 

Outcomes