Page 1 of 1

OpenCL Acceleration Questions

Posted: 2013-04-24T14:42:05-07:00
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

Re: OpenCL Acceleration Questions

Posted: 2013-04-24T17:07:49-07:00
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.

Re: OpenCL Acceleration Questions

Posted: 2013-04-24T20:55:14-07:00
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.

Re: OpenCL Acceleration Questions

Posted: 2013-05-06T13:42:32-07:00
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

Re: OpenCL Acceleration Questions

Posted: 2013-05-06T15:05:51-07:00
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.

Re: OpenCL Acceleration Questions

Posted: 2013-05-07T09:31:11-07:00
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?

Re: OpenCL Acceleration Questions

Posted: 2013-07-17T21:45:56-07:00
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!

Re: OpenCL Acceleration Questions

Posted: 2013-07-18T04:21:12-07:00
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.

Re: OpenCL Acceleration Questions

Posted: 2013-07-22T11:52:24-07:00
by jonoomph
Thanks for the update! Let me know if I can be of any assistance.

Re: OpenCL Acceleration Questions

Posted: 2013-11-20T22:54:27-07:00
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!

Re: OpenCL Acceleration Questions

Posted: 2013-11-21T05:32:50-07:00
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.