I am following along with Heterogeneous Computing with OpenCL and it is leaving me hanging.
They pass an image, as an array of floats, to enqueueWriteBuffer. I think the image, in this case, has no values for color. It is simply {col,row,col,row,col,row} e.g. {0,0,0,1,0,2,1,0,1,1,1,2...}.
but when they do enqueueReadBuffer the size they expect is HW and if you are going to do an array like I just did the array size would be HW*2.
// SETUP BUFFERS
Buffer d_ip = Buffer(context, CL_MEM_READ_ONLY, W*H*sizeof(float));
Buffer d_op = Buffer(context, CL_MEM_WRITE_ONLY, W*H*sizeof(float));
queue.enqueueWriteBuffer(d_ip, CL_TRUE, 0, W*H*sizeof(float), img); //img, what is img? the book just says it is my image.
// SETUP RANGES
NDRange globalws(W, H);
NDRange localws(16, 16);
// QUEUE AND READ
queue.enqueueNDRangeKernel(rotn_kernel, NullRange, globalws, localws);
queue.enqueueReadBuffer(d_op, CL_TRUE, 0, W*H*sizeof(float), img);
// X AND Y INSIDE THE KERNEL
const int x = get_global_id(0);
const int y = get_global_id(1);
If all of the new pixel coordinates are calculated in the kernel couldn't you just pass an empty float array of the appropriate size (WH apparently although I don't see how it isn't WH*2). But then I tried hard coding this (on a 500x300 image) and it blew up my stack.