Imagemagick uses only one core

I am running an Ubuntu server with 8 cores. However, imagemagick always uses only one core.
Running identify -version returns:

 Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC Features: OpenMP 

So, OpenMP , which is apparently necessary for multithreading, is allowed.

Running a test with the -bench option (for example, convert logo: -resize 500% -bench 10 logo.png ), as described here , returns

 Performance: 10i 1.17647ips 14.390u 0.14166666666833332977:08.500 

It does not return Performance[1] through Performance[8] as described in the manual , which makes me wonder.

Any ideas how I can get imagemagick to use all 8 cores?

Update: here is strace output from imagemagick call: http://pastebin.com/Q0gC3k09

+7
imagemagick openmp
source share
2 answers

I was able to reproduce this behavior on Ubuntu 10.04. The apt-get ImageMagick seems to have an OpenMP function and is configured using the -fopenmp flag, but the function does not seem to be enabled. This can be verified by completing the following line and comparing the FEATURES "(if present) list with various configuration flags.

 identify -list Configure | less 

I was able to solve this problem by following the article " " Installing ImageMagick from a Source on Ubuntu 8.04 ", which details the following process.

  • Remove ImageMagick
  • Install all the necessary image / graphic dependency libraries via apt-get
  • Download
    • wget http://www.imagemagick.org/download/ImageMagick-6.8.6-6.tar.gz
  • Follow the basic steps ./configure , make and sudo make install
  • Export library path to /usr/local/lib

It looks like OpenMP is now on the FEATURES list, and when I do the 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 are consistent with what I expect.

+11
source share

Some tests that I did on my side, but I could not configure a real or virtualized multicore machine to play. Therefore, I do not have a real solution, but more with a research strategy, because it really looks like a system dependency.

But at least I can say that:

  • If you get the latest ImageMagick source from http://www.imagemagick.org/script/install-source.php#unix , you can restore the IM for your system.

  • if you want to be sure that your compiler is processing the code as expected, you can do the following before calling make, edit the magick / studio.h file, find line 143, you should see Next.

     #if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__)) # include <omp.h> # define MAGICKCORE_OPENMP_SUPPORT 1 #endif 

    Change this 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 "./configure" and after the "make" command you will see a message that you added every time studio.h is used, and the BTW macro MAGICKCORE_OPEN_SUPPORT is set to 1.

  • MAGICKCORE_OPENMP_SUPPORT is a macro that IM uses internally to enable / disable preprocessing of OpenMp directives, so if you see this message, all #pragma omp code will be valid.

  • If everything is fine, still trying to execute the make install command and check if your bench command (multi-core) is working with your own version of convert (/ usr / local / bin / convert)

  • if it still does not work, it means that it is not connected with IM, but the program based on OpenMP does not work correctly on your system. In this case, you should consider the following question: Why does the OpenMP program work in only one thread and checks for OpenMP support with a shorter build and run program than IM!

+1
source share

All Articles