Comments (4)
In fact I think perhaps I can, and maybe should, do most of what I want using contexts.
If I'm controlling threading at the image level, so that each image has one single thread and I'm processing multiple images in parallel each of which may wish to use lcms functions, should each of those threads have its own cmsContext?
And if that is the case, if a data structure is created by a function operating in one context can it be used by another context? (So for example if at program initialisation I do something like cmsHPROFILE profile = cmsCreateProfileTHR(context0, ...);
can I later on do cmsCreateTransformTHR(context1, profile, ...);
?
from little-cms.
I think what you want is way more simple. You don't even need cmsContext. If all the images you want to convert are of same color space, you can share the color transform between threads.
In the main thread:
- Open profiles and create a transform
- For each image, launch a thread that calls cmsDoTransformLineStride(), use same transform handle
- Wait for threads completion with join threads or similar.
- Delete the transform
That's all. cmsDoTransformLineStride() is re-entrant. Caching happens at thread level.
If color spaces are different, you could create one different transform per thread but that will take a lot more time. Re-use transforms and the profiles you open if possible.
The point of the threaded plug-in is to parallelize automatically the call to cmsDoTransforLineStride(). Is intended for yet-existing code that wants to be multi threaded with no programming. But in your case you have more control just managing the threads by yourself.
cmsContext is to completely isolate working environment. For example, one context using its own memory-management routines or another context using some plugins that the main context doesn't use.
from little-cms.
A cmsTransform can be parallelized simply by #pragma omp
- ing the nested for loops that walk the image. With that, OMP can be passed the thread count you want used, so this can be adjusted in run-time. Here's how I do it in rawproc:
https://github.com/butcherg/rawproc/blob/master/src/gimage.cpp#L4818
from little-cms.
Thanks for both your responses, I'm confident I can control the threading of lcms2 suitably now. Closing the issue.
from little-cms.
Related Issues (20)
- Backwards incompatible API-change in 2.16 HOT 5
- The fast float plugin doesn't premultiply alpha HOT 1
- Plugins lack soversion when configured with meson
- Possible NPD in cmsCreate_OkLabProfile HOT 2
- FTBFS since commit c429e37 wrt type checking on pointer types HOT 2
- ICC profile with CICP tag HOT 14
- Unable to find program in file system after install HOT 4
- Overflow checks in cmsCreateExtendedTransform HOT 1
- CIE XYZ D65 profile HOT 5
- Non-equidistant planes in DoTransformLineStride HOT 1
- cmsCreateTransform returns nullptr in 2.16, but works in 2.15- HOT 6
- The build system seems to have obsolete zlib support HOT 1
- MD5 computation of Profile ID seems to zero wrong header field HOT 1
- Add ability to disable building tests
- cmsDoTransform for 64 bit image size HOT 5
- Feature request: utility function to duplicate colour profiles HOT 2
- Having trouble with `cmsPluginTag` using `cmsSigUInt32ArrayType` as the data type HOT 4
- FTBFS with mingw GCC 14
- gcc11: compilation warning in lcms2.14+ HOT 1
- TIFFTAG_TRANSFERFUNCTION values to cmsBuildTabulatedToneCurve16() HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from little-cms.