Hi Adrian,
What you need are contexts. Contexts gives you exactly the functionality you
asked for:
cmsContext ctx_single = cmsCreateContext(NULL, NULL); // A context for 1
thread
cmsContext ctx_multi =
cmsCreateContext(cmsThreadedExtensions(CMS_THREADED_GUESS_MAX_THREADS),
NULL); // A context for multi-threaded
Then use cmsCreateTransformTHR to create different transforms on each
context. The obtained transforms will use one thread or be multithreaded.
You can just apply the transforms by using cmsDoTransform or
cmsTransformLineStride. The CMM knows if it should split or not the work
because that information is already in the transform handle.
Hope that helps
Regards
Marti Maria
The LittleCMS Project
https://www.littlecms.com
> -----Original Message-----
> From: Adrian Knagg-Baugh <aje...@gm...>
> Sent: Friday, July 14, 2023 1:10 AM
> To: lcm...@li...
> Subject: [Lcms-user] How to change number of threads between transforms
>
> Hi,
>
> Please excuse the skeletal pseudocode. Sometimes in my code I would like
to
> use multiple threads when doing a transform, but at other times it is
> important that I only use a single thread. So I need to work out how best
to
> switch between the two configurations.
>
> Is it permitted to do something like this:
> {
> cmsPlugin(cmsFastFloatExtensions()); // Register fast float plugin
> cmsPlugin(cmsThreadedExtensions(CMS_THREADED_GUESS_MAX_THREADS,
> 0)); // Register the threading plugin with maximum threads
>
> // I want this transform to use maximum threads
> cmsDoTransformLineStride(...);
>
> // I want this next transform to use only 1 thread
> cmsPlugin(cmsThreadedExtensions(1, 0)); // Reconfigure the threading
plugin
> with 1 thread cmsDoTransformLineStride(...); // Do the single-threaded
> transform
>
> // Now back to maximum threads...
> cmsPlugin(cmsThreadedExtensions(CMS_THREADED_GUESS_MAX_THREADS,
> 0)); // Reconfigure the threading plugin with maximum threads }
>
> Or instead would I have to do this:
> {
> cmsPlugin(cmsFastFloatExtensions()); // Register fast float plugin
> cmsPlugin(cmsThreadedExtensions(CMS_THREADED_GUESS_MAX_THREADS,
> 0)); // Register the threading plugin with maximum threads
>
> // I want this transform to use maximum threads
> cmsDoTransformLineStride(...);
>
> // I want this next transform to use only 1 thread cmsUnregisterPlugins();
//
> Revert to pristine lcms2 cmsPlugin(cmsFastFloatExtensions()); //
Re-register
> fast float plugin only cmsDoTransformLineStride(...); // Do the
single-threaded
> transform
>
> // Now back to maximum threads...
> cmsPlugin(cmsThreadedExtensions(CMS_THREADED_GUESS_MAX_THREADS,
> 0)); // Re-register threading plugin with maximum threads }
>
> Thanks,
>
> Adrian.
>
>
> _______________________________________________
> Lcms-user mailing list
> Lcm...@li...
> https://lists.sourceforge.net/lists/listinfo/lcms-user
|