Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would a multithreaded program be more energy efficient?

In its Energy-Efficient Software Guidelines Intel suggests that programs are designed multithreaded for better energy efficiency.

I don't get it. Suppose I have a quad core processor that can switch off unused cores. Suppose my code is perfectly parallelizeable (synchronization overhead is negligible).

If I use only one core I burn one core for one hour, if I use four cores I burn four cores for 15 minutes - the same amount of core-hours either way. Where's the saving?

like image 735
sharptooth Avatar asked Aug 03 '11 11:08

sharptooth


2 Answers

I suspect it has to do with a non-linear relation between CPU utilization and power consumption. So if you can spread 100% CPU utilization over 4 CPUs each will have 25% utilization - and say 12% consumption.

This is especially true when dynamic CPU scaling is used according to Wikipedia the power drain of a CPU is P = C(V^2)F. When a CPU is running faster it requires higher voltages - and that 'to the power of 2' becomes crucial. Furthermore the voltage will be a function of F (which means F can be solved for V) giving something like P = C(F^2)F. Thus by spreading the load over 4 CPUs (running at 100% capacity at that frequency) you can mitigate the cost for the same work.

We can make F a function of L (load) at 100% of one core (as it would be in your OS), so:

F = 1000 + L/100 * 500 = 1000 + 5L
p = C((1000 + 5L)^2)(1000 + 5L) = C(1000 + 5L)^3

Now that we can relate load (L) to the power consumption we can see the characteristics of the power consumption given everything on one core:

p = C(1000 + 5L)^3
p = 1000000000 + 15000000L + 75000L^2 + 125L^3

Or spread over 4 cores:

p = 4C(1000 + (5/4)L)^3
p = 4000000000 + 15000000L + 18750.4L^2 + 7.5L^3

Notice the factors in front of the L^2 and L^3.

like image 191
Jonathan Dickinson Avatar answered Nov 10 '22 11:11

Jonathan Dickinson


During that one hour, the one core isn't the only thing you keep running.

like image 22
Marcelo Cantos Avatar answered Nov 10 '22 11:11

Marcelo Cantos