ENH: Add SetDefaultNumberOfThreads#149
ENH: Add SetDefaultNumberOfThreads#149thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
Conversation
|
@mrocklin please take a look |
|
From a Python user's perspective I would prefer an API like ... import itk
itk.set_nthreads(4)There are a few other libraries (blosc comes to mind) that do something similar. However, with proper documentation what's here also works. I imagine that the sorts of people who are going to want to change the default number of threads are also going to have a decently high tolerance for writing lots of code. Thank you all for working on this. |
jhlegarreta
left a comment
There was a problem hiding this comment.
Although @mrocklin 's comment seems fair, I guess it is not trivial to implement that under ITK's framework. If you think it is feasible, an issue could be opened in the ITK repository and cross-reference this example.
In the meantime, I think merging the example would help users have a better grasp of the current multi-threading mechanism use.
|
Yeah, that was my guess as to what was happening. Thought I'd mention it anyway. Thanks all! |
|
It should not be hard to implement. A stand-alone function void
set_nthreads(ThreadIdType numberOfThreads)
{
itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(numberOfThreads);
}should be about enough. |
|
While such a function wouldn't make much sense in C++, we could make it available only in Python. Thoughts? |
|
Thanks for the reviews! The CI failures are unrelated, so merging. If there is demand for it, we could add It would look like: |
Addresses: InsightSoftwareConsortium/ITK#113