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') 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