As some of you may be aware, GraphicsMagick has become multithreaded 
via OpenMP.

My original implementation of speeding up CMS transforms assumed that 
lcms is thread safe so that all threads shared the same transform 
created by cmsCreateTransform().  It turns out that lcms is not as 
thread safe as desired.  Several profiles cause image corruption if 
lcms is used in this way.  Even without the corruption, there is no 
speedup from multithreading (just more CPU consumption) so there must 
be some read/write contention for shared data which does not happen to 
influence the result in the common case.

I tried building lcms using its special thread safety option and this 
did eliminate the image corruption, but it also made lcms several 
orders of magnitude slower.

My current implementation uses cmsCreateTransform() to create an 
independent transform for use by each thread.  This avoids image 
corruption and I see linear speedup with efficient use of the CPU.

Unfortunately, it turns out that cmsCreateTransform() is not thread 
safe.  In order to improve performance on NUMA hardware it would be 
beneficial for cmsCreateTransform() to be invoked by the thread which 
will be using the data.  Since cmsCreateTransform() blows up if 
several threads invoke it at once, I have to prepare the transforms in 
advance, so the memory is allocated ideally for the thread which 
prepares the transforms but not for the rest of the worker threads.

Is there a better way to multithread the use of lcms without invoking 
cmsCreateTransform() sequentially in advance for the number of worker 
threads?

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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to