Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connected the cpu power model given by the topology.json to SimCpu.java #274

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
/**
Expand All @@ -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,
)

Expand All @@ -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()
Expand All @@ -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
}
Expand Down Expand Up @@ -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))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class HostsProvisioningStep internal constructor(
ctx.dispatcher.timeSource,
graph,
hostSpec.model,
hostSpec.cpuPowerModel,
powerMux,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,7 +112,11 @@ public double getCpuUsage() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public SimMachine(
FlowGraph graph, MachineModel machineModel, Multiplexer powerMux, Consumer<Exception> completion) {
FlowGraph graph,
MachineModel machineModel,
Multiplexer powerMux,
CpuPowerModel cpuPowerModel,
Consumer<Exception> completion) {
this.graph = graph;
this.machineModel = machineModel;
this.clock = graph.getEngine().getClock();
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public MachineModel(List<CpuModel> cpus, MemoryUnit memory) {
/**
* Return the processing units of this machine.
*/
public CpuModel getCpu() {
public CpuModel getCpuModel() {
return this.cpuModel;
}

Expand Down
12 changes: 12 additions & 0 deletions site/docs/getting-started/1-first-experiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
<summary>Expand this</summary>

This is content
</details>

:::tip Answer
<details>
<summary>Expand for the Answer</summary>
</details>
:::

:::info Learning goal
During this tutorial, we will learn how to create and execute a simple experiment in OpenDC.
:::
Expand Down
Loading