Multi-threaded operations?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
foxcorner

Multi-threaded operations?

Post by foxcorner »

Hello all,

I'm working on a computer performance benchmark relating to image processing. ImageMagick looks like it'll be a great tool for this. The thing is, I'm trying to exercise all the processor cores on my workstation (8, in this case), so I'm looking for some pointers to operations which are multi-threaded, either by default or with a command-line switch.

For example, I tried -blur, but it was clearly using only one core.

I'm using the standard Windows 6.3.8-9 dll.exe binary, downloaded today.

Are there some multi-threaded operations, filters, reads, writes, etc? If so, and they're not multi-threaded by default, how to I enable multi-threading? Do I need a different build?

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

Re: Multi-threaded operations?

Post by magick »

From http://magick.imagemagick.org/script/ar ... hp#threads:

Many of ImageMagick's internal algorithms are threaded to take advantage of speed-ups offered by the dual and quad-core processor technologies. However, you are welcome to use ImageMagick algorithm in your threads of execution with the exception of the MagickCore AcquireImagePixels(), GetImagePixels(), SetImagePixels(), and SyncImagePixels() pixel cache methods. These methods are intended for one thread of execution only. To access the pixel cache with more than one thread of execution, use a cache view. We do this for the CompositeImage() method, for example. Suppose we want to composite a single image over a different image in each thread of execution. If we use AcquireImagePixels(), the results could be corrupt since multiple threads might be asking for different areas of the pixel cache simultaneously. Instead we use AcquireCacheViewPixels() which creates a unique view for each thread of execution ensuring our program behaves properly regardless of how many threads are invoked. The other program interfaces, such as the MagickWand API, are completely thread safe so there are no special precautions for threads of execution.
foxcorner

Re: Multi-threaded operations?

Post by foxcorner »

magick wrote:From http://magick.imagemagick.org/script/ar ... hp#threads:

Many of ImageMagick's internal algorithms are threaded to take advantage of speed-ups offered by the dual and quad-core processor technologies. However, you are welcome to use ImageMagick algorithm in your threads of execution with the exception of the MagickCore AcquireImagePixels(), GetImagePixels(), SetImagePixels(), and SyncImagePixels() pixel cache methods. These methods are intended for one thread of execution only. To access the pixel cache with more than one thread of execution, use a cache view. We do this for the CompositeImage() method, for example. Suppose we want to composite a single image over a different image in each thread of execution. If we use AcquireImagePixels(), the results could be corrupt since multiple threads might be asking for different areas of the pixel cache simultaneously. Instead we use AcquireCacheViewPixels() which creates a unique view for each thread of execution ensuring our program behaves properly regardless of how many threads are invoked. The other program interfaces, such as the MagickWand API, are completely thread safe so there are no special precautions for threads of execution.
Thanks. Yes, I had seen this in my searches; but I don't have the knowledge to know how that information maps to the question: which operations in (say) convert are multi-threaded? I'm intending to use existing binary tools; I'm not planning to use the API.

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

Re: Multi-threaded operations?

Post by magick »

If you add --enable-openmp to your configure script command line and build ImageMagick, convolution operations run in multiple threads (e.g. blur, sharpen, unsharp mask, edge, etc). We intend to thread additional image processing algorithms in the future as time permits.
foxcorner

Re: Multi-threaded operations?

Post by foxcorner »

magick wrote:If you add --enable-openmp to your configure script command line and build ImageMagick, convolution operations run in multiple threads (e.g. blur, sharpen, unsharp mask, edge, etc). We intend to thread additional image processing algorithms in the future as time permits.
Thanks - that's what I was looking for. Now I've got to find a compiler... Presumably GCC is first choice (I'm on Windows XP-32)? What else is needed for a build environment that will build IM? I'm used to building on unixes, less so on Windows.

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

Re: Multi-threaded operations?

Post by magick »

Some Unix users prefer to build ImageMagick under Cygwin or MinGW otherwise build a native version with Visual C++.
Post Reply