Altera_Forum
Honored Contributor
8 years agoRead and print data from local memory .
Read and print from local memory .
Please, Do you can tell me if we can read and print the data stored in local memory. My data is defined as __local adress space in the kernel and setKernelArg in host code will be NULL. Also, As I understood, no buffer should be created with function Clcreatebuffer for local memory . So after, that When I try to read and print data in this local memory I have a huge and random number like this 343467048 , 7984984 . My output number should be 0 to 10 as I store it in local memory. But I call printf function to see my output in local buffer and I has 30984984.. So, Should I create buffer for local address space with Clcreatebuffer ? How I can read my output stored in local memory ? Where this huge and random number come ? My code : Kernel is : __global uint *restrict X __local uint * Z) Z[index]=X[index]; Host : input_X_buf = clcreatebuffer(context, cl_mem_read_only, n_per_device * sizeof(cl_uint), NULL, &status); status = clEnqueueWriteBuffer(queue, input_x_buf, CL_TRUE,0, n_per_device * sizeof(cl_uint), input_x, 0, NULL, &write_event); status = clSetKernelArg(kernel, argi++, sizeof(cl_mem), &input_x_buf); status = clSetKernelArg(kernel, argi++, sizeof(cl_mem), null);status = clenqueuereadbuffer(queue, output_Z_buf, cl_false,0, n_per_device * sizeof(cl_uint), output_Z, 1, &kernel_event, &finish_event);
printf(" device %d, index %d output_z: %d ref_output: %u ",i, j, output_z[j], ref_output[i][j]); Thanks in advance for your help.