[vtkusers] vtkMultiThreader question

Chauvin, Laurent,Ph.D. lchauvin at bwh.harvard.edu
Fri Oct 9 18:22:35 EDT 2015


Thank you for your answer.

I actually looked at it, but I’m still not sure what happen in this example.
Is each function run in one separated thread, or each function run in multiple threads ?

Here is what I have:

myMethod(void* arg)
{
For loop
              For loop
                    Computation()
}

And then I use vtkMultiThreader to execute this method like this:

Threader->SetSingleMethod(myMethod,NULL);
Threader->SingleMethodExecute()

What I was expecting was that thread detect the function could be split in multiple thread (because of the loops) and run each iteration of Computation() in a different thread.

But I think I got it wrong. I think I have to do something like that:

For Loop
     For Loop
         Threader->SetSingleMethod(myMethod,data[i][j])
         Threader->SingleMethodExecute()

Is it correct ?

Thank you.
-Laurent

From: Dan Lipsa <dan.lipsa at kitware.com<mailto:dan.lipsa at kitware.com>>
Date: Friday, October 9, 2015 at 11:18 PM
To: "Chauvin, Laurent,Ph.D." <lchauvin at bwh.harvard.edu<mailto:lchauvin at bwh.harvard.edu>>
Cc: Franz Neubert via vtkusers <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: Re: [vtkusers] vtkMultiThreader question

Laurent,
Did you look at the tests that come with this class. Do they work?

http://www.vtk.org/doc/nightly/html/c2_vtk_t_12.html#c2_vtk_t_vtkMultiThreader

Dan


On Fri, Oct 9, 2015 at 5:00 PM, Chauvin, Laurent,Ph.D. <lchauvin at bwh.harvard.edu<mailto:lchauvin at bwh.harvard.edu>> wrote:
Hello,

I’m trying to use a vtkMultiThreader to compute several thing in parallel.
However I’m not sure how it works.

Here is what I did.
I created a single method that calculate some metric pairwise. So I have 2 for loops in this method.
What I want to do, is to have one thread per iteration (kind of), so I can calculate all metrics simultaneously.

So I created a vtkMultiThreader and set the single method, which contains the loops, and executed it. However when I do that, I can only see one core working. I thought SingleMethod was using multiple thread to run this method. Is it true ? Why then it is not using all my other cores ?

Should I put the loops out of the single method then, and spawn a thread for each iteration, with different data as input ?

Thank you very much.
-Laurent

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151009/625d83c5/attachment.html>


More information about the vtkusers mailing list