ImageMagick Accelerate Using OpenCL

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

ImageMagick Accelerate Using OpenCL

Post by oneal »

Hello, all

I'm a engineer and focusing on the acceleration technology of GPU. now we have done some optimizations In ImageMagick and get some performance improvment, so I want to share and contribute my optimizations.

the goal of my optimizations is speeding up the image processing. such as I make the gaussian-blur filter run on the GPU using OpenCL and compare the performance improvement, I get a more than 5x speedup (CPU vs GPU)

I get about 1x ~ 10x speedup base my optimized imageMagick version for some filters. Is there anyone interesting my work ?
If you are interesting my work, I can share my optimization design with you and discusse it.


Thanks
Oneal
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick Accelerate Using OpenCL

Post by magick »

ImageMagick includes an OpenCL convolution filter which supports blur. How does your filter differ?

Do you have a repository or patch that we can download your filter to test?
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by oneal »

magick wrote:ImageMagick includes an OpenCL convolution filter which supports blur. How does your filter differ?

Do you have a repository or patch that we can download your filter to test?

I have done more than 20 filters. but our optimizations is base on the 6.7.3. now we are merge our optimizations with the latest ImagMagick version(version 7).
if ImageMgick community can create a branch for our optimizations, I can do the merge base on the OpenCL branch and submit our code into this branch when I finished this integration.

For our optimizations. we have the done three optimzations.
1) optimizing more than 20 filters using OpenCL
2) optimizing the jpeg decoder using OpenCL and SSE
3) changes for cache some OpenCL runtime objects(we add a demon mode to do the image processing, this mode have big benefit in case of images batch processing ). if we want to get the max speedup, we should do the three components.

I'm merging the optimized filters into the latest ImageMagick version by following the customer filter rule. I'm also merging the optimized jpeg decoder into the latest ImageMagick by foolwing rules:

http://www.imagemagick.org/script/archi ... php#coders. You'll need an unique id such as OJPEG then type:
convert ojpeg:image.jpg image.png
to utilize the optimized JPEG decoder.

For the 3th optimzation. because this approach has changes the original framework of ImageMagick, I want to know How I can implement this idear. is there other mechanism that I can use to cach these OpenCL runtime objects.

Thanks
Oneal
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by oneal »

now I merge my OpenCL-filters optimization with 6.8.3 as custom filter.
and the jpeg decoder optimizing using OpenCL and SSE merged as custom image code,also in 6.8.3.

Where shall I update my code ?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick Accelerate Using OpenCL

Post by magick »

Post a URL to your distribution. We can add it to the contrib/ folder of the ImageMagick distribution archive. Be sure to include a separate README.txt file so users can readily identify how to utilize your OpenCL operators.
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by oneal »

I modify the configure project and the imagemagick can utilize your OpenCL operators automaticly.
And I will send you a private message with the git URL,username,password by.
You can build and test it by following the "Readme.txt" file.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick Accelerate Using OpenCL

Post by magick »

We got the credentials to download your OpenCL-enabled distribution of ImageMagick. Instead of downloading it to the ImageMagick archives, why not announce your GIT repository here so the user community can download it and start making contributions / patches / etc.?
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by oneal »

Can you merge my OpenCL-enabled distribution with the imagemagick repository?so the user community can download and patches it.
And I have another optimization which is use a demon programme to initialize all the opencl environment.
That's can reduce much time when you use opencl filter,but it need another background process and I don't konw this demon programme is acceptable.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick Accelerate Using OpenCL

Post by magick »

We can make your OpenCL distributions available in the ImageMagick contrib folder at http://www.imagemagick.org/download. It needs to go through an incubation period before we can consider merging it in the Subversion trunk.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick Accelerate Using OpenCL

Post by magick »

Find the GPU-enabled patches to ImageMagick to accelerate common image processing operators such as blur, sharpening, and edge detection here: http://www.imagemagick.org/download/contrib/. We encourage the user community to download, test, and contribute bug reports and patches.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick Accelerate Using OpenCL

Post by fmw42 »

The text file GPUMagick.txt seems to indicate that this is Windows only as it references .exe. Is this usable on unix platforms?
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by oneal »

fmw42 wrote:The text file GPUMagick.txt seems to indicate that this is Windows only as it references .exe. Is this usable on unix platforms?
I only modify and test my optimization on Windows platforms with different CPU and GPU.
oneal
Posts: 9
Joined: 2013-03-05T18:03:50-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by oneal »

magick wrote:We can make your OpenCL distributions available in the ImageMagick contrib folder at http://www.imagemagick.org/download. It needs to go through an incubation period before we can consider merging it in the Subversion trunk.
Hi,
What is the step of merging code in the subversion trunk? In other words will the incubation period takes?
And I think a demon programme will reduce the time of opencl environment initializion but It needs a background process and I don't konw a background process is acceptable or not?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick Accelerate Using OpenCL

Post by magick »

We don't think about merging until a user base / user demand is established for the OpenCL acceleration. Another consideration: its possible that your acceleration may be achieved with simple OpenACC pragmas. Or perhaps with an Intel PHI coprocessor. Both of these solutions are desirable because they only require no or few patches and do not require maintenance of separate algorithm codesets, one for the CPU and one for the GPU / coprocessor.

Another consideration is that your codeset needs to be supported under ImageMagick 7 before we could think about merging.
Frank.Wei
Posts: 1
Joined: 2013-05-23T08:16:53-07:00
Authentication code: 6789

Re: ImageMagick Accelerate Using OpenCL

Post by Frank.Wei »

Hi, Magick,

Actually the user demand for GPU computing is quite big in the image processing area. Many corresponding open source software has added their OpenCL module.There is a long list for that: OpenCV, x264, Handbrake, FFMPEG, Irfanview... At the same time, Adobe is pushing very heavy on enabling OpenCL in Photoshop going forward. From the users feedback, they all have achieved tremendous performance improvements and are welcomed in open community.
User experience is quite importance, the user would not know the benefits of OpenCL acceleration until they can try it on their laptop/desktop for Imagemagick. It will be convenient for the users if the community could merge the OpenCL code.

Although the OpenACC is good option but they reply much on the compiler itself and of course could not achieve the best performance results. There are many debates on that already.Intel PHI coprocessor is somehow far away from common users who can not afford the expensive processors. OpenCL is supported widely on different product lines by major chip manufacturer which is its great advantage over any other heterogeneous programming language.
Post Reply