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)
- An heap overflow found in cmsStageAllocMatrix by fuzzing. HOT 1
- A potential off-by-one overflow in cmsIT8SaveToMem HOT 1
- Pack/Unroll for the common formats are not implemented HOT 5
- `meson test` doesn't run test suite like `make check` did in autotools build HOT 3
- CI: Set minimal permissions to your GitHub Workflows HOT 6
- 2.15: build fails because missing `sqrt()` detection HOT 4
- [IT8] Out-of-bound array access on WriteDataFormat HOT 3
- [IT8] Out-of-bound array access in CookPointers HOT 1
- Fast float plugin clamps values to [0,1] HOT 1
- Vector and matrix documentation fixes, and about curves HOT 17
- Support for Oklab/Oklch? HOT 18
- 2.15: failure to build fastfloat plugin on mingw64 HOT 2
- Create Security Policy
- threading plugin feature request: allow to replace the threading backend HOT 2
- fast float: compiler warning about misleading indentation HOT 2
- Fast float plugin causes incorrect results in sRGB to XYZ transform
- Ship separate pkgconf files for plugins HOT 4
- Suggest Adoption of Scorecard GitHub Action HOT 7
- Different results depending on endianess HOT 5
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.