Implementing Opencl kernel using clmagma arrays

Hello everyone!
i’m begginer with Opencl using clMagma library, my problem look some like this little example:

int row = 3, col = 3;
double *A_h, *B_h;
cl_mem A_k, B_k;
magma_malloc(&A_k, row*col*sizeof(double));
magma_malloc(&B_k, row*col*sizeof(double));
magma_malloc_cpu((void**) &A_h, row*col*sizeof(double));
magma_malloc_cpu((void**) &B_h, row*col*sizeof(double));
for(int z = 0; z < row*col; z++) A_h[z] = z+1;
for(int z = 0; z < row*col; z++) printf("%f ",A_h[z]); printf("

magma_dsetmatrix(row, col, A_h, row, A_k, size, row, queue);
magma_dgemm(MagmaNoTrans, MagmaTrans, row, row, col, alpha, A_k, size, row, A_k, size, row, beta, B_k, size, row, queue);
magma_dgetmatrix(row,col, B_k, size, row, B_h, row, queue);

for(int z = 0; z < row*col; z++) printf("%f ",B_h[z]); printf("

cl_kernel k_prueba;
k_prueba = clCreateKernel(program, "prueba", &status);
status = clSetKernelArg(k_prueba, 0, sizeof(cl_mem), &A_k);
exitOnFail(status, "Unable to set kernel prueba arguments.");//fail error -38

size_t global_prueba = row*col;
status = clEnqueueNDRangeKernel(command_queue, k_prueba, 1, NULL, &global_prueba, NULL, 0, NULL, NULL);
exitOnFail(status, "Launch OpenCL prueba kernel");

magma_dgetmatrix(row, col, A_k, size, row, A_h, row, queue);
for(int z = 0; z < row*col; z++) printf("%f ",A_h[z]); printf("

As you can see what i’m trying to achieve is: i have some arrays, that are allocated using magma_malloc, do some work whit then like magma_dgemm, and then use that array inside a normal OpenCl Kernel, but it seems that cant be use like because i get error -38 (CL_INVALID_MEM_OBJECT)

So my question is how can i do some work using both Clmagma and Opencl kernel?

i have tried alredy other options but didnt fully work.
[li] clEnqueueCopyBuffer. i’m guessing that magma pointer is not a buffer?
[/li][li] clCreateBuffer, declaring arrays whit clCreateBuffer don’t work in magma_dgemm

Any help will be much apreciated, thx for your time reading this and sorry if there is any misspelling error.
Best regards, Miguel