Page 1 of 1

Multi-threaded operations?

Posted: 2008-02-19T15:54:29-07:00
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

Re: Multi-threaded operations?

Posted: 2008-02-19T16:44:53-07:00
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.

Re: Multi-threaded operations?

Posted: 2008-02-20T09:52:23-07:00
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

Re: Multi-threaded operations?

Posted: 2008-02-20T10:01:46-07:00
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.

Re: Multi-threaded operations?

Posted: 2008-02-20T10:48:18-07:00
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

Re: Multi-threaded operations?

Posted: 2008-02-20T11:13:23-07:00
by magick
Some Unix users prefer to build ImageMagick under Cygwin or MinGW otherwise build a native version with Visual C++.