summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-09 21:59:07 +0000
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-13 17:42:01 +0000
commitfb2672afb2d8236d5291cd028196c99d8e4d47f1 (patch)
tree508bbec117239b3d8490cd1bde8d12b6a8ab2155 /opendc-simulator/opendc-simulator-compute/src
parent00ac59e8e9d6a41c2eac55aa25420dce8fa9c6e0 (diff)
refactor: Replace use of CoroutineContext by Dispatcher
This change replaces the use of `CoroutineContext` for passing the `SimulationDispatcher` across the different modules of OpenDC by the lightweight `Dispatcher` interface of the OpenDC common module.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt8
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt32
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt8
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt12
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt18
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt8
6 files changed, 43 insertions, 43 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 b761598b..eea46b95 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
@@ -74,7 +74,7 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkBareMetal() {
return runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
return@runSimulation machine.runWorkload(trace.createWorkload(0))
@@ -84,7 +84,7 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkSpaceSharedHypervisor() {
return runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1))
@@ -105,7 +105,7 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkFairShareHypervisorSingle() {
return runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1))
@@ -126,7 +126,7 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkFairShareHypervisorDouble() {
return runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1))
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt
index 646d687d..58b01e06 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt
@@ -72,7 +72,7 @@ class SimMachineTest {
@Test
fun testFlopsWorkload() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -97,7 +97,7 @@ class SimMachineTest {
}
val trace = builder.build()
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
graph,
@@ -112,7 +112,7 @@ class SimMachineTest {
@Test
fun testDualSocketMachine() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val cpuNode = machineModel.cpus[0].node
@@ -133,7 +133,7 @@ class SimMachineTest {
@Test
fun testPower() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
graph,
@@ -156,7 +156,7 @@ class SimMachineTest {
@Test
fun testCapacityClamp() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -184,7 +184,7 @@ class SimMachineTest {
@Test
fun testMemory() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -206,7 +206,7 @@ class SimMachineTest {
@Test
fun testMemoryUsage() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -230,7 +230,7 @@ class SimMachineTest {
@Test
fun testNetUsage() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -258,7 +258,7 @@ class SimMachineTest {
@Test
fun testDiskReadUsage() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -283,7 +283,7 @@ class SimMachineTest {
@Test
fun testDiskWriteUsage() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -308,7 +308,7 @@ class SimMachineTest {
@Test
fun testCancellation() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -330,7 +330,7 @@ class SimMachineTest {
@Test
fun testConcurrentRuns() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -351,7 +351,7 @@ class SimMachineTest {
@Test
fun testCatchStartFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -367,7 +367,7 @@ class SimMachineTest {
@Test
fun testCatchStopFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -384,7 +384,7 @@ class SimMachineTest {
@Test
fun testCatchShutdownFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -400,7 +400,7 @@ class SimMachineTest {
@Test
fun testCatchNestedFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
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 f60ff67c..99f47b2f 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
@@ -74,7 +74,7 @@ internal class SimFairShareHypervisorTest {
SimTraceFragment(duration * 3000, duration * 1000, 183.0, 1)
).createWorkload(0)
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, model)
@@ -118,7 +118,7 @@ internal class SimFairShareHypervisorTest {
SimTraceFragment(duration * 3000, duration * 1000, 73.0, 1)
).createWorkload(0)
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, model)
@@ -157,7 +157,7 @@ internal class SimFairShareHypervisorTest {
/*memory*/ List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
)
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, model)
@@ -184,7 +184,7 @@ internal class SimFairShareHypervisorTest {
.addGroup(setOf("a", "n"), 0.1, 0.8)
.build()
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, model)
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 31718794..93b67aa3 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
@@ -75,7 +75,7 @@ internal class SimSpaceSharedHypervisorTest {
SimTraceFragment(duration * 3000, duration * 1000, 183.0, 1)
).createWorkload(0)
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
@@ -99,7 +99,7 @@ internal class SimSpaceSharedHypervisorTest {
fun testRuntimeWorkload() = runSimulation {
val duration = 5 * 60L * 1000
val workload = SimWorkloads.runtime(duration, 1.0)
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
@@ -123,7 +123,7 @@ internal class SimSpaceSharedHypervisorTest {
fun testFlopsWorkload() = runSimulation {
val duration = 5 * 60L * 1000
val workload = SimWorkloads.flops((duration * 3.2).toLong(), 1.0)
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
@@ -144,7 +144,7 @@ internal class SimSpaceSharedHypervisorTest {
@Test
fun testTwoWorkloads() = runSimulation {
val duration = 5 * 60L * 1000
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
@@ -173,7 +173,7 @@ internal class SimSpaceSharedHypervisorTest {
*/
@Test
fun testConcurrentWorkloadFails() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
@@ -200,7 +200,7 @@ internal class SimSpaceSharedHypervisorTest {
*/
@Test
fun testConcurrentWorkloadSucceeds() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt
index c208a2af..08bb6509 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt
@@ -59,7 +59,7 @@ class SimChainWorkloadTest {
@Test
fun testMultipleWorkloads() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -80,7 +80,7 @@ class SimChainWorkloadTest {
@Test
fun testStartFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -105,7 +105,7 @@ class SimChainWorkloadTest {
@Test
fun testStartFailureSecond() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -131,7 +131,7 @@ class SimChainWorkloadTest {
@Test
fun testStopFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -155,7 +155,7 @@ class SimChainWorkloadTest {
@Test
fun testStopFailureSecond() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -180,7 +180,7 @@ class SimChainWorkloadTest {
@Test
fun testStartAndStopFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -206,7 +206,7 @@ class SimChainWorkloadTest {
@Test
fun testShutdownAndStopFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -232,7 +232,7 @@ class SimChainWorkloadTest {
@Test
fun testShutdownAndStartFailure() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -260,7 +260,7 @@ class SimChainWorkloadTest {
@Test
fun testSnapshot() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(graph, machineModel)
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 c0bdfd25..5c888fbc 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
@@ -53,7 +53,7 @@ class SimTraceWorkloadTest {
@Test
fun testSmoke() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -76,7 +76,7 @@ class SimTraceWorkloadTest {
@Test
fun testOffset() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -99,7 +99,7 @@ class SimTraceWorkloadTest {
@Test
fun testSkipFragment() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(
@@ -123,7 +123,7 @@ class SimTraceWorkloadTest {
@Test
fun testZeroCores() = runSimulation {
- val engine = FlowEngine.create(coroutineContext, timeSource)
+ val engine = FlowEngine.create(dispatcher)
val graph = engine.newGraph()
val machine = SimBareMetalMachine.create(