[Insight-developers] how can I verify that my code runs on several processors ?

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Tue Nov 29 10:59:26 EST 2005


Hi Luis,

My code is available at  
http://voxel.jouy.inra.fr/darcs/contrib-itk/histoErodeDilate/perf_threads.cxx
It will not run without the rest of the directory, but it is very simple  
to see what it does: run the same filter with an increasing number of  
threads.

The start() method is called just before the Update() method, and the  
stop() just after the Update(), so I get the wall time, and still don't  
understand why I don't get better performances with several threads :-/

The server runs an linux mandriva le2005 64bits, and I'm using a CVS  
version older than a week.

Gaetan

On Tue, 29 Nov 2005 16:03:35 +0100, Luis Ibanez <luis.ibanez at kitware.com>  
wrote:

>
> Hi Gaetan,
>
> Are you using a very recent CVS version of ITK ?
>
> TimeProbes in Windows previously returned only a time
> with precision of milliseconds, because they used to
> use clock() inside.
>
> Recently (last week) the TimeProbes started using
> the itk::RealTimeClock internally, which should give
> your precision of microseconds. Note that this only
> refers to the resolution of the clock, not its accuracy.
>
> ---
>
> About your question regarding threads, it all depends
> on the place where yuo put the TimeProbe and when you
> invoke its Start() and Stop() methods.
>
> If you created the TimeProbe and Started it before
> spawning the threads, and stopped it after joining
> the threads, then you will get the "wall-time" that
> it took to run the threads. This is *not* the sum
> of time for thread1 + thread2 + thread3... , but
> rather the Max of the time used by each thread.
>
>
>
> It will be useful if you post your code...
>
>
> This will make this conversation less esoteric...
>
>
>
> BTW, What operating system are you using ?
>
>
>
>
> Thanks
>
>
>
>     Luis
>
>
>
> ---------------------
> Gaetan Lehmann wrote:
>>  I'm thinking to something which could explain the result I get: I use   
>> TimeProbe to measure the execution time. TimeProbe give the CPU time  
>> which  is better than the real time, but what is its behavior with  
>> several  processors ? Does is add the time spent on all the processors  
>> used ?
>>  On Tue, 29 Nov 2005 15:26:41 +0100, Gaetan Lehmann   
>> <gaetan.lehmann at jouy.inra.fr> wrote:
>>
>>>
>>> The server contains 4 xeons with hyperthreading activated.
>>> The hyperthreading is a part of my problem: I don't know how I can be   
>>> sure that 2 threads are not running on the same processor. I see 8   
>>> processors, and I don't know how the CPU numbers are given, so I  
>>> can't  be sure my thread are not running on the same real CPU.
>>>
>>> But I'm not sure that the lone problem: I get worst and worst   
>>> performance when I increase the number of threads (up to 4) - it  
>>> seems  very similar to what I get on a single processor system. I  
>>> think I  should get a (small) increase of performance when the number  
>>> of thread  increase
>>>
>>> On Mon, 28 Nov 2005 16:24:52 +0100, Kent Williams   
>>> <norman-k-williams at uiowa.edu> wrote:
>>>
>>>> I don't know what processors your server contains, but it's not  
>>>> always  the case that multithreading increases performance.  Intel  
>>>> HT  processors in particular have problems with too many shared  
>>>> resources  between the computation units.  The following article  
>>>> indicates that  SQL Server and Citrix Terminal Server both perform  
>>>> better with  hyperthreading disabled.
>>>>
>>>> http://news.zdnet.co.uk/0,39020330,39237341,00.htm
>>>>
>>>> I don't know how you can verify that your threads are being spread   
>>>> across different processors on your server -- perhaps someone else  
>>>> here  does.   ITK's threading model generally works very well, but  
>>>> there may  be cases where it does not.  For some cases --  
>>>> particularly short,  simple ITK pipelines -- threading has minimal  
>>>> positive, and possibly  negative impact on performance.
>>>>
>>>> Gaetan Lehmann wrote:
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I'm trying to measure the performances of the filter I'm writing on  
>>>>> a   server with 4 processors. I'm quite surprise to see that using   
>>>>> several  threads seem to decrease the performances, as it do on a  
>>>>> host  with a  single processor.
>>>>> How can I verify that the different threads are running on several    
>>>>> processors ? It's not fully related to ITK, but I hope someone will   
>>>>> be  able to answer that question on this list :-)
>>>>>
>>>>> I'm running my tests on linux.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Gaetan
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>
>



-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr


More information about the Insight-developers mailing list