summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/main
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-11-29 13:54:31 +0100
committerGitHub <noreply@github.com>2024-11-29 13:54:31 +0100
commita49a3878758438fe8d04bf4c4d3e3ffc5873aace (patch)
treed89f2fcc058a9b23b798c29402f8b8fd69beca41 /opendc-simulator/opendc-simulator-compute/src/main
parent124b40ce36fa03c5275e12ff5a020fc40fe5fd5a (diff)
Multiplexer update (#278)
* Fixed the Multiplexer.java to properly divide the supply over the different consumers. Fixed a bug where fragments were being loaded in reversed order. * Optimized the Multiplexer.java, by only updating the supply of the consumer that updated its demand when possible.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/main')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java12
1 files changed, 8 insertions, 4 deletions
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 d3edc957..63331a6c 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
@@ -40,8 +40,9 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
private double currentCpuDemand = 0.0f; // cpu capacity demanded by the mux
private double currentCpuUtilization = 0.0f;
- private double currentPowerDemand = 0.0f; // power demanded of the psu
private double currentCpuSupplied = 0.0f; // cpu capacity supplied to the mux
+
+ private double currentPowerDemand = 0.0f; // power demanded of the psu
private double currentPowerSupplied = 0.0f; // cpu capacity supplied by the psu
private double maxCapacity;
@@ -122,7 +123,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
public long onUpdate(long now) {
updateCounters(now);
- this.currentCpuUtilization = this.currentCpuDemand / this.maxCapacity;
+ this.currentCpuUtilization = Math.min(this.currentCpuDemand / this.maxCapacity, 1.0);
// Calculate Power Demand and send to PSU
double powerDemand = this.cpuPowerModel.computePower(this.currentCpuUtilization);
@@ -132,7 +133,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
}
// Calculate the amount of cpu this can provide
- double cpuSupply = this.currentCpuDemand;
+ double cpuSupply = Math.min(this.currentCpuDemand, this.maxCapacity);
if (cpuSupply != this.currentCpuSupplied) {
this.pushSupply(this.muxEdge, cpuSupply);
@@ -205,6 +206,8 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
this.currentCpuDemand = newCpuDemand;
this.currentCpuUtilization = this.currentCpuDemand / this.maxCapacity;
+ this.currentCpuUtilization = Math.min(this.currentCpuDemand / this.maxCapacity, 1.0);
+
// Calculate Power Demand and send to PSU
double powerDemand = this.cpuPowerModel.computePower(this.currentCpuUtilization);
@@ -223,7 +226,8 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
this.currentPowerSupplied = newPowerSupply;
// Calculate the amount of cpu this can provide
- double cpuSupply = this.currentCpuDemand;
+ double cpuSupply = Math.min(this.currentCpuDemand, this.maxCapacity);
+ ;
if (cpuSupply != this.currentCpuSupplied) {
this.pushSupply(this.muxEdge, cpuSupply);