[lug] q: multithreading on smp weirdness.

karheng at softhome.net karheng at softhome.net
Mon Nov 29 19:33:13 MST 2004


greetings. 

i've got a test case with 2 threads
processing several chunks of data.
thread 1 processes chunk 1. once done,
it's relayed to thread 2. thread 1
now processes chunk 2 & thread 2 processes
chunk 1. this goes on until all chunks
are processed. 

my problem is, if i tweak the chunk size
to a size that is too small, elapse time
suddenly doubles. 

when done in single threading mode, it
takes 12 secs to complete.
when done via 2 threads, it takes 6 secs
to complete.
but with 2 threads, once the chunk sizes
get small enough, the prog takes 12 secs
to complete. 

more specifically:
(chunk size * iteration count always == 6000)
chunk size of 12 units, 500 iterations - 6+ secs
chunk size of 10 units, 600 iterations - 6+ secs
chunk size of 8 units, 750 iterations - 6++ secs
chunk size of 6 units, 1000 iterations - 6++ secs
chunk size of 5 units, 1200 iterations - 6+++ secs half the time & 11+ secs 
half the time
chunk size of 4 units, 1500 iterations - 11+ secs
chunk size of 3 units, 2000 iterations - 11+ secs
chunk size of 2 units, 3000 iterations - 11++ secs
chunk size of 1 unit, 6000 iterations - 12+ secs 

i'm running this on a 4 CPU itanium
linux server (redhat as 2.1). 

anyone might have a clue what's wrong?
thanks in advance.. 

rgds, 

kh 



More information about the LUG mailing list