This is what I have so far.
//Global on host
cl_mem centerBuf;
cl_float3 center;
//create buffer
centerBuf = clCreateBuffer(context,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
sizeof(cl_float3),
¢er, &error);
//set buffer as kernel arg
error = clSetKernelArg(kernel, 3, sizeof(centerBuf), ¢erBuf);
////update center vector
move code
//get pointer to buffer
cl_float3 *CENTERptr = (cl_float3 *)clEnqueueMapBuffer(queue,
centerBuf,
CL_TRUE,
CL_MAP_READ,
0,
sizeof(cl_float3),
0, NULL, NULL, NULL);
//copy center from host to global memory on gpu (I assume thats what this does)
memcpy(CENTERptr, ¢er, sizeof(cl_float3));
//inside the kerenel
__kernel void __main(..., __global float3* center,...) {
//store centers x y and z inside the debug buffer
debugBuf[id] = (float4)(center[0].x,center[0].y,center[0].z,id);
}
This doesn't work.
Am i using memcpy wrong? Am i accessing the buffer inside the kernel wrong?
Any tips would be great.
Thanks