summaryrefslogtreecommitdiff
path: root/simulator/opendc-simulator
diff options
context:
space:
mode:
authorHongyu <39747921+HongyuHe@users.noreply.github.com>2021-04-12 10:20:04 +0200
committerGitHub <noreply@github.com>2021-04-12 10:20:04 +0200
commitd08c3a340dee64bfb2925e5f8b59a1193dc2dbcd (patch)
tree4a99e111efe545aa033bc6e35fe08f4f4fcdc630 /simulator/opendc-simulator
parent3820ac4d31d6eb04034b85a1b53667d64ce6ba89 (diff)
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.
Diffstat (limited to 'simulator/opendc-simulator')
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt31
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt10
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt10
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt10
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt10
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt2
6 files changed, 53 insertions, 20 deletions
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),
)
}
}