Skip to content

Instantly share code, notes, and snippets.

@papercompute
Created May 13, 2015 15:11
Show Gist options
  • Select an option

  • Save papercompute/082c8406c4e624af4006 to your computer and use it in GitHub Desktop.

Select an option

Save papercompute/082c8406c4e624af4006 to your computer and use it in GitHub Desktop.
OpenCL Host level synchronization
for(int i=0;i<numIter-1;i++){ // numIter = 1000
status = clEnqueueNDRangeKernel(commandQueue,kernel1,2,NULL,globalThreads,localThreads,0,NULL,NULL);
ASSERT_CL(status);
status = clEnqueueNDRangeKernel(commandQueue,kernel2,2,NULL,globalThreads,localThreads,0,NULL,NULL);
ASSERT_CL(status);
if(i>0 && i%256==0){ // just
status = clFlush(commandQueue);
ASSERT_CL(status);
} // if
} // for i
// last iteration
status = clEnqueueNDRangeKernel(commandQueue,kernel1,2,NULL,globalThreads,localThreads,0,NULL,NULL);
ASSERT_CL(status);
status = clEnqueueNDRangeKernel(commandQueue,kernel2,2,NULL,globalThreads,localThreads,0,NULL,&ndrEvt);
ASSERT_CL(status);
status = clFlush(commandQueue);
ASSERT_CL(status);
// wait
spinForEventsComplete( 1, &ndrEvt );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment