[Insight-users] Multithreading Custom Filters

Luis Ibanez luis.ibanez@kitware.com
Sat May 15 05:19:17 EDT 2004


Hi Jayme,


1) Yes, you are right, you must implement the method
    "ThreadedGenerateData()".  You may also take advantage
    of the methods: BeforeGenerateData() and AfterGenerateDatat()
    but you are not forced to overload them.  They are usually
    useful for preparing the division of the task in threads,
    and for consolidating the results once the threads are done.


2) The regions to be processed are split at the level of the
    ImageSource class, in the method SplitRequestedRegion().
    This method is called from the ThreaderCallback() method in
    ProcessObject. You will find the code in

        Insight/Code/Common/itkImageSource.cxx

    By default it attempts to partition the data among the
    number of threads that are available.


3) You can use the SetNumberOfThreads() methods in order to
    "request" a certain number of threads. This is just a
    request and doesn't have to be fulfilled by the run time
    system.



Regards,


   Luis


-------------------
Jayme Kosior wrote:

> Hello.
> 
> I am starting to experiment with creating my own custom filters and I 
> have a question regarding multithreaded filters in ITK.
> 
> 1. As I understand it, if it is possible to thread the filter's task, 
> then the developer only needs to override the *ThreadedGenerateData()* 
> method and provide the filter's implementation. Then, the *ImageSource* 
> base class takes care of breaking the image up into multiple regions 
> that can be processed in separate threads. Is my understanding correct?
> 
> If this is how it works, what scheme does the *MultiThreader* class use 
> to decide how to partition the image into regions? For example, does it 
> look at how many processors are on the system? The complexity of the 
> operation? etc.
> 
> 2. There is a method in the base class *ProcessObject* called 
> *SetNumberOfThreads()*. Should developers use this method? Or does the 
> ITK multithreading framework use this method to implement the above scheme.
> 
> Thank you for time.
> 
> Jayme






More information about the Insight-users mailing list