diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt index 0b9916edc..e1ccdfaf4 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt @@ -32,6 +32,7 @@ import org.opendc.compute.simulator.telemetry.GuestSystemStats import org.opendc.compute.simulator.telemetry.HostCpuStats import org.opendc.compute.simulator.telemetry.HostSystemStats import org.opendc.simulator.Multiplexer +import org.opendc.simulator.compute.cpu.CpuPowerModel import org.opendc.simulator.compute.machine.SimMachine import org.opendc.simulator.compute.models.MachineModel import org.opendc.simulator.compute.models.MemoryUnit @@ -60,6 +61,7 @@ public class SimHost( private val clock: InstantSource, private val graph: FlowGraph, private val machineModel: MachineModel, + private val cpuPowerModel: CpuPowerModel, private val powerMux: Multiplexer, ) : AutoCloseable { /** @@ -83,8 +85,8 @@ public class SimHost( private val model: HostModel = HostModel( - machineModel.cpu.totalCapacity, - machineModel.cpu.coreCount, + machineModel.cpuModel.totalCapacity, + machineModel.cpuModel.coreCount, machineModel.memory.size, ) @@ -108,7 +110,7 @@ public class SimHost( private var totalUptime = 0L private var totalDowntime = 0L private var bootTime: Instant? = null - private val cpuLimit = machineModel.cpu.totalCapacity + private val cpuLimit = machineModel.cpuModel.totalCapacity init { launch() @@ -130,6 +132,7 @@ public class SimHost( this.graph, this.machineModel, this.powerMux, + this.cpuPowerModel, ) { cause -> hostState = if (cause != null) HostState.ERROR else HostState.DOWN } @@ -343,7 +346,7 @@ public class SimHost( * Convert flavor to machine model. */ private fun Flavor.toMachineModel(): MachineModel { - return MachineModel(simMachine!!.machineModel.cpu, MemoryUnit("Generic", "Generic", 3200.0, memorySize)) + return MachineModel(simMachine!!.machineModel.cpuModel, MemoryUnit("Generic", "Generic", 3200.0, memorySize)) } /** diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt index 30b50c4b2..8e7293c88 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt @@ -77,6 +77,7 @@ public class HostsProvisioningStep internal constructor( ctx.dispatcher.timeSource, graph, hostSpec.model, + hostSpec.cpuPowerModel, powerMux, ) diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java index 18214172b..d3edc9578 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java @@ -101,13 +101,13 @@ public String toString() { // Constructors //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public SimCpu(FlowGraph graph, CpuModel cpuModel, int id) { + public SimCpu(FlowGraph graph, CpuModel cpuModel, CpuPowerModel powerModel, int id) { super(graph); this.cpuModel = cpuModel; this.maxCapacity = this.cpuModel.getTotalCapacity(); // TODO: connect this to the front-end - this.cpuPowerModel = CpuPowerModels.linear(400, 200); + this.cpuPowerModel = powerModel; this.lastCounterUpdate = graph.getEngine().getClock().millis(); diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java index c7caa63f9..8364324a9 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java @@ -25,6 +25,7 @@ import java.time.InstantSource; import java.util.function.Consumer; import org.opendc.simulator.Multiplexer; +import org.opendc.simulator.compute.cpu.CpuPowerModel; import org.opendc.simulator.compute.cpu.SimCpu; import org.opendc.simulator.compute.memory.Memory; import org.opendc.simulator.compute.models.MachineModel; @@ -111,7 +112,11 @@ public double getCpuUsage() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public SimMachine( - FlowGraph graph, MachineModel machineModel, Multiplexer powerMux, Consumer completion) { + FlowGraph graph, + MachineModel machineModel, + Multiplexer powerMux, + CpuPowerModel cpuPowerModel, + Consumer completion) { this.graph = graph; this.machineModel = machineModel; this.clock = graph.getEngine().getClock(); @@ -121,7 +126,7 @@ public SimMachine( graph.addEdge(this.psu, powerMux); - this.cpu = new SimCpu(graph, this.machineModel.getCpu(), 0); + this.cpu = new SimCpu(graph, this.machineModel.getCpuModel(), cpuPowerModel, 0); graph.addEdge(this.cpu, this.psu); diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java index d6d139d7b..6c47fbe63 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java @@ -67,7 +67,7 @@ public MachineModel(List cpus, MemoryUnit memory) { /** * Return the processing units of this machine. */ - public CpuModel getCpu() { + public CpuModel getCpuModel() { return this.cpuModel; } diff --git a/site/docs/getting-started/1-first-experiment.md b/site/docs/getting-started/1-first-experiment.md index 313d757b6..9c84c4359 100644 --- a/site/docs/getting-started/1-first-experiment.md +++ b/site/docs/getting-started/1-first-experiment.md @@ -6,6 +6,18 @@ description: Designing a simple experiment Now that you have downloaded OpenDC, we will start creating a simple experiment. In this experiment we will compare the performance of a small, and a big data center on the same workload. +
+Expand this + +This is content +
+ +:::tip Answer +
+Expand for the Answer +
+::: + :::info Learning goal During this tutorial, we will learn how to create and execute a simple experiment in OpenDC. :::