static void bufferWritter(FILE *outFile) { int n; n = omp_get_max_threads(); #pragma omp flush(producing) while (producing) { writeBuffers(outFile, n); #pragma omp flush(producing) } writeBuffers(outFile, n); }
//Run the CL kernel //Handles buffer IO void runCLKernelsWithIO(void) { size_t globalThreads[1]; size_t localThreads[1]; localThreads[0]= threadsPerWorkgroup; //Break up kernel execution to 1 exec per WORK_ITEM_LIMIT work items. cl_uint remainingWidth = paddedWidth; cl_uint offset = 0; cl_event exec_events[1];//An event that tracks kernel execution while(remainingWidth > WORK_ITEM_LIMIT) { writeBuffers(offset,WORK_ITEM_LIMIT); //Enqueue a kernel run call. globalThreads[0] = WORK_ITEM_LIMIT; status = clEnqueueNDRangeKernel( commandQueue, kernel, 1, NULL, globalThreads, localThreads, 0, NULL, &exec_events[0]); if(status != CL_SUCCESS) exitOnError("Enqueueing kernel onto command queue.(clEnqueueNDRangeKernel)"); status = clWaitForEvents(1,&exec_events[0]); if(status != CL_SUCCESS) exitOnError("Waiting for kernel run to finish.(clWaitForEvents)"); readBuffers(offset,WORK_ITEM_LIMIT); remainingWidth -= WORK_ITEM_LIMIT; offset += WORK_ITEM_LIMIT; } //Final kernel run call for remaining work_items globalThreads[0] = remainingWidth; writeBuffers(offset,remainingWidth); status = clEnqueueNDRangeKernel( commandQueue, kernel, 1, NULL, globalThreads, localThreads, 0, NULL, &exec_events[0]); if(status != CL_SUCCESS) exitOnError("Enqueueing kernel onto command queue.(clEnqueueNDRangeKernel)"); status = clWaitForEvents(1,&exec_events[0]); if(status != CL_SUCCESS) exitOnError("Waiting for kernel run to finish.(clWaitForEvents)"); readBuffers(offset,remainingWidth); status = clReleaseEvent(exec_events[0]); if(status != CL_SUCCESS) exitOnError("Releasing event object exec_events[0].(clWaitForEvents)"); }
void Integrator::saveCheckpoint() { writeBuffers("_checkpoint", true); }
void Integrator::saveOutputs() { writeBuffers("", _scene->rendererSettings().overwriteOutputFiles()); }