Hi,
In the ITK 5.0 you’ve added new multithreading approach using the TBB library. Now it’s possible to parallelize work on a pixel level. My question is in following - how can I force TBB splitter to stop on slice level? I’m using my own data structures and I want to run default ITK filters on these data structures. Earlier ITK provides a virtual method SplitRequestedRegion(…) and this was enough for me.
But now almost the same functionality (TBBImageRegionSplitter) is in file Modules/Core/Common/src/itkTBBMultiThreader.cxx under the anonymous namespace and now I cannot control splitting without changing ITK.
Maybe it is possible to pass region splitter as lambda or provide a method to override it in ITK?
I do realize that I can use old parallelization but it will be great to use a new TBB approach.
Currently there is no way for ITK user to modify TBB’s splitting behavior. You are welcome to propose a PR which introduces an API for controlling the region splitting process. If you decide to try that, beware that the default multi-threader can be selected by environment variable, and that it might not be TBBMultiThreader despite that being the default if it is built.
If you can consider splitting your data into N things, then the ParallelizeArray method may be a good fit. N things could be N ImageRegions computed on the fly.
Thanks for the reply! I’ve looked at this function but it didn’t help me because I want to run default ITK filters on my data structures. I can write a new filter using ParallelizeImageRegionRestrictDimension but my goal is to run out of box ITK filters without changing source code.
I don’t think any of the multi-threaders use the Filter’s Splitter any more. It looks like it might be possible to restore it for the PlatformMultiThread and the PoolMultiThreader. Currently the multthreaders just use the global default as opposed to the filters:
DynamicThreadedGenerateData does not use the filter’s splitter. When that is needed, ThreadedGenerateData should be used, as per classic multi-threading model.