# Energy
86 kJ is about how much energy it takes to heat the water for one cup of tea.
# 1 Measurement
On Debian Linux, the turbostat
tool
from the package linux-cpupower
can measure energy consumption of the CPU
while a program is running.
This is not quite the same as the energy consumption of the program,
so take background measurements (for example, of the sleep
command),
and the computer has things other than the CPU package using power,
so take with salt.
# 2 Parallelism Example
Calculating the Mandelbrot set using subdivision data structures up to level 17, on AMD 2700X CPU.
Background measurement: 30 W
Bit-packed quad-tree: 45 W, 1 thread, 41m07s wall-clock, 41m07s cpu time
Vector of bitmaps: 120 W, 16 threads, 3m35s wall-clock, 55m29s cpu time
Comparing CPU time: vector of bitmaps is 35% less efficient vs perfect parallelism
Comparing energy: 45 W × 41m07s = 111 kJ ; 120 W × 3m35s = 25.8 kJ; i.e. the imperfect parallelism is 4.3× more energy efficient than single threadeed.
Taking off background measurement (e.g. if the computer is on all the time in any case): (45 W - 30 W) × 41m07s = 37 kJ ; (120 W - 30 W) × 3m35s = 19.4 kJ; i.e. the imperfect parallelism is 1.9× more energy efficient than single threaded.
In summary, power consumption is not linear with load: idle uses 30 W, 1 thread adds 15 W, but 16 threads adds only 5.6 W per thread.
Better to get in and out as quickly as possible (even if parallelism isn’t perfect) so the machine can be idle or powered off.