From d08c3a340dee64bfb2925e5f8b59a1193dc2dbcd Mon Sep 17 00:00:00 2001 From: Hongyu <39747921+HongyuHe@users.noreply.github.com> Date: Mon, 12 Apr 2021 10:20:04 +0200 Subject: simulator: Add the asymptotic power model from GreenCloud (#114) This change adds the asymptotic power model that is used in GreenCloud to the available power models in OpenDC. --- .../compute/power/AsymptoticPowerModel.kt | 31 ++++++++++++++++++++++ .../simulator/compute/power/CubicPowerModel.kt | 10 +++---- .../simulator/compute/power/LinearPowerModel.kt | 10 +++---- .../simulator/compute/power/SqrtPowerModel.kt | 10 +++---- .../simulator/compute/power/SquarePowerModel.kt | 10 +++---- .../simulator/compute/power/PowerModelTest.kt | 2 ++ 6 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt (limited to 'simulator/opendc-simulator') diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt new file mode 100644 index 00000000..fc08891d --- /dev/null +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt @@ -0,0 +1,31 @@ +package org.opendc.simulator.compute.power + +import kotlin.math.E +import kotlin.math.pow + +/** + * The asymptotic power model partially adapted from GreenCloud. + * + * @param maxPower The maximum power draw of the server in W. + * @param staticPower The power draw of the server in halting state in W. + * @param asymUtil A utilization level at which the server attains asymptotic, + * i.e., close to linear power consumption versus the offered load. + * For most of the CPUs,a is in [0.2, 0.5]. + * @param isDvfsEnabled A flag indicates whether DVFS is enabled. + */ +public class AsymptoticPowerModel( + private val maxPower: Double, + private val staticPower: Double, + private val asymUtil: Double, + private val isDvfsEnabled: Boolean, +) : PowerModel { + private val factor: Double = (maxPower - staticPower) / 100 + + public override fun computePower(utilization: Double): Double = + if (isDvfsEnabled) + staticPower + (factor * 100) / 2 * (1 + utilization.pow(3) - E.pow(-utilization.pow(3) / asymUtil)) + else + staticPower + (factor * 100) / 2 * (1 + utilization - E.pow(-utilization / asymUtil)) + + override fun toString(): String = "AsymptoticPowerModel[max=$maxPower,static=$staticPower,asymptotic=$asymUtil]" +} diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt index 48edace6..1fff01f9 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt @@ -6,14 +6,14 @@ import kotlin.math.pow * The cubic power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param idlePower The power draw of the server in idle state in W. + * @param staticPower The power draw of the server in halting state in W. */ -public class CubicPowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { - private val factor: Double = (maxPower - idlePower) / 100.0.pow(3) +public class CubicPowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { + private val factor: Double = (maxPower - staticPower) / 100.0.pow(3) public override fun computePower(utilization: Double): Double { - return idlePower + factor * (utilization * 100).pow(3) + return staticPower + factor * (utilization * 100).pow(3) } - override fun toString(): String = "CubicPowerModel[max=$maxPower,idle=$idlePower]" + override fun toString(): String = "CubicPowerModel[max=$maxPower,static=$staticPower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt index 1a0cc07b..9ccf734b 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt @@ -4,17 +4,17 @@ package org.opendc.simulator.compute.power * The linear power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param idlePower The power draw of the server in idle state in W. + * @param staticPower The power draw of the server in halting state in W. */ -public class LinearPowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { +public class LinearPowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { /** * The linear interpolation factor of the model. */ - private val factor: Double = (maxPower - idlePower) / 100 + private val factor: Double = (maxPower - staticPower) / 100 public override fun computePower(utilization: Double): Double { - return idlePower + factor * utilization * 100 + return staticPower + factor * utilization * 100 } - override fun toString(): String = "LinearPowerModel[max=$maxPower,idle=$idlePower]" + override fun toString(): String = "LinearPowerModel[max=$maxPower,static=$staticPower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt index da40ca85..a4732e68 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt @@ -6,14 +6,14 @@ import kotlin.math.sqrt * The square root power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param idlePower The power draw of the server in idle state in W. + * @param staticPower The power draw of the server in halting state in W. */ -public class SqrtPowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { - private val factor: Double = (maxPower - idlePower) / sqrt(100.0) +public class SqrtPowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { + private val factor: Double = (maxPower - staticPower) / sqrt(100.0) override fun computePower(utilization: Double): Double { - return idlePower + factor * sqrt(utilization * 100) + return staticPower + factor * sqrt(utilization * 100) } - override fun toString(): String = "SqrtPowerModel[max=$maxPower,idle=$idlePower]" + override fun toString(): String = "SqrtPowerModel[max=$maxPower,static=$staticPower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt index 4f914ddf..eb78eebc 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt @@ -6,14 +6,14 @@ import kotlin.math.pow * The square power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param idlePower The power draw of the server in idle state in W. + * @param staticPower The power draw of the server in halting state in W. */ -public class SquarePowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { - private val factor: Double = (maxPower - idlePower) / 100.0.pow(2) +public class SquarePowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { + private val factor: Double = (maxPower - staticPower) / 100.0.pow(2) override fun computePower(utilization: Double): Double { - return idlePower + factor * (utilization * 100).pow(2) + return staticPower + factor * (utilization * 100).pow(2) } - override fun toString(): String = "SquarePowerModel[max=$maxPower,idle=$idlePower]" + override fun toString(): String = "SquarePowerModel[max=$maxPower,static=$staticPower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt index 439be274..60af0eb0 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt @@ -62,6 +62,8 @@ internal class PowerModelTest { Arguments.of(SquarePowerModel(350.0, 200.0), 321.5), Arguments.of(CubicPowerModel(350.0, 200.0), 309.35), Arguments.of(SqrtPowerModel(350.0, 200.0), 342.302), + Arguments.of(AsymptoticPowerModel(350.0, 200.0, 0.3, false), 338.765), + Arguments.of(AsymptoticPowerModel(350.0, 200.0, 0.3, true), 323.072), ) } } -- cgit v1.2.3