Coder Social home page Coder Social logo

Comments (4)

ajeb78 avatar ajeb78 commented on May 28, 2024

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.

mm2 avatar mm2 commented on May 28, 2024

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.

butcherg avatar butcherg commented on May 28, 2024

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.

ajeb78 avatar ajeb78 commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.