filteredImageBuffer = NULL;
addNoiseKernel = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
image_view=AcquireAuthenticCacheView(image,exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (queue!=NULL) RelinquishOpenCLCommandQueue(device, queue);
- if (addNoiseKernel!=NULL) RelinquishOpenCLKernel(addNoiseKernel);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (queue!=NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
+ if (addNoiseKernel!=NULL)
+ RelinquishOpenCLKernel(addNoiseKernel);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
if (outputReady == MagickFalse && filteredImage != NULL)
filteredImage=DestroyImage(filteredImage);
outputReady = MagickFalse;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
image_view=AcquireAuthenticCacheView(image,exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (tempImageBuffer!=NULL) clEnv->library->clReleaseMemObject(tempImageBuffer);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (imageKernelBuffer!=NULL) clEnv->library->clReleaseMemObject(imageKernelBuffer);
- if (blurRowKernel!=NULL) RelinquishOpenCLKernel(blurRowKernel);
- if (blurColumnKernel!=NULL) RelinquishOpenCLKernel(blurColumnKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device, queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (tempImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(tempImageBuffer);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (imageKernelBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageKernelBuffer);
+ if (blurRowKernel!=NULL)
+ RelinquishOpenCLKernel(blurRowKernel);
+ if (blurColumnKernel!=NULL)
+ RelinquishOpenCLKernel(blurColumnKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse && filteredImage != NULL)
filteredImage=DestroyImage(filteredImage);
+
return(filteredImage);
}
imageBuffer = NULL;
compositeImageBuffer = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
/* Create and initialize OpenCL buffers. */
cleanup:
image_view=DestroyCacheView(image_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (compositeImageBuffer!=NULL) clEnv->library->clReleaseMemObject(compositeImageBuffer);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (compositeImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(compositeImageBuffer);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
return(outputReady);
}
filterKernel = NULL;
queue = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
/* Create and initialize OpenCL buffers. */
image_view=AcquireAuthenticCacheView(image,exception);
image_view=DestroyCacheView(image_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (filterKernel!=NULL) RelinquishOpenCLKernel(filterKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (filterKernel!=NULL)
+ RelinquishOpenCLKernel(filterKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
+
return(outputReady);
}
/*
* initialize opencl env
*/
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
/*
clEnv->library->clReleaseMemObject(stretchMapBuffer);
if (stretch_map!=NULL)
stretch_map=(PixelPacket *) RelinquishMagickMemory(stretch_map);
-
-
if (histogramBuffer!=NULL)
clEnv->library->clReleaseMemObject(histogramBuffer);
if (histogram!=NULL)
histogram=(cl_uint4 *) RelinquishMagickMemory(histogram);
-
-
- if (histogramKernel!=NULL)
+ if (histogramKernel!=NULL)
RelinquishOpenCLKernel(histogramKernel);
- if (stretchKernel!=NULL)
+ if (stretchKernel!=NULL)
RelinquishOpenCLKernel(stretchKernel);
-
- if (queue != NULL)
- RelinquishOpenCLCommandQueue(device, queue);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
return(outputReady);
}
filteredImage_view = NULL;
outputReady = MagickFalse;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
image_view=AcquireAuthenticCacheView(image,exception);
inputPixels=GetCacheViewAuthenticPixels(image_view,0,0,image->columns,image->rows,exception);
image_view=DestroyCacheView(image_view);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
-
if (imageBuffer != NULL)
clEnv->library->clReleaseMemObject(imageBuffer);
-
if (filteredImageBuffer != NULL)
clEnv->library->clReleaseMemObject(filteredImageBuffer);
-
if (convolutionKernel != NULL)
clEnv->library->clReleaseMemObject(convolutionKernel);
-
if (clkernel != NULL)
RelinquishOpenCLKernel(clkernel);
-
if (queue != NULL)
- RelinquishOpenCLCommandQueue(device, queue);
-
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse)
{
if (filteredImage != NULL)
queue = NULL;
tempImageBuffer[0] = tempImageBuffer[1] = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
image_view=AcquireAuthenticCacheView(image,exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device, queue);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
for (k = 0; k < 2; k++)
{
- if (tempImageBuffer[k]!=NULL) clEnv->library->clReleaseMemObject(tempImageBuffer[k]);
+ if (tempImageBuffer[k]!=NULL)
+ clEnv->library->clReleaseMemObject(tempImageBuffer[k]);
}
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (hullPass1!=NULL) RelinquishOpenCLKernel(hullPass1);
- if (hullPass2!=NULL) RelinquishOpenCLKernel(hullPass2);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (hullPass1!=NULL)
+ RelinquishOpenCLKernel(hullPass1);
+ if (hullPass2!=NULL)
+ RelinquishOpenCLKernel(hullPass2);
if (outputReady == MagickFalse && filteredImage != NULL)
filteredImage=DestroyImage(filteredImage);
+
return(filteredImage);
}
/*
* initialize opencl env
*/
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
/*
image_view=DestroyCacheView(image_view);
- if (imageBuffer!=NULL)
+ if (imageBuffer!=NULL)
clEnv->library->clReleaseMemObject(imageBuffer);
-
if (map!=NULL)
map=(FloatPixelPacket *) RelinquishMagickMemory(map);
-
if (equalizeMapBuffer!=NULL)
clEnv->library->clReleaseMemObject(equalizeMapBuffer);
if (equalize_map!=NULL)
equalize_map=(PixelPacket *) RelinquishMagickMemory(equalize_map);
-
- if (histogramBuffer!=NULL)
+ if (histogramBuffer!=NULL)
clEnv->library->clReleaseMemObject(histogramBuffer);
if (histogram!=NULL)
histogram=(cl_uint4 *) RelinquishMagickMemory(histogram);
-
- if (histogramKernel!=NULL)
+ if (histogramKernel!=NULL)
RelinquishOpenCLKernel(histogramKernel);
- if (equalizeKernel!=NULL)
+ if (equalizeKernel!=NULL)
RelinquishOpenCLKernel(equalizeKernel);
-
- if (queue != NULL)
+ if (queue != NULL)
RelinquishOpenCLCommandQueue(device, queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
return(outputReady);
}
parametersBuffer = NULL;
pixels = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
image_view=AcquireAuthenticCacheView(image,exception);
imageBuffer=createReadWriteBuffer(image,image_view,clEnv,device,pixels,
image_view=DestroyCacheView(image_view);
- if (clkernel != NULL) RelinquishOpenCLKernel(clkernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device, queue);
- if (imageBuffer != NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (parametersBuffer != NULL) clEnv->library->clReleaseMemObject(parametersBuffer);
+ if (clkernel != NULL)
+ RelinquishOpenCLKernel(clkernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
+ if (imageBuffer != NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (parametersBuffer != NULL)
+ clEnv->library->clReleaseMemObject(parametersBuffer);
return(status);
}
/*
* initialize opencl env
*/
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
/* Create and initialize OpenCL buffers.
if (grayscaleKernel!=NULL)
RelinquishOpenCLKernel(grayscaleKernel);
if (queue != NULL)
- RelinquishOpenCLCommandQueue(device, queue);
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
return( outputReady);
}
queue = NULL;
outputReady = MagickFalse;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
/* Create and initialize OpenCL buffers. */
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (tempImageBuffer!=NULL) clEnv->library->clReleaseMemObject(tempImageBuffer);
- if (imageKernelBuffer!=NULL) clEnv->library->clReleaseMemObject(imageKernelBuffer);
- if (blurRowKernel!=NULL) RelinquishOpenCLKernel(blurRowKernel);
- if (blurColumnKernel!=NULL) RelinquishOpenCLKernel(blurColumnKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device, queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (tempImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(tempImageBuffer);
+ if (imageKernelBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageKernelBuffer);
+ if (blurRowKernel!=NULL)
+ RelinquishOpenCLKernel(blurRowKernel);
+ if (blurColumnKernel!=NULL)
+ RelinquishOpenCLKernel(blurColumnKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device, queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse)
{
if (filteredImage != NULL)
filteredImage = NULL;
}
}
+
return(filteredImage);
}
/*
* initialize opencl env
*/
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
outputReady = MagickFalse;
image_view=DestroyCacheView(image_view);
- if (imageBuffer!=NULL)
+ if (imageBuffer!=NULL)
clEnv->library->clReleaseMemObject(imageBuffer);
- if (modulateKernel!=NULL)
+ if (modulateKernel!=NULL)
RelinquishOpenCLKernel(modulateKernel);
- if (queue != NULL)
+ if (queue != NULL)
RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
return outputReady;
motionBlurKernel = NULL;
queue = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
/* Create and initialize OpenCL buffers. */
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (imageKernelBuffer!=NULL) clEnv->library->clReleaseMemObject(imageKernelBuffer);
- if (motionBlurKernel!=NULL) RelinquishOpenCLKernel(motionBlurKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (imageKernelBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageKernelBuffer);
+ if (motionBlurKernel!=NULL)
+ RelinquishOpenCLKernel(motionBlurKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse && filteredImage != NULL)
filteredImage=DestroyImage(filteredImage);
cubicCoefficientsBuffer = NULL;
queue = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
image_view = AcquireAuthenticCacheView(image, exception);
imageBuffer=createReadBuffer(image,image_view,clEnv,device,exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (tempImageBuffer!=NULL) clEnv->library->clReleaseMemObject(tempImageBuffer);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (cubicCoefficientsBuffer!=NULL) clEnv->library->clReleaseMemObject(cubicCoefficientsBuffer);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device, queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (tempImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(tempImageBuffer);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (cubicCoefficientsBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(cubicCoefficientsBuffer);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse && filteredImage != NULL)
filteredImage=DestroyImage(filteredImage);
+
return(filteredImage);
}
queue = NULL;
rotationalBlurKernel = NULL;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
image_view=AcquireAuthenticCacheView(image, exception);
imageBuffer=createReadBuffer(image,image_view,clEnv,device,exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (sinThetaBuffer!=NULL) clEnv->library->clReleaseMemObject(sinThetaBuffer);
- if (cosThetaBuffer!=NULL) clEnv->library->clReleaseMemObject(cosThetaBuffer);
- if (rotationalBlurKernel!=NULL) RelinquishOpenCLKernel(rotationalBlurKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (sinThetaBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(sinThetaBuffer);
+ if (cosThetaBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(cosThetaBuffer);
+ if (rotationalBlurKernel!=NULL)
+ RelinquishOpenCLKernel(rotationalBlurKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse)
{
if (filteredImage != NULL)
filteredImage = NULL;
}
}
+
return filteredImage;
}
queue = NULL;
outputReady = MagickFalse;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
image_view = AcquireAuthenticCacheView(image, exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (tempImageBuffer!=NULL) clEnv->library->clReleaseMemObject(tempImageBuffer);
- if (imageKernelBuffer!=NULL) clEnv->library->clReleaseMemObject(imageKernelBuffer);
- if (blurRowKernel!=NULL) RelinquishOpenCLKernel(blurRowKernel);
- if (unsharpMaskBlurColumnKernel!=NULL) RelinquishOpenCLKernel(unsharpMaskBlurColumnKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (tempImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(tempImageBuffer);
+ if (imageKernelBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageKernelBuffer);
+ if (blurRowKernel!=NULL)
+ RelinquishOpenCLKernel(blurRowKernel);
+ if (unsharpMaskBlurColumnKernel!=NULL)
+ RelinquishOpenCLKernel(unsharpMaskBlurColumnKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse)
{
if (filteredImage != NULL)
filteredImage = NULL;
}
}
+
return(filteredImage);
}
queue = NULL;
outputReady = MagickFalse;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
image_view=AcquireAuthenticCacheView(image,exception);
if (filteredImage_view != NULL)
filteredImage_view=DestroyCacheView(filteredImage_view);
- if (imageBuffer!=NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (filteredImageBuffer!=NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (imageKernelBuffer!=NULL) clEnv->library->clReleaseMemObject(imageKernelBuffer);
- if (unsharpMaskKernel!=NULL) RelinquishOpenCLKernel(unsharpMaskKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (imageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (filteredImageBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (imageKernelBuffer!=NULL)
+ clEnv->library->clReleaseMemObject(imageKernelBuffer);
+ if (unsharpMaskKernel!=NULL)
+ RelinquishOpenCLKernel(unsharpMaskKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse)
{
if (filteredImage != NULL)
filteredImage = NULL;
}
}
+
return(filteredImage);
}
denoiseKernel = NULL;
outputReady = MagickFalse;
- device = GetOpenCLDevice(clEnv);
+ device = RequestOpenCLDevice(clEnv);
queue = AcquireOpenCLCommandQueue(device);
/* Create and initialize OpenCL buffers. */
if (filteredImage_view != NULL)
filteredImage_view = DestroyCacheView(filteredImage_view);
- if (imageBuffer != NULL) clEnv->library->clReleaseMemObject(imageBuffer);
- if (filteredImageBuffer != NULL) clEnv->library->clReleaseMemObject(filteredImageBuffer);
- if (denoiseKernel != NULL) RelinquishOpenCLKernel(denoiseKernel);
- if (queue != NULL) RelinquishOpenCLCommandQueue(device,queue);
+ if (imageBuffer != NULL)
+ clEnv->library->clReleaseMemObject(imageBuffer);
+ if (filteredImageBuffer != NULL)
+ clEnv->library->clReleaseMemObject(filteredImageBuffer);
+ if (denoiseKernel != NULL)
+ RelinquishOpenCLKernel(denoiseKernel);
+ if (queue != NULL)
+ RelinquishOpenCLCommandQueue(device,queue);
+ if (device != NULL)
+ ReleaseOpenCLDevice(clEnv,device);
if (outputReady == MagickFalse)
{
if (filteredImage != NULL)
filteredImage = NULL;
}
}
+
return(filteredImage);
}
assert(device != (MagickCLDevice) NULL);
LockSemaphoreInfo(device->lock);
- device->created_queues++;
if ((device->profile_kernels == MagickFalse) &&
(device->command_queues_index >= 0))
{
return(default_CLEnv);
}
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% G e t O p e n C L D e v i c e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% GetOpenCLDevice() returns one of the enabled OpenCL devices.
-%
-% The format of the GetOpenCLDevice method is:
-%
-% MagickCLDevice GetOpenCLDevice(MagickCLEnv clEnv)
-%
-% A description of each parameter follows:
-%
-% o clEnv: the OpenCL environment.
-*/
-
-MagickPrivate MagickCLDevice GetOpenCLDevice(MagickCLEnv clEnv)
-{
- MagickCLDevice
- device;
-
- double
- score,
- best_score;
-
- size_t
- i;
-
- if (clEnv == (MagickCLEnv) NULL)
- return((MagickCLDevice) NULL);
-
- if (clEnv->number_devices == 1)
- {
- if (clEnv->devices[0]->enabled)
- return(clEnv->devices[0]);
- else
- return((MagickCLDevice) NULL);
- }
-
- device=(MagickCLDevice) NULL;
- best_score=0.0;
- for (i = 0; i < clEnv->number_devices; i++)
- {
- if (clEnv->devices[i]->enabled == MagickFalse)
- continue;
-
- LockSemaphoreInfo(clEnv->devices[i]->lock);
- score=clEnv->devices[i]->score+(clEnv->devices[i]->score*
- clEnv->devices[i]->created_queues);
- UnlockSemaphoreInfo(clEnv->devices[i]->lock);
- if ((device == (MagickCLDevice) NULL) || (score < best_score))
- {
- device=clEnv->devices[i];
- best_score=score;
- }
- }
- return(device);
-}
-
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
return(MagickFalse);
/* Check if we need to compile a kernel for one of the devices */
+ status=MagickTrue;
for (i = 0; i < clEnv->number_devices; i++)
{
if ((clEnv->devices[i]->enabled != MagickFalse) &&
(clEnv->devices[i]->program == (cl_program) NULL))
+ {
+ status=MagickFalse;
break;
+ }
}
- if (i == clEnv->number_devices)
+ if (status != MagickFalse)
return(MagickTrue);
/* Get additional options */
name=DestroyString(name);
}
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e l e a s e M a g i c k C L D e v i c e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ReleaseOpenCLDevice() returns the OpenCL device to the environment
+%
+% The format of the ReleaseOpenCLDevice method is:
+%
+% void ReleaseOpenCLDevice(MagickCLEnv clEnv,MagickCLDevice device)
+%
+% A description of each parameter follows:
+%
+% o clEnv: the OpenCL environment.
+%
+% o device: the OpenCL device to be released.
+%
+*/
+
+MagickPrivate void ReleaseOpenCLDevice(MagickCLEnv clEnv,MagickCLDevice device)
+{
+ LockSemaphoreInfo(clEnv->lock);
+ device->requested--;
+ UnlockSemaphoreInfo(clEnv->lock);
+}
+
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
assert(device != (MagickCLDevice) NULL);
LockSemaphoreInfo(device->lock);
- device->created_queues--;
if ((device->profile_kernels != MagickFalse) ||
- (device->command_queues_index >= MAGICKCORE_OPENCL_COMMAND_QUEUES-1))
- (void) openCL_library->clReleaseCommandQueue(queue);
+ (device->command_queues_index >= MAGICKCORE_OPENCL_COMMAND_QUEUES - 1))
+ {
+ UnlockSemaphoreInfo(device->lock);
+ (void)openCL_library->clReleaseCommandQueue(queue);
+ }
else
- device->command_queues[++device->command_queues_index]=queue;
- UnlockSemaphoreInfo(device->lock);
+ {
+ device->command_queues[++device->command_queues_index] = queue;
+ UnlockSemaphoreInfo(device->lock);
+ }
}
/*
(void) openCL_library->clReleaseKernel(kernel);
}
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e q u e s t O p e n C L D e v i c e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% RequestOpenCLDevice() returns one of the enabled OpenCL devices.
+%
+% The format of the RequestOpenCLDevice method is:
+%
+% MagickCLDevice RequestOpenCLDevice(MagickCLEnv clEnv)
+%
+% A description of each parameter follows:
+%
+% o clEnv: the OpenCL environment.
+*/
+
+MagickPrivate MagickCLDevice RequestOpenCLDevice(MagickCLEnv clEnv)
+{
+ MagickCLDevice
+ device;
+
+ double
+ score,
+ best_score;
+
+ size_t
+ i;
+
+ if (clEnv == (MagickCLEnv) NULL)
+ return((MagickCLDevice) NULL);
+
+ if (clEnv->number_devices == 1)
+ {
+ if (clEnv->devices[0]->enabled)
+ return(clEnv->devices[0]);
+ else
+ return((MagickCLDevice) NULL);
+ }
+
+ device=(MagickCLDevice) NULL;
+ best_score=0.0;
+ LockSemaphoreInfo(clEnv->lock);
+ for (i = 0; i < clEnv->number_devices; i++)
+ {
+ if (clEnv->devices[i]->enabled == MagickFalse)
+ continue;
+
+ score=clEnv->devices[i]->score+(clEnv->devices[i]->score*
+ clEnv->devices[i]->requested);
+ if ((device == (MagickCLDevice) NULL) || (score < best_score))
+ {
+ device=clEnv->devices[i];
+ best_score=score;
+ }
+ }
+ if (device != (MagickCLDevice)NULL)
+ device->requested++;
+ UnlockSemaphoreInfo(clEnv->lock);
+
+ return(device);
+}
+
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %