1

I'm trying to calculate speedup of a code using Amdahl's law and the following are my CPU specs: enter image description here

Amdahl's law:-

Speedup = 1 / 1-p+ (p/n)

where n = number of processors.

According to my specs, it says cores = 4 while logical processors = 8

What should I use as the number of processors in the equation?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
S.Dan
  • 1,826
  • 5
  • 28
  • 55

1 Answers1

2

First of all, let me explain what cores and logical processors stand for in case you do not know. Cores means actual physical processor cores and you have 4 of them in your case. Logical processors on the other hand means, you are using hyper-threading, which means on one physical core, you can run two processes concurrently. You can find additional information in the following link: https://en.wikipedia.org/wiki/Hyper-threading

There are two things to consider in your question. First, Amdahl's law is older than hyper-threading, so the law itself assumes you have physical processors. Secondly, although hyper-threading will increase the performance, there is no way it can double if you are using two logical processors instead of one. Therefore, from the Amdahl's Law point of view, it would be better if you used 4 cores for your calculations.

For example, if 50% of your code can be parallelized,with 4 physical cores, you will have:

Speedup = 1/ ((1-0.5) + (0.5 / 4)) = 1.6

If you used 8 processors you would have:

Speedup = 1/ ((1-0.5) + (0.5 / 8)) = 1.833

However, in the case of using logical cores, you will never reach 1.833. Maybe you can reach 1.7 at most. In the physical cores usage case, you may be able to reach as much as 1.55 due to memory latency and branches. The main thing to remember is that Amdahl's law includes not the number of cores, but the speed-up to the baseline case, therefore, you won't reach to the theoretical number of the calculation.

Note: In research community, for performance calculations and experiments, hyper-threading and logical cores usually do not get included.

parallel highway
  • 354
  • 2
  • 12
  • 1
    You imply this, but it would be good to say that some code is more hyperthreading-friendly than others. For code with long dependency chains and low ILP (and not too big a cache footprint...), running two threads on one physical core might barely slow each other down, so you might get almost as good results as with 8 full cores. But other code barely gets any speedup, because it already keeps a physical core busy without HT. – Peter Cordes Jul 17 '17 at 05:08