summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-08 22:02:07 +0200
committerGitHub <noreply@github.com>2021-10-08 22:02:07 +0200
commitb7a71e5b4aa77b41ef41deec2ace42b67a5a13a7 (patch)
treeb88bbede15108c6855d7f94ded4c7054df186a72 /opendc-simulator/opendc-simulator-compute
parent3098eeb116a80ce12e6575e454d0448867478792 (diff)
parente2f002358e9d5be2239fa2cb7ca92c9c96a21b6f (diff)
merge: Performance improvements for flow engine
This pull request applies multiple performance improvements for the flow engine and compute simulator. * Optimize SimTraceWorkload (by storing fragments using several arrays) * Skip fair-share algorithm if capacity remaining * Count interference for multiplexer inputs * Simplify FlowSink implementation * Do not update outputs if rate is unchanged * Eliminate ArrayList iteration overhead * Optimize clock storage * Specialize FlowEngine queues * Eliminate clock access in hot path **Breaking API Changes** * `SimTraceWorkload` now accepts a `SimTrace` as parameter. This trace can be constructed using fragments or directly using builder class. Internally, the trace is now stored using several arrays.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt13
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt90
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTrace.kt233
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceFragment.kt38
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt83
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt52
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt14
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt40
8 files changed, 385 insertions, 178 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
index b8e0227a..cb52d24f 100644
--- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
@@ -22,7 +22,6 @@
package org.opendc.simulator.compute
-import javafx.application.Application.launch
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
@@ -34,6 +33,7 @@ import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.power.SimplePowerDriver
+import org.opendc.simulator.compute.workload.SimTrace
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
@@ -48,7 +48,7 @@ import java.util.concurrent.TimeUnit
@OptIn(ExperimentalCoroutinesApi::class)
class SimMachineBenchmarks {
private lateinit var machineModel: MachineModel
- private lateinit var trace: Sequence<SimTraceWorkload.Fragment>
+ private lateinit var trace: SimTrace
@Setup
fun setUp() {
@@ -60,8 +60,13 @@ class SimMachineBenchmarks {
)
val random = ThreadLocalRandom.current()
- val entries = List(10000) { SimTraceWorkload.Fragment(it * 1000L, 1000, random.nextDouble(0.0, 4500.0), 1) }
- trace = entries.asSequence()
+ val builder = SimTrace.builder()
+ repeat(10000) {
+ val timestamp = it.toLong()
+ val deadline = timestamp + 1000
+ builder.add(timestamp, deadline, random.nextDouble(0.0, 4500.0), 1)
+ }
+ trace = builder.build()
}
@Benchmark
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt
index aac8b959..f6d8f628 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt
@@ -66,45 +66,7 @@ public abstract class SimAbstractHypervisor(
*/
public override val counters: SimHypervisorCounters
get() = _counters
- private val _counters = object : SimHypervisorCounters {
- @JvmField var d = 1.0 // Number of CPUs divided by total CPU capacity
-
- override var cpuActiveTime: Long = 0L
- override var cpuIdleTime: Long = 0L
- override var cpuStealTime: Long = 0L
- override var cpuLostTime: Long = 0L
-
- private var _previousDemand = 0.0
- private var _previousActual = 0.0
- private var _previousRemaining = 0.0
- private var _previousInterference = 0.0
-
- /**
- * Record the CPU time of the hypervisor.
- */
- fun record() {
- val counters = mux.counters
- val demand = counters.demand
- val actual = counters.actual
- val remaining = counters.remaining
- val interference = counters.interference
-
- val demandDelta = demand - _previousDemand
- val actualDelta = actual - _previousActual
- val remainingDelta = remaining - _previousRemaining
- val interferenceDelta = interference - _previousInterference
-
- _previousDemand = demand
- _previousActual = actual
- _previousRemaining = remaining
- _previousInterference = interference
-
- cpuActiveTime += (actualDelta * d).roundToLong()
- cpuIdleTime += (remainingDelta * d).roundToLong()
- cpuStealTime += ((demandDelta - actualDelta) * d).roundToLong()
- cpuLostTime += (interferenceDelta * d).roundToLong()
- }
- }
+ private val _counters = CountersImpl(this)
/**
* The CPU capacity of the hypervisor in MHz.
@@ -204,7 +166,7 @@ public abstract class SimAbstractHypervisor(
get() = (cpus.sumOf { it.counters.actual + it.counters.remaining } * d).roundToLong()
override val cpuStealTime: Long
get() = (cpus.sumOf { it.counters.demand - it.counters.actual } * d).roundToLong()
- override val cpuLostTime: Long = 0L
+ override val cpuLostTime: Long = (cpus.sumOf { it.counters.interference } * d).roundToLong()
}
/**
@@ -277,4 +239,52 @@ public abstract class SimAbstractHypervisor(
override val min: Double = 0.0
}
+
+ /**
+ * Implementation of [SimHypervisorCounters].
+ */
+ private class CountersImpl(private val hv: SimAbstractHypervisor) : SimHypervisorCounters {
+ @JvmField var d = 1.0 // Number of CPUs divided by total CPU capacity
+
+ override val cpuActiveTime: Long
+ get() = _cpuTime[0]
+ override val cpuIdleTime: Long
+ get() = _cpuTime[1]
+ override val cpuStealTime: Long
+ get() = _cpuTime[2]
+ override val cpuLostTime: Long
+ get() = _cpuTime[3]
+
+ private val _cpuTime = LongArray(4)
+ private val _previous = DoubleArray(4)
+
+ /**
+ * Record the CPU time of the hypervisor.
+ */
+ fun record() {
+ val cpuTime = _cpuTime
+ val previous = _previous
+ val counters = hv.mux.counters
+
+ val demand = counters.demand
+ val actual = counters.actual
+ val remaining = counters.remaining
+ val interference = counters.interference
+
+ val demandDelta = demand - previous[0]
+ val actualDelta = actual - previous[1]
+ val remainingDelta = remaining - previous[2]
+ val interferenceDelta = interference - previous[3]
+
+ previous[0] = demand
+ previous[1] = actual
+ previous[2] = remaining
+ previous[3] = interference
+
+ cpuTime[0] += (actualDelta * d).roundToLong()
+ cpuTime[1] += (remainingDelta * d).roundToLong()
+ cpuTime[2] += ((demandDelta - actualDelta) * d).roundToLong()
+ cpuTime[3] += (interferenceDelta * d).roundToLong()
+ }
+ }
}
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTrace.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTrace.kt
new file mode 100644
index 00000000..4f567b55
--- /dev/null
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTrace.kt
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.simulator.compute.workload
+
+import org.opendc.simulator.compute.model.ProcessingUnit
+import org.opendc.simulator.flow.FlowConnection
+import org.opendc.simulator.flow.FlowSource
+import kotlin.math.min
+
+/**
+ * A workload trace that describes the resource utilization over time in a collection of [SimTraceFragment]s.
+ *
+ * @param usageCol The column containing the CPU usage of each fragment (in MHz).
+ * @param timestampCol The column containing the starting timestamp for each fragment (in epoch millis).
+ * @param deadlineCol The column containing the ending timestamp for each fragment (in epoch millis).
+ * @param coresCol The column containing the utilized cores.
+ * @param size The number of fragments in the trace.
+ */
+public class SimTrace(
+ private val usageCol: DoubleArray,
+ private val timestampCol: LongArray,
+ private val deadlineCol: LongArray,
+ private val coresCol: IntArray,
+ private val size: Int,
+) {
+ init {
+ require(size >= 0) { "Invalid trace size" }
+ require(usageCol.size >= size) { "Invalid number of usage entries" }
+ require(timestampCol.size >= size) { "Invalid number of timestamp entries" }
+ require(deadlineCol.size >= size) { "Invalid number of deadline entries" }
+ require(coresCol.size >= size) { "Invalid number of core entries" }
+ }
+
+ public companion object {
+ /**
+ * Construct a [SimTrace] with the specified fragments.
+ */
+ public fun ofFragments(fragments: List<SimTraceFragment>): SimTrace {
+ val size = fragments.size
+ val usageCol = DoubleArray(size)
+ val timestampCol = LongArray(size)
+ val deadlineCol = LongArray(size)
+ val coresCol = IntArray(size)
+
+ for (i in fragments.indices) {
+ val fragment = fragments[i]
+ usageCol[i] = fragment.usage
+ timestampCol[i] = fragment.timestamp
+ deadlineCol[i] = fragment.timestamp + fragment.duration
+ coresCol[i] = fragment.cores
+ }
+
+ return SimTrace(usageCol, timestampCol, deadlineCol, coresCol, size)
+ }
+
+ /**
+ * Construct a [SimTrace] with the specified fragments.
+ */
+ @JvmStatic
+ public fun ofFragments(vararg fragments: SimTraceFragment): SimTrace {
+ val size = fragments.size
+ val usageCol = DoubleArray(size)
+ val timestampCol = LongArray(size)
+ val deadlineCol = LongArray(size)
+ val coresCol = IntArray(size)
+
+ for (i in fragments.indices) {
+ val fragment = fragments[i]
+ usageCol[i] = fragment.usage
+ timestampCol[i] = fragment.timestamp
+ deadlineCol[i] = fragment.timestamp + fragment.duration
+ coresCol[i] = fragment.cores
+ }
+
+ return SimTrace(usageCol, timestampCol, deadlineCol, coresCol, size)
+ }
+
+ /**
+ * Create a [SimTrace.Builder] instance.
+ */
+ @JvmStatic
+ public fun builder(): Builder = Builder()
+ }
+
+ /**
+ * Construct a new [FlowSource] for the specified [cpu].
+ */
+ public fun newSource(cpu: ProcessingUnit, offset: Long): FlowSource {
+ return CpuConsumer(cpu, offset, usageCol, timestampCol, deadlineCol, coresCol, size)
+ }
+
+ /**
+ * A builder class for a [SimTrace].
+ */
+ public class Builder internal constructor() {
+ /**
+ * The columns of the trace.
+ */
+ private var usageCol: DoubleArray = DoubleArray(16)
+ private var timestampCol: LongArray = LongArray(16)
+ private var deadlineCol: LongArray = LongArray(16)
+ private var coresCol: IntArray = IntArray(16)
+
+ /**
+ * The number of entries in the trace.
+ */
+ private var size = 0
+
+ /**
+ * Add the specified [SimTraceFragment] to the trace.
+ */
+ public fun add(fragment: SimTraceFragment) {
+ add(fragment.timestamp, fragment.timestamp + fragment.duration, fragment.usage, fragment.cores)
+ }
+
+ /**
+ * Add a fragment to the trace.
+ *
+ * @param timestamp Timestamp at which the fragment starts (in epoch millis).
+ * @param deadline Timestamp at which the fragment ends (in epoch millis).
+ * @param usage CPU usage of this fragment.
+ * @param cores Number of cores used.
+ */
+ public fun add(timestamp: Long, deadline: Long, usage: Double, cores: Int) {
+ val size = size
+
+ if (size == usageCol.size) {
+ grow()
+ }
+
+ timestampCol[size] = timestamp
+ deadlineCol[size] = deadline
+ usageCol[size] = usage
+ coresCol[size] = cores
+
+ this.size++
+ }
+
+ /**
+ * Helper function to grow the capacity of the column arrays.
+ */
+ private fun grow() {
+ val arraySize = usageCol.size
+ val newSize = arraySize * 2
+
+ usageCol = usageCol.copyOf(newSize)
+ timestampCol = timestampCol.copyOf(newSize)
+ deadlineCol = deadlineCol.copyOf(newSize)
+ coresCol = coresCol.copyOf(newSize)
+ }
+
+ /**
+ * Construct the immutable [SimTrace].
+ */
+ public fun build(): SimTrace {
+ return SimTrace(usageCol, timestampCol, deadlineCol, coresCol, size)
+ }
+ }
+
+ /**
+ * A CPU consumer for the trace workload.
+ */
+ private class CpuConsumer(
+ cpu: ProcessingUnit,
+ private val offset: Long,
+ private val usageCol: DoubleArray,
+ private val timestampCol: LongArray,
+ private val deadlineCol: LongArray,
+ private val coresCol: IntArray,
+ private val size: Int
+ ) : FlowSource {
+ private val id = cpu.id
+ private val coreCount = cpu.node.coreCount
+
+ /**
+ * The index in the trace.
+ */
+ private var _idx = 0
+
+ override fun onPull(conn: FlowConnection, now: Long, delta: Long): Long {
+ val size = size
+ val nowOffset = now - offset
+
+ var idx = _idx
+ val deadlines = deadlineCol
+ var deadline = deadlines[idx]
+
+ while (deadline <= nowOffset && ++idx < size) {
+ deadline = deadlines[idx]
+ }
+
+ if (idx >= size) {
+ conn.close()
+ return Long.MAX_VALUE
+ }
+
+ _idx = idx
+ val timestamp = timestampCol[idx]
+
+ // Fragment is in the future
+ if (timestamp > nowOffset) {
+ conn.push(0.0)
+ return timestamp - nowOffset
+ }
+
+ val cores = min(coreCount, coresCol[idx])
+ val usage = usageCol[idx]
+
+ conn.push(if (id < cores) usage / cores else 0.0)
+ return deadline - nowOffset
+ }
+ }
+}
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceFragment.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceFragment.kt
new file mode 100644
index 00000000..5285847f
--- /dev/null
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceFragment.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.simulator.compute.workload
+
+/**
+ * A fragment of the workload trace.
+ *
+ * @param timestamp The timestamp at which the fragment starts (in epoch millis).
+ * @param duration The duration of the fragment (in milliseconds).
+ * @param usage The CPU usage during the fragment (in MHz).
+ * @param cores The amount of cores utilized during the fragment.
+ */
+public data class SimTraceFragment(
+ @JvmField val timestamp: Long,
+ @JvmField val duration: Long,
+ @JvmField val usage: Double,
+ @JvmField val cores: Int
+)
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
index 49ae5933..53c98409 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
@@ -23,10 +23,6 @@
package org.opendc.simulator.compute.workload
import org.opendc.simulator.compute.SimMachineContext
-import org.opendc.simulator.compute.model.ProcessingUnit
-import org.opendc.simulator.flow.FlowConnection
-import org.opendc.simulator.flow.FlowSource
-import kotlin.math.min
/**
* A [SimWorkload] that replays a workload trace consisting of multiple fragments, each indicating the resource
@@ -35,89 +31,14 @@ import kotlin.math.min
* @param trace The trace of fragments to use.
* @param offset The offset for the timestamps.
*/
-public class SimTraceWorkload(public val trace: Sequence<Fragment>, private val offset: Long = 0L) : SimWorkload {
- private val iterator = trace.iterator()
- private var fragment: Fragment? = null
-
+public class SimTraceWorkload(private val trace: SimTrace, private val offset: Long = 0L) : SimWorkload {
override fun onStart(ctx: SimMachineContext) {
val lifecycle = SimWorkloadLifecycle(ctx)
for (cpu in ctx.cpus) {
- cpu.startConsumer(lifecycle.waitFor(Consumer(cpu.model)))
+ cpu.startConsumer(lifecycle.waitFor(trace.newSource(cpu.model, offset)))
}
}
override fun toString(): String = "SimTraceWorkload"
-
- /**
- * Obtain the fragment with a timestamp equal or greater than [now].
- */
- private fun pullFragment(now: Long): Fragment? {
- // Return the most recent fragment if its starting time + duration is later than `now`
- var fragment = fragment
- if (fragment != null && fragment.timestamp + offset + fragment.duration > now) {
- return fragment
- }
-
- while (iterator.hasNext()) {
- fragment = iterator.next()
- if (fragment.timestamp + offset + fragment.duration > now) {
- this.fragment = fragment
- return fragment
- }
- }
-
- this.fragment = null
- return null
- }
-
- private inner class Consumer(cpu: ProcessingUnit) : FlowSource {
- private val offset = this@SimTraceWorkload.offset
- private val id = cpu.id
- private val coreCount = cpu.node.coreCount
-
- override fun onPull(conn: FlowConnection, now: Long, delta: Long): Long {
- val fragment = pullFragment(now)
-
- if (fragment == null) {
- conn.close()
- return Long.MAX_VALUE
- }
-
- val timestamp = fragment.timestamp + offset
-
- // Fragment is in the future
- if (timestamp > now) {
- conn.push(0.0)
- return timestamp - now
- }
-
- val cores = min(coreCount, fragment.cores)
- val usage = if (fragment.cores > 0)
- fragment.usage / cores
- else
- 0.0
- val deadline = timestamp + fragment.duration
- val duration = deadline - now
-
- conn.push(if (id < cores && usage > 0.0) usage else 0.0)
-
- return duration
- }
- }
-
- /**
- * A fragment of the workload.
- *
- * @param timestamp The timestamp at which the fragment starts.
- * @param duration The duration of the fragment.
- * @param usage The CPU usage during the fragment.
- * @param cores The amount of cores utilized during the fragment.
- */
- public data class Fragment(
- @JvmField val timestamp: Long,
- @JvmField val duration: Long,
- @JvmField val usage: Double,
- @JvmField val cores: Int
- )
}
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt
index 9db2e6ec..6f32cf46 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt
@@ -38,6 +38,8 @@ import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.power.SimplePowerDriver
+import org.opendc.simulator.compute.workload.SimTrace
+import org.opendc.simulator.compute.workload.SimTraceFragment
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
@@ -66,11 +68,11 @@ internal class SimFairShareHypervisorTest {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, duration * 1000, 28.0, 1),
- SimTraceWorkload.Fragment(duration * 1000, duration * 1000, 3500.0, 1),
- SimTraceWorkload.Fragment(duration * 2000, duration * 1000, 0.0, 1),
- SimTraceWorkload.Fragment(duration * 3000, duration * 1000, 183.0, 1)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, duration * 1000, 28.0, 1),
+ SimTraceFragment(duration * 1000, duration * 1000, 3500.0, 1),
+ SimTraceFragment(duration * 2000, duration * 1000, 0.0, 1),
+ SimTraceFragment(duration * 3000, duration * 1000, 183.0, 1)
),
)
@@ -106,20 +108,20 @@ internal class SimFairShareHypervisorTest {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, duration * 1000, 28.0, 1),
- SimTraceWorkload.Fragment(duration * 1000, duration * 1000, 3500.0, 1),
- SimTraceWorkload.Fragment(duration * 2000, duration * 1000, 0.0, 1),
- SimTraceWorkload.Fragment(duration * 3000, duration * 1000, 183.0, 1)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, duration * 1000, 28.0, 1),
+ SimTraceFragment(duration * 1000, duration * 1000, 3500.0, 1),
+ SimTraceFragment(duration * 2000, duration * 1000, 0.0, 1),
+ SimTraceFragment(duration * 3000, duration * 1000, 183.0, 1)
),
)
val workloadB =
SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, duration * 1000, 28.0, 1),
- SimTraceWorkload.Fragment(duration * 1000, duration * 1000, 3100.0, 1),
- SimTraceWorkload.Fragment(duration * 2000, duration * 1000, 0.0, 1),
- SimTraceWorkload.Fragment(duration * 3000, duration * 1000, 73.0, 1)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, duration * 1000, 28.0, 1),
+ SimTraceFragment(duration * 1000, duration * 1000, 3100.0, 1),
+ SimTraceFragment(duration * 2000, duration * 1000, 0.0, 1),
+ SimTraceFragment(duration * 3000, duration * 1000, 73.0, 1)
)
)
@@ -201,20 +203,20 @@ internal class SimFairShareHypervisorTest {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, duration * 1000, 0.0, 1),
- SimTraceWorkload.Fragment(duration * 1000, duration * 1000, 28.0, 1),
- SimTraceWorkload.Fragment(duration * 2000, duration * 1000, 3500.0, 1),
- SimTraceWorkload.Fragment(duration * 3000, duration * 1000, 183.0, 1)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, duration * 1000, 0.0, 1),
+ SimTraceFragment(duration * 1000, duration * 1000, 28.0, 1),
+ SimTraceFragment(duration * 2000, duration * 1000, 3500.0, 1),
+ SimTraceFragment(duration * 3000, duration * 1000, 183.0, 1)
),
)
val workloadB =
SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, duration * 1000, 0.0, 1),
- SimTraceWorkload.Fragment(duration * 1000, duration * 1000, 28.0, 1),
- SimTraceWorkload.Fragment(duration * 2000, duration * 1000, 3100.0, 1),
- SimTraceWorkload.Fragment(duration * 3000, duration * 1000, 73.0, 1)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, duration * 1000, 0.0, 1),
+ SimTraceFragment(duration * 1000, duration * 1000, 28.0, 1),
+ SimTraceFragment(duration * 2000, duration * 1000, 3100.0, 1),
+ SimTraceFragment(duration * 3000, duration * 1000, 73.0, 1)
)
)
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt
index b05ffd22..02d308ff 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt
@@ -36,9 +36,7 @@ import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.power.SimplePowerDriver
-import org.opendc.simulator.compute.workload.SimFlopsWorkload
-import org.opendc.simulator.compute.workload.SimRuntimeWorkload
-import org.opendc.simulator.compute.workload.SimTraceWorkload
+import org.opendc.simulator.compute.workload.*
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
@@ -66,11 +64,11 @@ internal class SimSpaceSharedHypervisorTest {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, duration * 1000, 28.0, 1),
- SimTraceWorkload.Fragment(duration * 1000, duration * 1000, 3500.0, 1),
- SimTraceWorkload.Fragment(duration * 2000, duration * 1000, 0.0, 1),
- SimTraceWorkload.Fragment(duration * 3000, duration * 1000, 183.0, 1)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, duration * 1000, 28.0, 1),
+ SimTraceFragment(duration * 1000, duration * 1000, 3500.0, 1),
+ SimTraceFragment(duration * 2000, duration * 1000, 0.0, 1),
+ SimTraceFragment(duration * 3000, duration * 1000, 183.0, 1)
),
)
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt
index cdbffe4b..574860e8 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt
@@ -58,11 +58,11 @@ class SimTraceWorkloadTest {
)
val workload = SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, 1000, 2 * 28.0, 2),
- SimTraceWorkload.Fragment(1000, 1000, 2 * 3100.0, 2),
- SimTraceWorkload.Fragment(2000, 1000, 0.0, 2),
- SimTraceWorkload.Fragment(3000, 1000, 2 * 73.0, 2)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, 1000, 2 * 28.0, 2),
+ SimTraceFragment(1000, 1000, 2 * 3100.0, 2),
+ SimTraceFragment(2000, 1000, 0.0, 2),
+ SimTraceFragment(3000, 1000, 2 * 73.0, 2)
),
offset = 0
)
@@ -85,11 +85,11 @@ class SimTraceWorkloadTest {
)
val workload = SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, 1000, 2 * 28.0, 2),
- SimTraceWorkload.Fragment(1000, 1000, 2 * 3100.0, 2),
- SimTraceWorkload.Fragment(2000, 1000, 0.0, 2),
- SimTraceWorkload.Fragment(3000, 1000, 2 * 73.0, 2)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, 1000, 2 * 28.0, 2),
+ SimTraceFragment(1000, 1000, 2 * 3100.0, 2),
+ SimTraceFragment(2000, 1000, 0.0, 2),
+ SimTraceFragment(3000, 1000, 2 * 73.0, 2)
),
offset = 1000
)
@@ -112,11 +112,11 @@ class SimTraceWorkloadTest {
)
val workload = SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, 1000, 2 * 28.0, 2),
- SimTraceWorkload.Fragment(1000, 1000, 2 * 3100.0, 2),
- SimTraceWorkload.Fragment(2000, 1000, 0.0, 2),
- SimTraceWorkload.Fragment(3000, 1000, 2 * 73.0, 2)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, 1000, 2 * 28.0, 2),
+ SimTraceFragment(1000, 1000, 2 * 3100.0, 2),
+ SimTraceFragment(2000, 1000, 0.0, 2),
+ SimTraceFragment(3000, 1000, 2 * 73.0, 2)
),
offset = 0
)
@@ -140,11 +140,11 @@ class SimTraceWorkloadTest {
)
val workload = SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(0, 1000, 2 * 28.0, 2),
- SimTraceWorkload.Fragment(1000, 1000, 2 * 3100.0, 2),
- SimTraceWorkload.Fragment(2000, 1000, 0.0, 0),
- SimTraceWorkload.Fragment(3000, 1000, 2 * 73.0, 2)
+ SimTrace.ofFragments(
+ SimTraceFragment(0, 1000, 2 * 28.0, 2),
+ SimTraceFragment(1000, 1000, 2 * 3100.0, 2),
+ SimTraceFragment(2000, 1000, 0.0, 0),
+ SimTraceFragment(3000, 1000, 2 * 73.0, 2)
),
offset = 0
)