summaryrefslogtreecommitdiff
path: root/simulator/opendc-simulator/opendc-simulator-compute/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 11:47:01 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 11:48:57 +0200
commit41ad2f2950550fcd95a599bd8869aa191c88396a (patch)
tree5d9bf52b5b93dddb92ad7e2ea29b0af08147113d /simulator/opendc-simulator/opendc-simulator-compute/src/main
parent2ed3ad44885c93287d4ef9c7996db73f1d49d62d (diff)
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.
Diffstat (limited to 'simulator/opendc-simulator/opendc-simulator-compute/src/main')
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt5
1 files changed, 3 insertions, 2 deletions
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<Fragment>) : 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)