Imagemagick only uses one core

前端 未结 2 1496
灰色年华
灰色年华 2020-12-31 18:59

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

Version         


        
2条回答
  •  天命终不由人
    2020-12-31 19:56

    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:

    1. 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.

    2. 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 
      #  define MAGICKCORE_OPENMP_SUPPORT  1
      #endif
      

      Modify those line to add a compiler diagnostic message:

      #if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
      #  include 
      #  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.

    3. 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.

    4. 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)

    5. 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 !

提交回复
热议问题