[Insight-users] Problem with multi-threaded metric computation

Miller, James V (Research) millerjv at crd.ge.com
Fri Aug 12 14:14:56 EDT 2005


Florence, 

What is that you want to do?  Do you want to have a multithreaded metric?
Or do you want run multiple registrations in different threads?

It is not too difficult to create a multithreaded metric.  The 
MatchCardinalityImageToImageMetric is multithreaded.  This means when GetValue()
is called, it divides the problem into multiple sections, spawns a thread
for each section, and then recombines the results to build the final 
value returned to the optimizer.  Is this what you want?

Jim	



-----Original Message-----
From: Florence Dru [mailto:fdru at imaging.robarts.ca]
Sent: Friday, August 12, 2005 1:05 PM
To: Miller, James V (Research)
Subject: Re: [Insight-users] Problem with multi-threaded metric
computation


Thank you for replying but I would have one more question :
How can I create different cost function object within my optimizer 
class since the cost function object is assigned from outside by the 
ImageRegistrationMethod object ?
Could you give me an example of the code? Thanks beforehand.

Florence DRU

Miller, James V (Research) wrote:

>The cost functions are not guarenteed to be thread safe. By this I mean
>that you cannot assume that you can share a cost function across
>multiple threads and be able to make calls to the cost function
>from each thread.
>
>What you can do is create an array of cost functions and use one
>per thread (or just create a cost function in each thread that needs
>one).
>
>Jim
>
>-----Original Message-----
>From: insight-users-bounces+millerjv=crd.ge.com at itk.org
>[mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of
>Florence Dru
>Sent: Friday, August 12, 2005 11:34 AM
>To: insight-users at itk.org
>Subject: [Insight-users] Problem with multi-threaded metric computation
>
>
>Hello,
>here is my problem: I have parallelized a part of my program that calls 
>the "GetValue()" function of my cost function object.
>I used the itkMultiThreader class to do this.
>But the problem is that when I use more than 1 thread, when the cost 
>function object is evaluated a one point the returned values are 
>completely incorrect ( in the order of 200 instead of the usual order of 
>0.3) and I was wondering whether it could come from the different 
>threads that access the same object at the same time, messing up everything.
>Could someone help me ?
>Thanks beforehand for replying.
>
>Florence DRU
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>  
>



More information about the Insight-users mailing list