[Lcms-user] How to change number of threads between transforms
An ICC-based CMM for color management
Brought to you by:
mm2
|
From: Adrian Knagg-B. <aje...@gm...> - 2023-07-13 23:10:12
|
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.
|