0

My program: 100% CPU and RAM based, performs mathematical calculations, reads the data from the HDD into RAM in the beginning. No communication between threads. The threads, all take the same time also (almost).

Question:

If my program uses threads equal to the number of CPU threads, what kind of performance can I expect from a 2 cpu system?

Say I use two 8 core xeons, each with 16 threads, so 16x2 = 32 threads total. If my program uses 32 threads, all with 100% usage, will I get double the preformance over a single same cpu?

3
  • You're going to have to be more specific about what you're attempting to parallelize if you want an answer to this question. Dec 5, 2013 at 3:03
  • 1
    More details added. Dec 5, 2013 at 3:07
  • With a shared memory you're never going to get 100% out of the second, third, fourth... CPU, except in very rare circumstances. Early dual processor systems were lucky to get 50% added throughput from a second CPU (though that's improved as cache designs have gotten better). You do have an "advantage" in this case in that the throughput has already been "discounted" for multiple cores, so the "hit" might not be too bad. However, the 8-core design is likely "tuned" to make full use of memory bandwidth, so the system could "choke" with two units. Dec 16, 2013 at 12:46

3 Answers 3

3

Really, the best answer you can give is "probably not, but it depends". You have twice the raw CPU horsepower available, but:

  1. You won't really have twice the usable memory bandwidth.

  2. It will take time to "ping pong" some cache lines between CPUs.

  3. Sometimes one thread will have to wait for another and the more threads you have, the more that happens.

  4. Sometimes, even though you have a lot of work to do, you can't do it all at once.

And so on.

In very rare cases, you can actually get more than twice the performance. If an operation is cache limited, having more cores may mean the thread can run for longer (because the core won't have other things to do because the other cores are doing them), allowing the CPU caches to stay hot for longer.

2
  • So, given the updated info, what's your guess regarding the performance improvement? Dec 5, 2013 at 3:14
  • Given the updated info, I'd say most likely yes, though you may have to make some adjustments to your program to avoid things like false sharing or implicit synchronization due to things like changing the process memory map. It may "just work", but it may take someone who understands these issues to "tweak" the code to make it work. Dec 5, 2013 at 3:18
0

The ultimate answer to performance questions is don't guess it, test it!

9
  • Cool, but how to test if I don't have the system? Dec 5, 2013 at 3:16
  • 2
    There are any number of ways you can "borrow" a system and change its configuration. Amazon's EC2 service, for example, is the most obvious. Dec 5, 2013 at 3:22
  • @ShadowHero A more practical question would be what if you get the system based on a guess and find out there is no gain
    – jwalker
    Dec 5, 2013 at 3:24
  • The bad thing is, those xeon are expensive... :/ Dec 5, 2013 at 3:32
  • @ShadowHero That's exactly why you shouldn't want to guess
    – jwalker
    Dec 5, 2013 at 4:57
0

It sounds like you're working on an embarrassingly parallel computing task, in which case the answer is yes, your throughput will scale nearly linearly with the total CPU threads used.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .