From eff68d2f292f1c614b49af56fbe35b0ca322a578 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 8 Apr 2021 10:11:56 +0200 Subject: simulator: Perform usage propagation only on change This change updates the logic in SimAbstractMachine to only propagate usages when the value has changed. --- .../kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'simulator/opendc-simulator/opendc-simulator-compute') diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt index 1f26c9c9..252a40ec 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt @@ -101,11 +101,17 @@ public abstract class SimAbstractMachine(private val clock: Clock) : SimMachine for ((cpu, source) in resources) { val consumer = workload.getConsumer(ctx, cpu) val adapter = SimSpeedConsumerAdapter(consumer) { newSpeed -> + val _speed = _speed + val _usage = _usage + val oldSpeed = _speed[cpu.id] _speed[cpu.id] = newSpeed totalSpeed = totalSpeed - oldSpeed + newSpeed - updateUsage(totalSpeed / totalCapacity) + val newUsage = totalSpeed / totalCapacity + if (_usage.value != newUsage) { + updateUsage(totalSpeed / totalCapacity) + } } launch { source.consume(adapter) } -- cgit v1.2.3 From 41ad2f2950550fcd95a599bd8869aa191c88396a Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 8 Apr 2021 11:47:01 +0200 Subject: simulator: Divide CPU usage over all cores This change fixes an issue in SimTraceWorkload where the CPU usage was not divided across the cores, but was instead requested for all cores. --- .../kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'simulator/opendc-simulator/opendc-simulator-compute') diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt index 2442d748..694a928b 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt @@ -50,14 +50,15 @@ public class SimTraceWorkload(public val trace: Sequence) : SimWorkloa override fun onNext(ctx: SimResourceContext): SimResourceCommand { val now = ctx.clock.millis() val fragment = fragment ?: return SimResourceCommand.Exit - val work = (fragment.duration / 1000) * fragment.usage + val usage = fragment.usage / fragment.cores + val work = (fragment.duration / 1000) * usage val deadline = offset + fragment.duration assert(deadline >= now) { "Deadline already passed" } val cmd = if (cpu.id < fragment.cores && work > 0.0) - SimResourceCommand.Consume(work, fragment.usage, deadline) + SimResourceCommand.Consume(work, usage, deadline) else SimResourceCommand.Idle(deadline) -- cgit v1.2.3 From 638dd7a33d5f7f0b8fcca9c99cdc92819cf0847c Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 30 Mar 2021 22:42:41 +0200 Subject: exp: Add experiment for OpenDC Energy project This change adds an experiment for the OpenDC Energy project, which tests various energy models that have been implemented in OpenDC. --- .../compute/power/InterpolationPowerModel.kt | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'simulator/opendc-simulator/opendc-simulator-compute') diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt index 85613a57..cbfcd810 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt @@ -10,15 +10,12 @@ import kotlin.math.min * The linear interpolation power model partially adapted from CloudSim. * This model is developed to adopt the SPECpower benchmark. * - * @param hardwareName The name of the hardware vendor. + * @param powerValues A [List] of average active power measured by the power analyzer(s) and accumulated by the + * PTDaemon (Power and Temperature Daemon) for this measurement interval, displayed as watts (W). * @see Machines used in the SPEC benchmark */ -public class InterpolationPowerModel(hardwareName: String) : PowerModel { - /** - * A [List] of average active power measured by the power analyzer(s) and accumulated by the - * PTDaemon (Power and Temperature Daemon) for this measurement interval, displayed as watts (W). - */ - private val averagePowerValues: List = loadAveragePowerValue(hardwareName) +public class InterpolationPowerModel(private val powerValues: List) : PowerModel { + public constructor(hardwareName: String) : this(loadAveragePowerValue(hardwareName)) public override fun computePower(utilization: Double): Double { val clampedUtilization = min(1.0, max(0.0, utilization)) @@ -34,7 +31,7 @@ public class InterpolationPowerModel(hardwareName: String) : PowerModel { powerFlr + delta * (clampedUtilization - utilizationFlr.toDouble() / 10) * 100 } - override fun toString(): String = "InterpolationPowerModel[entries=${averagePowerValues.size}]" + override fun toString(): String = "InterpolationPowerModel[entries=${powerValues.size}]" /** * Gets the power consumption for a given utilization percentage. @@ -43,13 +40,15 @@ public class InterpolationPowerModel(hardwareName: String) : PowerModel { * where 10 means 100% of utilization. * @return the power consumption for the given utilization percentage */ - private fun getAveragePowerValue(index: Int): Double = averagePowerValues[index] + private fun getAveragePowerValue(index: Int): Double = powerValues[index] - private fun loadAveragePowerValue(hardwareName: String, path: String = "spec_machines.yml"): List { - val content = this::class - .java.classLoader - .getResourceAsStream(path) - val hardwareToAveragePowerValues: Map> = Yaml().load(content) - return hardwareToAveragePowerValues.getOrDefault(hardwareName, listOf()) + private companion object { + private fun loadAveragePowerValue(hardwareName: String, path: String = "spec_machines.yml"): List { + val content = this::class + .java.classLoader + .getResourceAsStream(path) + val hardwareToAveragePowerValues: Map> = Yaml().load(content) + return hardwareToAveragePowerValues.getOrDefault(hardwareName, listOf()) + } } } -- cgit v1.2.3