I am running an Ubuntu server with 8 cores. However imagemagick always only uses 1 single core.
Running identify -version
returns:
Version
I was able to reproduce this behavior on Ubuntu 10.04. ImageMagick from apt-get seems to have the OpenMP feature, and configure with the -fopenmp
flag, but the feature doesn't seem to be enabled. This can be verified by running the following line, and comparing the "FEATURES" list (if present) to the various configuration flags.
identify -list Configure | less
I was able to resolve this by following the article "Installing ImageMagick from Source on Ubuntu 8.04" which detailed the following process.
wget http://www.imagemagick.org/download/ImageMagick-6.8.6-6.tar.gz
./configure
, make
, & sudo make install
steps/usr/local/lib
This seems to work as OpenMP is now present under "FEATURES" list, and when I execute convert logo: -resize 500% -bench 10 logo.png
. I see the following
Performance[1]: 10i 0.750ips 1.000e 18.750u 0:13.330
Performance[2]: 10i 0.751ips 0.500e 18.660u 0:13.320
Performance[3]: 10i 0.738ips 0.496e 18.840u 0:13.550
Performance[4]: 10i 0.469ips 0.385e 19.560u 0:21.320
And these results match what I would expect.
Some tests I made on my side but I not able to setup a real or virtualized multicore machine to reproduce. So I don't come with a real solution but more with a strategy to investigate because it really seems to be system dependent.
But at least I can say that:
if you get the last ImageMagick source from http://www.imagemagick.org/script/install-source.php#unix, you should be able to rebuild IM for your system.
if you want to be sure that your compiler handle the code as expected, you can do the following before calling "make", Edit the magick/studio.h file, found the line 143, you should see the following.
#if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
# include <omp.h>
# define MAGICKCORE_OPENMP_SUPPORT 1
#endif
Modify those line to add a compiler diagnostic message:
#if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
# include <omp.h>
# define MAGICKCORE_OPENMP_SUPPORT 1
# pragma message "MAGICKCORE_OPENMP_SUPPORT 1"
#endif
Now run the './configure' and after the 'make' command, you should see the message you added every time studio.h is used and BTW MAGICKCORE_OPEN_SUPPORT macro set to 1.
MAGICKCORE_OPENMP_SUPPORT is the macro that IM use internally to enable/disable the preprocessing of the OpenMp directives, so if you see the message, all #pragma omp of the code will be process for real.
If everything is ok until now try to perform the 'make install' command and check if your 'bench' command work better (multicore) with your own version of convert (/usr/local/bin/convert)
if it's still not working, it means that it's not related to IM, but that openMP based program don't run correctly on your system. In that case you should consider the following question Why OpenMP program runs only in one thread, and check openMP support with a shorter program to build and run than IM !