From f4efc3223e7563fe510e53c62f4527c2d3f5fbb0 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Mon, 10 Oct 2016 16:08:00 +0200 Subject: [PATCH] [ENERGY] Fixed a bug (division of integers) Well, that should've been a division of doubles. I also fixed the tesh tests. --- examples/smpi/energy/energy.tesh | 16 ++++++++-------- examples/smpi/energy/f77/energy.tesh | 16 ++++++++-------- examples/smpi/energy/f90/energy.tesh | 16 ++++++++-------- src/surf/plugins/energy.cpp | 5 +++-- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/examples/smpi/energy/energy.tesh b/examples/smpi/energy/energy.tesh index bf48442687..b54624685a 100644 --- a/examples/smpi/energy/energy.tesh +++ b/examples/smpi/energy/energy.tesh @@ -9,16 +9,16 @@ $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platf > [0.000000] [rank 1] Pstates: 3; Powers: 100000000, 50000000, 20000000 > [0.000000] [rank 0] Current pstate: 0; Current power: 100000000 > [0.000000] [rank 1] Current pstate: 0; Current power: 100000000 -> [10.000000] [rank 0] Energy consumed: 2000 Joules. -> [10.000000] [rank 1] Energy consumed: 2000 Joules. +> [10.000000] [rank 0] Energy consumed: 1200 Joules. +> [10.000000] [rank 1] Energy consumed: 1200 Joules. > [10.000000] [rank 0] Current pstate: 1; Current power: 50000000 > [10.000000] [rank 1] Current pstate: 1; Current power: 50000000 -> [30.000000] [rank 0] Energy consumed: 5400 Joules. -> [30.000000] [rank 1] Energy consumed: 5400 Joules. +> [30.000000] [rank 0] Energy consumed: 3400 Joules. +> [30.000000] [rank 1] Energy consumed: 3400 Joules. > [30.000000] [rank 0] Current pstate: 2; Current power: 20000000 > [30.000000] [rank 1] Current pstate: 2; Current power: 20000000 -> [80.000000] [rank 0] Energy consumed: 12900 Joules. -> [80.000000] [rank 1] Energy consumed: 12900 Joules. -> [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 12900.000000 Joules -> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 12900.000000 Joules +> [80.000000] [rank 0] Energy consumed: 8650 Joules. +> [80.000000] [rank 1] Energy consumed: 8650 Joules. +> [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 8650.000000 Joules +> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 8650.000000 Joules > [80.000000] [surf_energy/INFO] Total energy of host MyHost3: 8000.000000 Joules diff --git a/examples/smpi/energy/f77/energy.tesh b/examples/smpi/energy/f77/energy.tesh index a6668aac82..e6a588faf9 100644 --- a/examples/smpi/energy/f77/energy.tesh +++ b/examples/smpi/energy/f77/energy.tesh @@ -16,16 +16,16 @@ $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platf > [ 0.0000000000000000 ] [rank 1 ] Power: 20000000.000000000 > [ 0.0000000000000000 ] [rank 0 ] Current pstate: 0 ; Current power: 100000000.00000000 > [ 0.0000000000000000 ] [rank 1 ] Current pstate: 0 ; Current power: 100000000.00000000 -> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 2000.0000000000000 -> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 2000.0000000000000 +> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 1200.0000000000000 +> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 1200.0000000000000 > [ 10.000000000000000 ] [rank 0 ] Current pstate: 1 ; Current power: 50000000.000000000 > [ 10.000000000000000 ] [rank 1 ] Current pstate: 1 ; Current power: 50000000.000000000 -> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 5400.0000000000000 -> [ 30.000000000000000 ] [rank 1 ] Energy consumed (Joules): 5400.0000000000000 +> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 3400.0000000000000 +> [ 30.000000000000000 ] [rank 1 ] Energy consumed (Joules): 3400.0000000000000 > [ 30.000000000000000 ] [rank 0 ] Current pstate: 2 ; Current power: 20000000.000000000 > [ 30.000000000000000 ] [rank 1 ] Current pstate: 2 ; Current power: 20000000.000000000 -> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 12900.000000000000 -> [ 80.000000000000000 ] [rank 1 ] Energy consumed (Joules): 12900.000000000000 -> [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 12900.000000 Joules -> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 12900.000000 Joules +> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 8650.0000000000000 +> [ 80.000000000000000 ] [rank 1 ] Energy consumed (Joules): 8650.0000000000000 +> [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 8650.000000 Joules +> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 8650.000000 Joules > [80.000000] [surf_energy/INFO] Total energy of host MyHost3: 8000.000000 Joules diff --git a/examples/smpi/energy/f90/energy.tesh b/examples/smpi/energy/f90/energy.tesh index c66b898ad8..14b02750d5 100644 --- a/examples/smpi/energy/f90/energy.tesh +++ b/examples/smpi/energy/f90/energy.tesh @@ -16,16 +16,16 @@ $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platf > [ 0.0000000000000000 ] [rank 1 ] Power: 20000000.000000000 > [ 0.0000000000000000 ] [rank 0 ] Current pstate: 0 ; Current power: 100000000.00000000 > [ 0.0000000000000000 ] [rank 1 ] Current pstate: 0 ; Current power: 100000000.00000000 -> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 2000.0000000000000 -> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 2000.0000000000000 +> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 1200.0000000000000 +> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 1200.0000000000000 > [ 10.000000000000000 ] [rank 0 ] Current pstate: 1 ; Current power: 50000000.000000000 > [ 10.000000000000000 ] [rank 1 ] Current pstate: 1 ; Current power: 50000000.000000000 -> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 5400.0000000000000 -> [ 30.000000000000000 ] [rank 1 ] Energy consumed (Joules): 5400.0000000000000 +> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 3400.0000000000000 +> [ 30.000000000000000 ] [rank 1 ] Energy consumed (Joules): 3400.0000000000000 > [ 30.000000000000000 ] [rank 0 ] Current pstate: 2 ; Current power: 20000000.000000000 > [ 30.000000000000000 ] [rank 1 ] Current pstate: 2 ; Current power: 20000000.000000000 -> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 12900.000000000000 -> [ 80.000000000000000 ] [rank 1 ] Energy consumed (Joules): 12900.000000000000 -> [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 12900.000000 Joules -> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 12900.000000 Joules +> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 8650.0000000000000 +> [ 80.000000000000000 ] [rank 1 ] Energy consumed (Joules): 8650.0000000000000 +> [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 8650.000000 Joules +> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 8650.000000 Joules > [80.000000] [surf_energy/INFO] Total energy of host MyHost3: 8000.000000 Joules diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 82248cd160..48085230b4 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -166,12 +166,13 @@ double HostEnergy::getCurrentWattsValue(double cpu_load) */ double power_slope; int coreCount = host->coreCount(); + double coreReciprocal = static_cast(1) / static_cast(coreCount); if (coreCount > 1) - power_slope = (max_power - min_power) / (1 - 1 / coreCount); + power_slope = (max_power - min_power) / (1 - coreReciprocal); else power_slope = 0; // Should be 0, since max_power == min_power (in this case) - current_power = min_power + (cpu_load - (1 / coreCount)) * power_slope; + current_power = min_power + (cpu_load - coreReciprocal) * power_slope; } else { /* Our machine is idle, take the dedicated value! */ current_power = range.idle; -- 2.20.1