OpenCL Acceleration Questions

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.
Post Reply
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

OpenCL Acceleration Questions

Post by jonoomph »

Greetings! I have a quick question regarding OpenCL support in ImageMagick. The next version of OpenShot (http://www.openshot.org) is using ImageMagick++ as its image processing platform, and integrating OpenCL to speed up performance on certain methods would be a highly desirable thing. I recently saw on the ImageMagick forums, a user (i.e. oneal) had shared many additional OpenCL accelerated methods (viewtopic.php?f=2&t=22906), but apparently they were not merged into the newest version of ImageMagick (from what I understand).

Okay, so here is my question. What is the best (i.e. most effective) way to implement OpenCL on more ImageMagick functions. For example, would you recommend I take oneal's work, merge it into the latest ImageMagick source, and submit that branch back to you? Or, would it be better to not follow the current example in accelerate.c, and instead use OpenACC pragmas, like you suggested to oneal?

Also, if anyone is interested in joining my efforts to speed up ImageMagick with OpenCL, I would love the help and suggestions.

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

Re: OpenCL Acceleration Questions

Post by magick »

The ImageMagick developers are looking toward OpenMP 4.0 to accelerate ImageMagick algortihms. It supports new pragmas such as SIMD to vectorize certain loops. With OpenMP, there is no requirement to support separate codesets on the CPU host and the GPU. Our first efforts are with OpenMP 4.0 on an Phi coprocessor.
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

Re: OpenCL Acceleration Questions

Post by jonoomph »

That's very exciting! I'm also using OpenMP in OpenShot to parallelize various things, but I'm not familiar with their new 4.0 release candidate. So, does this mean once OpenMP 4.0 is widely available in compilers, ImageMagick can leverage its existing use of OpenMP pragmas, and with some small adjustments, leverage both the CPU and GPU? Also, I wonder how long it will take before OpenMP 4.0 is available in the GCC and other popular compilers.
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

Re: OpenCL Acceleration Questions

Post by jonoomph »

Have you already started to test OpenMP 4.0 with your Intel Xeon Phi coprocessor? I am very interested to hear about your experience, and how the tests are going. Just out of curiosity, did Intel "gift" you a Phi coprocessor? Those things are crazy expensive. =)

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

Re: OpenCL Acceleration Questions

Post by magick »

The latest release of the Intel compilers support OpenMP 4.0 on any Intel multi-core or multi-processor system. You can download a trial for something like 30 days. We'll report back on the Intel Phi late this summer.
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

Re: OpenCL Acceleration Questions

Post by jonoomph »

In case anyone is wondering when OpenMP 4.0 will be released, I did some research and here is what I've found. It looks like the OpenMP 4.0 specification will be completed and released very soon (2nd quarter of 2013), and then I suppose it will take some time before compilers get it implemented correctly. The GCC has a separate branch you can download and test, and as you mentioned, Intel compilers already support it.

I'm curious how much of a speed improvement ImageMagick will receive from the Intel Phi... as compared to another (less expensive) accelerator, such as a mid-level graphics card (~$150). Since image filters are processed in small blocks of pixels (to the best of my knowledge), is it possible that ImageMagick will not be able to use all the Phi's available threads... resulting in similar performance to a mid-level graphics card?
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

Re: OpenCL Acceleration Questions

Post by jonoomph »

Hi Magick!
I was wondering if you have had any success with the Intel Phi and OpenMP 4.0 this summer? I am anxious to hear the results. Thanks!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: OpenCL Acceleration Questions

Post by magick »

We're just getting started. We have a volunteer to get the OpenCL code into ImageMagick for GPU acceleration and we're thinking about how best to accelerate ImageMagick on the Phi coprocessor. It will probably be well into fall before we have something for users to test.
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

Re: OpenCL Acceleration Questions

Post by jonoomph »

Thanks for the update! Let me know if I can be of any assistance.
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

Re: OpenCL Acceleration Questions

Post by jonoomph »

How goes the implementation of OpenMP 4.0 with your Intel Phi processor? Any results to share with the community yet? As I've mentioned before, if you need any help, I would be happy to assist or even possibly donate money to help with this feature. I think it will be a tremendous capability for ImageMagick! Thanks again for all your hard work!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: OpenCL Acceleration Questions

Post by magick »

We tried to engage Intel on contributing to this effort but they didn't bite. In the mean-time we learned how to leverage the PHI Coprocessor by reading several books on the topic but we have not translated our learnings to ImageMagick code just yet. We got distracted by the contributions AMD has made to support 20+ ImageMagick algorithms for the GPU, written in OpenCL. We will get back to the PHI but it will likely be at least a month.

In the mean-time you of course can help by contributing algorithms that would work on the PHI. If you don't have the knowledge / time / PHI Coprocessor, be patient. We'll get to it but it may be awhile. Otherwise, OpenCL should work on the PHI, adapt the OpenCL algorithms AMD contributed to the PHI.
Post Reply