summaryrefslogtreecommitdiff
path: root/opendc-experiments
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-experiments')
-rw-r--r--opendc-experiments/opendc-experiments-capelin/build.gradle.kts1
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt16
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt26
-rw-r--r--opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/FailureModel.kt7
-rw-r--r--opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/HostsProvisioningStep.kt11
-rw-r--r--opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/TraceHelpers.kt3
-rw-r--r--opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/telemetry/table/ServiceData.kt12
-rw-r--r--opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/topology/HostSpec.kt11
-rw-r--r--opendc-experiments/opendc-experiments-faas/src/main/kotlin/org/opendc/experiments/faas/FunctionTraceWorkload.kt3
-rw-r--r--opendc-experiments/opendc-experiments-faas/src/test/kotlin/org/opendc/experiments/faas/FaaSExperiment.kt4
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt76
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MLEnvironmentReader.kt4
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MachineDef.kt4
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt14
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt4
-rw-r--r--opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt2
16 files changed, 105 insertions, 93 deletions
diff --git a/opendc-experiments/opendc-experiments-capelin/build.gradle.kts b/opendc-experiments/opendc-experiments-capelin/build.gradle.kts
index e19784ba..da45adde 100644
--- a/opendc-experiments/opendc-experiments-capelin/build.gradle.kts
+++ b/opendc-experiments/opendc-experiments-capelin/build.gradle.kts
@@ -44,6 +44,7 @@ dependencies {
implementation(libs.jackson.dataformat.csv)
runtimeOnly(projects.opendcTrace.opendcTraceOpendc)
+ runtimeOnly(libs.log4j.core)
runtimeOnly(libs.log4j.slf4j)
}
diff --git a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt
index 08d4a7e0..0b4cafa6 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt
@@ -25,13 +25,13 @@
package org.opendc.experiments.capelin.topology
import org.opendc.experiments.compute.topology.HostSpec
+import org.opendc.simulator.compute.SimPsuFactories
import org.opendc.simulator.compute.model.MachineModel
import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
-import org.opendc.simulator.compute.power.LinearPowerModel
-import org.opendc.simulator.compute.power.PowerModel
-import org.opendc.simulator.compute.power.SimplePowerDriver
+import org.opendc.simulator.compute.power.CpuPowerModel
+import org.opendc.simulator.compute.power.CpuPowerModels
import java.io.File
import java.io.InputStream
import java.util.Random
@@ -48,7 +48,7 @@ private val reader = ClusterSpecReader()
*/
fun clusterTopology(
file: File,
- powerModel: PowerModel = LinearPowerModel(350.0, idlePower = 200.0),
+ powerModel: CpuPowerModel = CpuPowerModels.linear(350.0, 200.0),
random: Random = Random(0)
): List<HostSpec> {
return clusterTopology(reader.read(file), powerModel, random)
@@ -59,7 +59,7 @@ fun clusterTopology(
*/
fun clusterTopology(
input: InputStream,
- powerModel: PowerModel = LinearPowerModel(350.0, idlePower = 200.0),
+ powerModel: CpuPowerModel = CpuPowerModels.linear(350.0, 200.0),
random: Random = Random(0)
): List<HostSpec> {
return clusterTopology(reader.read(input), powerModel, random)
@@ -68,14 +68,14 @@ fun clusterTopology(
/**
* Construct a topology from the given list of [clusters].
*/
-fun clusterTopology(clusters: List<ClusterSpec>, powerModel: PowerModel, random: Random = Random(0)): List<HostSpec> {
+fun clusterTopology(clusters: List<ClusterSpec>, powerModel: CpuPowerModel, random: Random = Random(0)): List<HostSpec> {
return clusters.flatMap { it.toHostSpecs(random, powerModel) }
}
/**
* Helper method to convert a [ClusterSpec] into a list of [HostSpec]s.
*/
-private fun ClusterSpec.toHostSpecs(random: Random, powerModel: PowerModel): List<HostSpec> {
+private fun ClusterSpec.toHostSpecs(random: Random, powerModel: CpuPowerModel): List<HostSpec> {
val cpuSpeed = cpuSpeed
val memoryPerHost = memCapacityPerHost.roundToLong()
@@ -92,7 +92,7 @@ private fun ClusterSpec.toHostSpecs(random: Random, powerModel: PowerModel): Lis
"node-$name-$it",
mapOf("cluster" to id),
machineModel,
- SimplePowerDriver(powerModel)
+ SimPsuFactories.simple(powerModel)
)
}
}
diff --git a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
index 70363b6c..47058caa 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
@@ -120,11 +120,11 @@ class CapelinIntegrationTest {
{ assertEquals(0, monitor.serversActive, "All VMs should finish after a run") },
{ assertEquals(0, monitor.attemptsFailure, "No VM should be unscheduled") },
{ assertEquals(0, monitor.serversPending, "No VM should not be in the queue") },
- { assertEquals(223393683, monitor.idleTime) { "Incorrect idle time" } },
- { assertEquals(66977508, monitor.activeTime) { "Incorrect active time" } },
- { assertEquals(3160381, monitor.stealTime) { "Incorrect steal time" } },
+ { assertEquals(223394204, monitor.idleTime) { "Incorrect idle time" } },
+ { assertEquals(66976984, monitor.activeTime) { "Incorrect active time" } },
+ { assertEquals(3160316, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(0, monitor.lostTime) { "Incorrect lost time" } },
- { assertEquals(5.840939264814157E9, monitor.energyUsage, 0.01) { "Incorrect power draw" } }
+ { assertEquals(5.84093E9, monitor.energyUsage, 1E4) { "Incorrect power draw" } }
)
}
@@ -160,11 +160,11 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(10999592, monitor.idleTime) { "Idle time incorrect" } },
- { assertEquals(9741207, monitor.activeTime) { "Active time incorrect" } },
+ { assertEquals(10999504, monitor.idleTime) { "Idle time incorrect" } },
+ { assertEquals(9741294, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(0, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, monitor.lostTime) { "Lost time incorrect" } },
- { assertEquals(7.011676470304312E8, monitor.energyUsage, 0.01) { "Incorrect power draw" } }
+ { assertEquals(7.0116E8, monitor.energyUsage, 1E4) { "Incorrect power draw" } }
)
}
@@ -199,10 +199,10 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(6028050, monitor.idleTime) { "Idle time incorrect" } },
- { assertEquals(14712749, monitor.activeTime) { "Active time incorrect" } },
- { assertEquals(12532907, monitor.stealTime) { "Steal time incorrect" } },
- { assertEquals(470593, monitor.lostTime) { "Lost time incorrect" } }
+ { assertEquals(6027979, monitor.idleTime) { "Idle time incorrect" } },
+ { assertEquals(14712820, monitor.activeTime) { "Active time incorrect" } },
+ { assertEquals(12532979, monitor.stealTime) { "Steal time incorrect" } },
+ { assertEquals(445913, monitor.lostTime) { "Lost time incorrect" } }
)
}
@@ -229,8 +229,8 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(10085158, monitor.idleTime) { "Idle time incorrect" } },
- { assertEquals(8539158, monitor.activeTime) { "Active time incorrect" } },
+ { assertEquals(10085103, monitor.idleTime) { "Idle time incorrect" } },
+ { assertEquals(8539212, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(0, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, monitor.lostTime) { "Lost time incorrect" } },
{ assertEquals(2328039558, monitor.uptime) { "Uptime incorrect" } }
diff --git a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/FailureModel.kt b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/FailureModel.kt
index e0d6fdc1..81a5cf33 100644
--- a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/FailureModel.kt
+++ b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/FailureModel.kt
@@ -35,5 +35,10 @@ public interface FailureModel {
/**
* Construct a [HostFaultInjector] for the specified [service].
*/
- public fun createInjector(context: CoroutineContext, clock: Clock, service: ComputeService, random: Random): HostFaultInjector
+ public fun createInjector(
+ context: CoroutineContext,
+ clock: Clock,
+ service: ComputeService,
+ random: Random
+ ): HostFaultInjector
}
diff --git a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/HostsProvisioningStep.kt b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/HostsProvisioningStep.kt
index 9fa8d00c..292be929 100644
--- a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/HostsProvisioningStep.kt
+++ b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/HostsProvisioningStep.kt
@@ -29,7 +29,7 @@ import org.opendc.experiments.provisioner.ProvisioningContext
import org.opendc.experiments.provisioner.ProvisioningStep
import org.opendc.simulator.compute.SimBareMetalMachine
import org.opendc.simulator.compute.kernel.SimHypervisor
-import org.opendc.simulator.flow.FlowEngine
+import org.opendc.simulator.flow2.FlowEngine
import java.util.SplittableRandom
/**
@@ -46,19 +46,20 @@ public class HostsProvisioningStep internal constructor(
) : ProvisioningStep {
override fun apply(ctx: ProvisioningContext): AutoCloseable {
val service = requireNotNull(ctx.registry.resolve(serviceDomain, ComputeService::class.java)) { "Compute service $serviceDomain does not exist" }
- val engine = FlowEngine(ctx.coroutineContext, ctx.clock)
+ val engine = FlowEngine.create(ctx.coroutineContext, ctx.clock)
+ val graph = engine.newGraph()
val hosts = mutableSetOf<SimHost>()
for (spec in specs) {
- val machine = SimBareMetalMachine(engine, spec.model, spec.powerDriver)
- val hypervisor = SimHypervisor(engine, spec.multiplexerFactory, SplittableRandom(ctx.seeder.nextLong()))
+ val machine = SimBareMetalMachine.create(graph, spec.model, spec.psuFactory)
+ val hypervisor = SimHypervisor.create(spec.multiplexerFactory, SplittableRandom(ctx.seeder.nextLong()))
val host = SimHost(
spec.uid,
spec.name,
spec.meta,
ctx.coroutineContext,
- ctx.clock,
+ graph,
machine,
hypervisor,
optimize = optimize
diff --git a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/TraceHelpers.kt b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/TraceHelpers.kt
index e98636fa..f0e31932 100644
--- a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/TraceHelpers.kt
+++ b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/TraceHelpers.kt
@@ -29,7 +29,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.yield
import org.opendc.compute.service.ComputeService
-import org.opendc.simulator.compute.workload.SimTraceWorkload
import java.time.Clock
import java.util.Random
import kotlin.coroutines.coroutineContext
@@ -82,7 +81,7 @@ public suspend fun ComputeService.replay(
}
val workloadOffset = -offset + 300001
- val workload = SimTraceWorkload(entry.trace, workloadOffset)
+ val workload = entry.trace.createWorkload(workloadOffset)
val meta = mutableMapOf<String, Any>("workload" to workload)
val interferenceProfile = entry.interferenceProfile
diff --git a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/telemetry/table/ServiceData.kt b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/telemetry/table/ServiceData.kt
index 5b6960a3..e19d7c68 100644
--- a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/telemetry/table/ServiceData.kt
+++ b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/telemetry/table/ServiceData.kt
@@ -43,5 +43,15 @@ public data class ServiceData(
* Convert a [ServiceTableReader] into a persistent object.
*/
public fun ServiceTableReader.toServiceData(): ServiceData {
- return ServiceData(timestamp, hostsUp, hostsDown, serversTotal, serversPending, serversActive, attemptsSuccess, attemptsFailure, attemptsError)
+ return ServiceData(
+ timestamp,
+ hostsUp,
+ hostsDown,
+ serversTotal,
+ serversPending,
+ serversActive,
+ attemptsSuccess,
+ attemptsFailure,
+ attemptsError
+ )
}
diff --git a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/topology/HostSpec.kt b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/topology/HostSpec.kt
index b5dbaaeb..08c3dca2 100644
--- a/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/topology/HostSpec.kt
+++ b/opendc-experiments/opendc-experiments-compute/src/main/kotlin/org/opendc/experiments/compute/topology/HostSpec.kt
@@ -22,11 +22,10 @@
package org.opendc.experiments.compute.topology
+import org.opendc.simulator.compute.SimPsuFactories
+import org.opendc.simulator.compute.SimPsuFactory
import org.opendc.simulator.compute.model.MachineModel
-import org.opendc.simulator.compute.power.LinearPowerModel
-import org.opendc.simulator.compute.power.PowerDriver
-import org.opendc.simulator.compute.power.SimplePowerDriver
-import org.opendc.simulator.flow.mux.FlowMultiplexerFactory
+import org.opendc.simulator.flow2.mux.FlowMultiplexerFactory
import java.util.UUID
/**
@@ -36,7 +35,7 @@ import java.util.UUID
* @param name The name of the host.
* @param meta The metadata of the host.
* @param model The physical model of the machine.
- * @param powerDriver The [PowerDriver] to model the power consumption of the machine.
+ * @param psuFactory The [SimPsuFactory] to construct the PSU that models the power consumption of the machine.
* @param multiplexerFactory The [FlowMultiplexerFactory] that is used to multiplex the virtual machines over the host.
*/
public data class HostSpec(
@@ -44,6 +43,6 @@ public data class HostSpec(
val name: String,
val meta: Map<String, Any>,
val model: MachineModel,
- val powerDriver: PowerDriver = SimplePowerDriver(LinearPowerModel(350.0, idlePower = 200.0)),
+ val psuFactory: SimPsuFactory = SimPsuFactories.noop(),
val multiplexerFactory: FlowMultiplexerFactory = FlowMultiplexerFactory.maxMinMultiplexer()
)
diff --git a/opendc-experiments/opendc-experiments-faas/src/main/kotlin/org/opendc/experiments/faas/FunctionTraceWorkload.kt b/opendc-experiments/opendc-experiments-faas/src/main/kotlin/org/opendc/experiments/faas/FunctionTraceWorkload.kt
index 90e76dac..71a2536c 100644
--- a/opendc-experiments/opendc-experiments-faas/src/main/kotlin/org/opendc/experiments/faas/FunctionTraceWorkload.kt
+++ b/opendc-experiments/opendc-experiments-faas/src/main/kotlin/org/opendc/experiments/faas/FunctionTraceWorkload.kt
@@ -25,13 +25,12 @@ package org.opendc.experiments.faas
import org.opendc.faas.simulator.workload.SimFaaSWorkload
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.compute.workload.SimWorkload
/**
* A [SimFaaSWorkload] for a [FunctionTrace].
*/
public class FunctionTraceWorkload(trace: FunctionTrace) :
- SimFaaSWorkload, SimWorkload by SimTraceWorkload(SimTrace.ofFragments(trace.samples.map { SimTraceFragment(it.timestamp, it.duration, it.cpuUsage, 1) })) {
+ SimFaaSWorkload, SimWorkload by SimTrace.ofFragments(trace.samples.map { SimTraceFragment(it.timestamp, it.duration, it.cpuUsage, 1) }).createWorkload(0) {
override suspend fun invoke() {}
}
diff --git a/opendc-experiments/opendc-experiments-faas/src/test/kotlin/org/opendc/experiments/faas/FaaSExperiment.kt b/opendc-experiments/opendc-experiments-faas/src/test/kotlin/org/opendc/experiments/faas/FaaSExperiment.kt
index 2342c3f6..1ad9c57f 100644
--- a/opendc-experiments/opendc-experiments-faas/src/test/kotlin/org/opendc/experiments/faas/FaaSExperiment.kt
+++ b/opendc-experiments/opendc-experiments-faas/src/test/kotlin/org/opendc/experiments/faas/FaaSExperiment.kt
@@ -82,8 +82,8 @@ class FaaSExperiment {
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
return MachineModel(
- cpus = List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) },
- memory = List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
+ /*cpus*/ List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) },
+ /*memory*/ List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
)
}
}
diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt
index c71c4520..a7fc102a 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt
@@ -31,16 +31,17 @@ import kotlinx.coroutines.suspendCancellableCoroutine
import org.opendc.simulator.compute.SimBareMetalMachine
import org.opendc.simulator.compute.SimMachine
import org.opendc.simulator.compute.SimMachineContext
+import org.opendc.simulator.compute.SimPsuFactories
import org.opendc.simulator.compute.model.MachineModel
import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingUnit
-import org.opendc.simulator.compute.power.PowerModel
-import org.opendc.simulator.compute.power.SimplePowerDriver
+import org.opendc.simulator.compute.power.CpuPowerModel
import org.opendc.simulator.compute.runWorkload
import org.opendc.simulator.compute.workload.SimWorkload
-import org.opendc.simulator.flow.FlowConnection
-import org.opendc.simulator.flow.FlowEngine
-import org.opendc.simulator.flow.FlowSource
+import org.opendc.simulator.flow2.FlowEngine
+import org.opendc.simulator.flow2.FlowStage
+import org.opendc.simulator.flow2.FlowStageLogic
+import org.opendc.simulator.flow2.OutPort
import java.time.Clock
import java.util.ArrayDeque
import java.util.UUID
@@ -60,7 +61,7 @@ public class SimTFDevice(
clock: Clock,
pu: ProcessingUnit,
private val memory: MemoryUnit,
- powerModel: PowerModel
+ powerModel: CpuPowerModel
) : TFDevice {
/**
* The scope in which the device runs.
@@ -70,25 +71,25 @@ public class SimTFDevice(
/**
* The [SimMachine] representing the device.
*/
- private val machine = SimBareMetalMachine(
- FlowEngine(scope.coroutineContext, clock),
+ private val machine = SimBareMetalMachine.create(
+ FlowEngine.create(context, clock).newGraph(),
MachineModel(listOf(pu), listOf(memory)),
- SimplePowerDriver(powerModel)
+ SimPsuFactories.simple(powerModel)
)
/**
* The workload that will be run by the device.
*/
- private val workload = object : SimWorkload, FlowSource {
+ private val workload = object : SimWorkload, FlowStageLogic {
/**
- * The resource context to interrupt the workload with.
+ * The [FlowStage] of the workload.
*/
- var ctx: FlowConnection? = null
+ var stage: FlowStage? = null
/**
- * The capacity of the device.
+ * The output of the workload.
*/
- private var capacity: Double = 0.0
+ private var output: OutPort? = null
/**
* The queue of work to run.
@@ -112,37 +113,35 @@ public class SimTFDevice(
private var lastPull: Long = 0L
override fun onStart(ctx: SimMachineContext) {
- for (cpu in ctx.cpus) {
- cpu.startConsumer(this)
- }
- }
+ val stage = ctx.graph.newStage(this)
+ this.stage = stage
+ output = stage.getOutlet("out")
+ lastPull = ctx.graph.engine.clock.millis()
- override fun onStop(ctx: SimMachineContext) {}
+ ctx.graph.connect(output, ctx.cpus[0].input)
+ }
- override fun onStart(conn: FlowConnection, now: Long) {
- ctx = conn
- capacity = conn.capacity
- lastPull = now
- conn.shouldSourceConverge = false
+ override fun onStop(ctx: SimMachineContext) {
+ stage?.close()
+ stage = null
+ output = null
}
- override fun onPull(conn: FlowConnection, now: Long): Long {
+ override fun onUpdate(ctx: FlowStage, now: Long): Long {
+ val output = output ?: return Long.MAX_VALUE
val lastPull = lastPull
this.lastPull = now
val delta = (now - lastPull).coerceAtLeast(0)
-
- val consumedWork = conn.rate * delta / 1000.0
-
- capacity = conn.capacity
+ val consumedWork = output.rate * delta / 1000.0
val activeWork = activeWork
if (activeWork != null) {
if (activeWork.consume(consumedWork)) {
this.activeWork = null
} else {
- val duration = ceil(activeWork.flops / conn.capacity * 1000).toLong()
- conn.push(conn.capacity)
- return duration
+ val duration = ceil(activeWork.flops / output.capacity * 1000).toLong()
+ output.push(output.capacity)
+ return now + duration
}
}
@@ -150,11 +149,11 @@ public class SimTFDevice(
val head = queue.poll()
return if (head != null) {
this.activeWork = head
- val duration = (head.flops / conn.capacity * 1000).roundToLong()
- conn.push(conn.capacity)
- duration
+ val duration = (head.flops / output.capacity * 1000).roundToLong()
+ output.push(output.capacity)
+ now + duration
} else {
- conn.push(0.0)
+ output.push(0.0f)
Long.MAX_VALUE
}
}
@@ -174,13 +173,12 @@ public class SimTFDevice(
override suspend fun compute(flops: Double) = suspendCancellableCoroutine<Unit> { cont ->
workload.queue.add(Work(flops, cont))
if (workload.isIdle) {
- workload.ctx?.pull()
+ workload.stage?.invalidate()
}
}
override fun getDeviceStats(): TFDeviceStats {
- val resourceUsage = machine.cpus.sumOf { it.rate }
- return TFDeviceStats(resourceUsage, machine.powerUsage, machine.energyUsage)
+ return TFDeviceStats(machine.cpuUsage, machine.psu.powerUsage, machine.psu.energyUsage)
}
override fun close() {
diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MLEnvironmentReader.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MLEnvironmentReader.kt
index 4913c019..2a7578b3 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MLEnvironmentReader.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MLEnvironmentReader.kt
@@ -29,7 +29,7 @@ import org.opendc.simulator.compute.model.MachineModel
import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
-import org.opendc.simulator.compute.power.LinearPowerModel
+import org.opendc.simulator.compute.power.CpuPowerModels
import java.io.InputStream
import java.util.UUID
@@ -102,7 +102,7 @@ public class MLEnvironmentReader {
"node-${counter++}",
mapOf("gpu" to isGpuFlag),
MachineModel(cores, memories),
- LinearPowerModel(maxPower, minPower)
+ CpuPowerModels.linear(maxPower, minPower)
)
}
}
diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MachineDef.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MachineDef.kt
index 63f00d53..6b72e155 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MachineDef.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/util/MachineDef.kt
@@ -23,7 +23,7 @@
package org.opendc.experiments.tf20.util
import org.opendc.simulator.compute.model.MachineModel
-import org.opendc.simulator.compute.power.PowerModel
+import org.opendc.simulator.compute.power.CpuPowerModel
import java.util.UUID
/**
@@ -34,5 +34,5 @@ public data class MachineDef(
val name: String,
val meta: Map<String, Any>,
val model: MachineModel,
- val powerModel: PowerModel
+ val powerModel: CpuPowerModel
)
diff --git a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt
index c4698058..32f72686 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt
@@ -29,7 +29,7 @@ import org.opendc.experiments.tf20.core.SimTFDevice
import org.opendc.experiments.tf20.distribute.MirroredStrategy
import org.opendc.experiments.tf20.distribute.OneDeviceStrategy
import org.opendc.experiments.tf20.util.MLEnvironmentReader
-import org.opendc.simulator.compute.power.LinearPowerModel
+import org.opendc.simulator.compute.power.CpuPowerModels
import org.opendc.simulator.kotlin.runSimulation
import java.util.UUID
@@ -52,7 +52,7 @@ class TensorFlowTest {
clock,
def.model.cpus[0],
def.model.memory[0],
- LinearPowerModel(250.0, 60.0)
+ CpuPowerModels.linear(250.0, 60.0)
)
val strategy = OneDeviceStrategy(device)
val batchSize = 32
@@ -87,7 +87,7 @@ class TensorFlowTest {
clock,
def.model.cpus[0],
def.model.memory[0],
- LinearPowerModel(250.0, 60.0)
+ CpuPowerModels.linear(250.0, 60.0)
)
val strategy = OneDeviceStrategy(device)
val batchSize = 128
@@ -102,8 +102,8 @@ class TensorFlowTest {
val stats = device.getDeviceStats()
assertAll(
- { assertEquals(176230322904, clock.millis()) },
- { assertEquals(4.4057580726E10, stats.energyUsage) }
+ { assertEquals(176230328513, clock.millis()) },
+ { assertEquals(4.405758212825E10, stats.energyUsage) }
)
}
@@ -122,7 +122,7 @@ class TensorFlowTest {
clock,
def.model.cpus[0],
def.model.memory[0],
- LinearPowerModel(250.0, 60.0)
+ CpuPowerModels.linear(250.0, 60.0)
)
val deviceB = SimTFDevice(
@@ -132,7 +132,7 @@ class TensorFlowTest {
clock,
def.model.cpus[0],
def.model.memory[0],
- LinearPowerModel(250.0, 60.0)
+ CpuPowerModels.linear(250.0, 60.0)
)
val strategy = MirroredStrategy(listOf(deviceA, deviceB))
diff --git a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
index 85d63e9b..910cbcc9 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test
import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
-import org.opendc.simulator.compute.power.LinearPowerModel
+import org.opendc.simulator.compute.power.CpuPowerModels
import org.opendc.simulator.kotlin.runSimulation
import java.util.UUID
@@ -51,7 +51,7 @@ internal class SimTFDeviceTest {
clock,
pu,
memory,
- LinearPowerModel(250.0, 100.0)
+ CpuPowerModels.linear(250.0, 100.0)
)
// Load 1 GiB into GPU memory
diff --git a/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt b/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt
index 2ae69949..4dc3a775 100644
--- a/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt
+++ b/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt
@@ -74,7 +74,7 @@ public fun Trace.toJobs(): List<Job> {
val submitTime = reader.getInstant(TASK_SUBMIT_TIME)!!
val runtime = reader.getDuration(TASK_RUNTIME)!!
val flops: Long = 4000 * runtime.seconds * grantedCpus
- val workload = SimFlopsWorkload(flops)
+ val workload = SimFlopsWorkload(flops, 1.0)
val task = Task(
UUID(0L, id),
"<unnamed>",