From: Dirk Lemstra Date: Thu, 6 Apr 2017 10:46:19 +0000 (+0200) Subject: Added retry to OpenCL kernel execution. X-Git-Tag: 7.0.5-5~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21ab795f33f70061dd8a6f9a86dc6699781f1ca9;p=imagemagick Added retry to OpenCL kernel execution. --- diff --git a/MagickCore/opencl.c b/MagickCore/opencl.c index 23c5f15de..13a62a367 100644 --- a/MagickCore/opencl.c +++ b/MagickCore/opencl.c @@ -1630,6 +1630,13 @@ MagickPrivate MagickBooleanType EnqueueOpenCLKernel(cl_command_queue queue, } status=openCL_library->clEnqueueNDRangeKernel(queue,kernel,work_dim,offset, gsize,lsize,event_count,events,&event); + /* This can fail due to memory issues and calling clFinish might help. */ + if ((status != CL_SUCCESS) && (event_count > 0)) + { + openCL_library->clFinish(queue); + status=openCL_library->clEnqueueNDRangeKernel(queue,kernel,work_dim, + offset,gsize,lsize,event_count,events,&event); + } if ((output_info != (CacheInfo *) NULL) && (output_info->opencl->event_count > 0)) events=(cl_event *) RelinquishMagickMemory(events);