<metaname="description"content="Use ImageMagick® to create, edit, compose, and convert bitmap images. Resize an image, crop it, change its shades and colors, add captions, and more."/>
<pclass="lead magick-description">Many of ImageMagick's internal algorithms are threaded to take advantage of speed-ups offered by the multicore processor chips and <ahref="http://www.openmp.org">OpenMP</a>. OpenMP, is an API specification for parallel programming. If your compiler supports OpenMP (e.g. gcc, Visual Studio 2005) directives, ImageMagick automatically includes support. To verify, look for the OpenMP feature of ImageMagick with this command:</p>
<p>With OpenMP enabled, most ImageMagick algorithms execute on all the cores on your system in parallel. ImageMagick typically divides the work so that each thread processes 64 rows of pixels. As rows are completed, OpenMP assigns more chunks of pixel rows to each thread until the algorithm completes. For example, if you have a quad-core system, and attempt to resize an image, the resizing takes place on 4 cores (8 if hyperthreading is enabled).</p>
<p>You can further increase performance by reducing lock contention with the <ahref="http://goog-perftools.sourceforge.net/doc/tcmalloc.html">tcmalloc</a> memory allocation library. To enable, add <code>--with-tcmalloc</code> to the <code>configure</code> command-line when you build ImageMagick.</p>
<h5>The Perils of Parallel Execution</h5>
<p>It can be difficult to predict behavior in a parallel environment. Performance might depend on a number of factors including the compiler, the version of the OpenMP library, the processor type, the number of cores, the amount of memory, whether hyperthreading is enabled, the mix of applications that are executing concurrently with ImageMagick, or the particular image-processing algorithm you utilize. The only way to be certain of the optimal performance, in terms of the number of threads, is to benchmark. ImageMagick includes progressive threading when benchmarking a command and returns the elapsed time and efficiency for one or more threads. This can help you identify how many threads are the most efficient in your environment. Here is an example benchmark for threads 1-8:</p>
<p>Better performance correlates with higher values of IPS (iterations-per-second). In our example, 8 cores are optimal. However, in certain cases it might be optimal to set the number of threads to 1 (e.g. <code>-limit thread 1</code>) or to disable OpenMP completely. To disable this feature, add <code>--disable-openmp</code> to your configure script command line then rebuild and re-install ImageMagick.</p>
</div>
</div>
</main><!-- /.container -->
<footerclass="magick-footer">
<divclass="container">
<p><ahref="security-policy.html">Security</a> •
<ahref="news.html">News</a>
<ahref="openmp.html#"><imgclass="d-inline"id="wand"alt="And Now a Touch of Magick"width="16"height="16"src="../images/wand.ico"/></a>