Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Use application provided ThreadPool #1763

Open
MrKepzie opened this issue Sep 8, 2017 · 2 comments
Open

[Enhancement] Use application provided ThreadPool #1763

MrKepzie opened this issue Sep 8, 2017 · 2 comments

Comments

@MrKepzie
Copy link
Contributor

MrKepzie commented Sep 8, 2017

When an external application already has its own threading technology (be it a thread-pool or w/e), it is hard to wire it to OpenImageIO's own thread-pool.

If we enable multi-threading with the oiio threadpool we get overthreading because a threadpool is a centralized way of managing threads workload.

If we disable multi-threading for OIIO using oiio-threads, we then get no multi-threading for things like parallel_convert_image.

OIIO being a library, it should be able to operate with another application's thread-pool, so that we get the best performance possible out of OIIO.

I tried to hack around and modify the thread-pool API so it could be inherited by the application and we could replace the default thread-pool by forwarding calls to our own threading mechanism, but the API of the thread-pool being complicated with templated functors makes it impossible to achieve.
The other way around would be to use OIIO's thread-pool as main threading backend of the application but we do not want that as there is better suited threading technologies available.

I did the same with OpenEXR's thread-pool and it works well because their thread-pool API is essentially very simple with just a "addTask" function and their simple Task and TaskGroup classes.

@el3ment
Copy link

el3ment commented Mar 11, 2020

is it possible to disable threading from the python bindings?

@lgritz
Copy link
Collaborator

lgritz commented Mar 12, 2020

Yes:

import OpenImageIO as oiio
oiio.attribute("threads", 1)

should set the default thread pool size to 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants