[prev in list] [next in list] [prev in thread] [next in thread] 

List:       graphicsmagick-bugs
Subject:    Re: [GM-bugs] graphicsmagick bugs in  multi threads programs
From:       Bob Friesenhahn <bfriesen () simple ! dallas ! tx ! us>
Date:       2013-05-09 13:55:29
Message-ID: alpine.GSO.2.01.1305090839350.2267 () freddy ! simplesystems ! org
[Download RAW message or body]

On Wed, 8 May 2013, 王利超 wrote:

> hi,all:
> I find GraphicsMagick doesn't work well if the program self is multi thread。The \
> CPU is only 200%   (my computer is 16 core).
> The C++ API of GraphicsMagick is not working when   users program   is   multi \
> thread,openMP in  GraphicsMagick   is not like   paralle process.
> 
> My test GraphicsMagick versions are :1.3.18 ,1.3.17 ,1.3.16
> single threads test case is like:

The problem is almost certainly because the JPEG coder has been marked 
as not thread safe.  Take a look at RegisterJPEGImage() in 
magick/jpeg.c.

You could experiment by commenting out the two lines that say

   entry->thread_support=False; /* libjpeg is not thread safe */

or change from False to True.

or you could try this non-recommended approach (casts away const) with 
existing binaries:

    MagickInfo *magick_info=("JPEG",MagickInfo &exception);
    magick_info->thread_support=MagickTrue;
    MagickInfo *magick_info=("JPG",MagickInfo &exception);
    magick_info->thread_support=MagickTrue;

before reading/writing the JPEG files.  Please let us know how it 
turns out.  The JP2, PNG, and TIFF coders are marked the same way.

As far as I am aware, only the JPEG error reporting might not be 
thread safe because it uses setjmp()/longjmp() and behavior of these 
functions in multi-threaded programs is not well-defined because some 
processor context might not be restored, or the processor context 
restored might not be correct (for example, the longjmp() might occur 
on a different CPU than the original setjmp()).  This is highly OS and 
CPU dependent.

I do have an idea for how to eliminate use of setjmp()/longjmp() but 
it would then depend on POSIX threads features.

Bob
-- 
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may

_______________________________________________
Graphicsmagick-bugs mailing list
Graphicsmagick-bugs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-bugs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic