Thank you so much for the help. I tried to make this work, but I’m not setting it up right.
Here is how I setup the relevant parts of my kernel:
cl_mem memObjects[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
memObjects[3] = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, NUM_ATOMS*sizeof(float), atom_X, NULL);
errNum |= clSetKernelArg(CheckKernel, 3, sizeof(cl_mem), &memObjects[3]);
for(i=0;i<40,000;i++){
errNum = clEnqueueNDRangeKernel(commandQueue, CheckKernel, 1, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL);
clFinish(commandQueue);
errNum = clEnqueueReadBuffer(commandQueue, memObjects[7], CL_TRUE, 0, NUM_RAYS*sizeof(float), distances, 0, NULL, NULL);
//use results to move atom_X
float* X;
X = (float*)clEnqueueMapBuffer(commandQueue, memObjects[3], CL_TRUE, CL_MAP_WRITE, 0, NUM_ATOMS*sizeof(float), 0, NULL, NULL, &errNum);
for(j=0;j<NUM_ATOMS;j++){
atom_X[j] = atom_X[j] + 2;//2 is just to test
}
errNum = clEnqueueUnmapMemObject(commandQueue,memObjects[3],(void *)X,0,NULL,&errNum);
//rerun kernel with new position
}
Is this the correct direction to go? Also, I’m getting this error:
error: cannot convert ‘cl_int*’ to ‘_cl_event**’ for argument ‘6’ to ‘cl_int clEnqueueUnmapMemObject(_cl_command_queue*, _cl_mem*, void*, cl_uint, _cl_event* const*, _cl_event**)’
Thanks again