Click here to Skip to main content
15,074,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

I've built a multithreading using C++, I get improvement in computation time compared to when the program is run on single thread using Windows XP (duel core and guad core). This is expected.

However, the program runs slower on Windows Server 2003 when multithreaded compared to when the program is run on single thread. This server has 24 cores and I can see that all 24 cores are working.

What u think the problem could be?



I would guess that the communication overhead is becoming a problem, presumably the threads are spending an excessive amount of time communicating and waiting for other threads to complete tasks. Apparently, this doesn't become a problem with a small number of cores but once you hit larger numbers it does. This could be a problem with the maximum granularity it is sensible to try and extract from the problem, i.e. you are splitting the work into too small chunks when running on many cores or could be a problem with how your communication and thread synchronisation scale.

It's hard to come up with a more detailed explanation without more details of what is happening.
Inter-core and IO communication coupled with thread granularity is most likely the issue here, for example accessing data that is currently sat in RAM or on Disc will prove problematic.

This wouldn't show itself on fewer cores where you may have less requirement to fetch data, however on systems with numerous cores with a process that is splitting tasks down in to smaller chucks IO access will increase and you will get no improvement or as in this case see a decline in performance.

You'd be surprised how much of a bottle neck accessing RAM is...
Read this[^] article: it gives detailed informations about what can happen when dealing with multi-threaded applications...
Thanks guys - this certain makes sense! Must say it caught me by surpise :(

I guess the answer is make the set of variables for each thread sits on whole memory blocks.

Looked on the MSDN website which talks about using the "align" function to separate the structs into 64 bit blocks. However seems to be for VS 2010.

How to impliment this in VS 2008?



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900