diff options
34 files changed, 230 insertions, 367 deletions
diff --git a/buildSrc/src/main/kotlin/testing-conventions.gradle.kts b/buildSrc/src/main/kotlin/testing-conventions.gradle.kts index a7fa9da9..b374d0ff 100644 --- a/buildSrc/src/main/kotlin/testing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/testing-conventions.gradle.kts @@ -48,6 +48,10 @@ tasks.register<Test>("testsOn18") { }) useJUnitPlatform() + + minHeapSize = "512m" + maxHeapSize = "1024m" + jvmArgs = listOf("-XX:MaxMetaspaceSize=512m") } tasks.register<Test>("testsOn19") { @@ -56,4 +60,8 @@ tasks.register<Test>("testsOn19") { }) useJUnitPlatform() + + minHeapSize = "512m" + maxHeapSize = "1024m" + jvmArgs = listOf("-XX:MaxMetaspaceSize=512m") } diff --git a/gradle.properties b/gradle.properties index 06c56148..ad65d71b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ # # For Dokka https://github.com/Kotlin/dokka/issues/1405 -org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G +org.gradle.jvmargs=-XX:MaxMetaspaceSize=10G org.gradle.parallel=true org.gradle.caching=true @@ -199,7 +199,7 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +DEFAULT_JVM_OPTS='"-Xmx512m" "-Xms512m"' # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f..dd50e9c4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -34,7 +34,7 @@ set APP_HOME=%DIRNAME% for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" +set DEFAULT_JVM_OPTS="-Xmx512m" "-Xms512m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTrace.kt b/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTrace.kt index 6eb7a762..2ba3e4e3 100644 --- a/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTrace.kt +++ b/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTrace.kt @@ -40,7 +40,7 @@ import java.time.Instant public data class CarbonFragment( var startTime: Long, var endTime: Long, - var carbonIntensity: Float, + var carbonIntensity: Double, ) { init { require(endTime > startTime) { @@ -67,7 +67,7 @@ public class CarbonTrace(reports: List<CarbonFragment>? = null) { return index < numberOfReports } - public fun getCarbonIntensity(timestamp: Instant): Float { + public fun getCarbonIntensity(timestamp: Instant): Double { return getCarbonIntensity(timestamp.toEpochMilli()) } @@ -79,9 +79,9 @@ public class CarbonTrace(reports: List<CarbonFragment>? = null) { * @param timestamp * @return The carbon intensity at the given timestamp in gCO2/kWh */ - public fun getCarbonIntensity(timestamp: Long): Float { + public fun getCarbonIntensity(timestamp: Long): Double { if (reports == null) { - return 0.0f + return 0.0 } var currentFragment: CarbonFragment diff --git a/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTraceLoader.kt b/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTraceLoader.kt index 12340adf..b66aedf9 100644 --- a/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTraceLoader.kt +++ b/opendc-compute/opendc-compute-carbon/src/main/kotlin/org/opendc/compute/carbon/CarbonTraceLoader.kt @@ -56,7 +56,7 @@ public class CarbonTraceLoader { try { while (reader.nextRow()) { val startTime = reader.getInstant(startTimeCol)!! - val carbonIntensity = reader.getFloat(carbonIntensityCol) + val carbonIntensity = reader.getDouble(carbonIntensityCol) builder.add(startTime, carbonIntensity) } @@ -106,7 +106,7 @@ public class CarbonTraceLoader { */ fun add( startTime: Instant, - carbonIntensity: Float, + carbonIntensity: Double, ) { fragments.add( CarbonFragment(startTime.toEpochMilli(), Long.MAX_VALUE, carbonIntensity), diff --git a/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/hostfault/StartStopHostFault.kt b/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/hostfault/StartStopHostFault.kt index c7ddc5b5..06fad3e6 100644 --- a/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/hostfault/StartStopHostFault.kt +++ b/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/hostfault/StartStopHostFault.kt @@ -48,8 +48,6 @@ public class StartStopHostFault( for ((task, snapshot) in tasks.zip(snapshots)) { client.rescheduleTask(task, snapshot) } - - print("test") } delay(faultDuration) diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/host/HostModel.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/host/HostModel.java index 96236c5c..1ea73ea6 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/host/HostModel.java +++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/host/HostModel.java @@ -29,4 +29,4 @@ package org.opendc.compute.simulator.host; * @param coreCount The number of logical processing cores available for this host. * @param memoryCapacity The amount of memory available for this host in MB. */ -public record HostModel(float cpuCapacity, int coreCount, long memoryCapacity) {} +public record HostModel(double cpuCapacity, int coreCount, long memoryCapacity) {} diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/GuestCpuStats.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/GuestCpuStats.java index ea37f5f2..97202104 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/GuestCpuStats.java +++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/GuestCpuStats.java @@ -38,6 +38,6 @@ public record GuestCpuStats( long idleTime, long stealTime, long lostTime, - float capacity, - float usage, - float utilization) {} + double capacity, + double usage, + double utilization) {} diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostCpuStats.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostCpuStats.java index 3f2aab78..4817690a 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostCpuStats.java +++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostCpuStats.java @@ -40,7 +40,7 @@ public record HostCpuStats( long idleTime, long stealTime, long lostTime, - float capacity, - float demand, - float usage, - float utilization) {} + double capacity, + double demand, + double usage, + double utilization) {} diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostSystemStats.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostSystemStats.java index 353e62fa..aa292797 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostSystemStats.java +++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/telemetry/HostSystemStats.java @@ -42,8 +42,8 @@ public record HostSystemStats( Duration uptime, Duration downtime, Instant bootTime, - float powerDraw, - float energyUsage, + double powerDraw, + double energyUsage, int guestsTerminated, int guestsRunning, int guestsError, diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/ComputeMetricReader.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/ComputeMetricReader.kt index d5fb991d..c84b2a3f 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/ComputeMetricReader.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/ComputeMetricReader.kt @@ -340,21 +340,21 @@ public class ComputeMetricReader( get() = _guestsInvalid private var _guestsInvalid = 0 - override val cpuLimit: Float + override val cpuLimit: Double get() = _cpuLimit - private var _cpuLimit = 0.0f + private var _cpuLimit = 0.0 - override val cpuUsage: Float + override val cpuUsage: Double get() = _cpuUsage - private var _cpuUsage = 0.0f + private var _cpuUsage = 0.0 - override val cpuDemand: Float + override val cpuDemand: Double get() = _cpuDemand - private var _cpuDemand = 0.0f + private var _cpuDemand = 0.0 - override val cpuUtilization: Float + override val cpuUtilization: Double get() = _cpuUtilization - private var _cpuUtilization = 0.0f + private var _cpuUtilization = 0.0 override val cpuActiveTime: Long get() = _cpuActiveTime - previousCpuActiveTime @@ -376,22 +376,22 @@ public class ComputeMetricReader( private var _cpuLostTime = 0L private var previousCpuLostTime = 0L - override val powerDraw: Float + override val powerDraw: Double get() = _powerDraw - private var _powerDraw = 0.0f + private var _powerDraw = 0.0 - override val energyUsage: Float + override val energyUsage: Double get() = _energyUsage - previousEnergyUsage - private var _energyUsage = 0.0f - private var previousEnergyUsage = 0.0f + private var _energyUsage = 0.0 + private var previousEnergyUsage = 0.0 - override val carbonIntensity: Float + override val carbonIntensity: Double get() = _carbonIntensity - private var _carbonIntensity = 0.0f + private var _carbonIntensity = 0.0 - override val carbonEmission: Float + override val carbonEmission: Double get() = _carbonEmission - private var _carbonEmission = 0.0f + private var _carbonEmission = 0.0 override val uptime: Long get() = _uptime - previousUptime @@ -437,7 +437,7 @@ public class ComputeMetricReader( _energyUsage = hostSysStats.energyUsage _carbonIntensity = carbonTrace.getCarbonIntensity(timestampAbsolute) - _carbonEmission = carbonIntensity * (energyUsage / 3600000.0f) // convert energy usage from J to kWh + _carbonEmission = carbonIntensity * (energyUsage / 3600000.0) // convert energy usage from J to kWh _uptime = hostSysStats.uptime.toMillis() _downtime = hostSysStats.downtime.toMillis() _bootTime = hostSysStats.bootTime @@ -462,15 +462,15 @@ public class ComputeMetricReader( _guestsError = 0 _guestsInvalid = 0 - _cpuLimit = 0.0f - _cpuUsage = 0.0f - _cpuDemand = 0.0f - _cpuUtilization = 0.0f + _cpuLimit = 0.0 + _cpuUsage = 0.0 + _cpuDemand = 0.0 + _cpuUtilization = 0.0 - _powerDraw = 0.0f - _energyUsage = 0.0f - _carbonIntensity = 0.0f - _carbonEmission = 0.0f + _powerDraw = 0.0 + _energyUsage = 0.0 + _carbonIntensity = 0.0 + _carbonEmission = 0.0 } } @@ -569,9 +569,9 @@ public class ComputeMetricReader( get() = _finishTime private var _finishTime: Instant? = null - override val cpuLimit: Float + override val cpuLimit: Double get() = _cpuLimit - private var _cpuLimit = 0.0f + private var _cpuLimit = 0.0 override val cpuActiveTime: Long get() = _cpuActiveTime - previousCpuActiveTime @@ -625,7 +625,7 @@ public class ComputeMetricReader( _timestamp = now _timestampAbsolute = now + startTime - _cpuLimit = cpuStats?.capacity ?: 0.0f + _cpuLimit = cpuStats?.capacity ?: 0.0 _cpuActiveTime = cpuStats?.activeTime ?: 0 _cpuIdleTime = cpuStats?.idleTime ?: 0 _cpuStealTime = cpuStats?.stealTime ?: 0 @@ -658,7 +658,7 @@ public class ComputeMetricReader( previousCpuLostTime = _cpuLostTime _host = null - _cpuLimit = 0.0f + _cpuLimit = 0.0 } } } diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostInfo.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostInfo.kt index 1f1b9522..0220971b 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostInfo.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostInfo.kt @@ -30,6 +30,6 @@ public data class HostInfo( val name: String, val arch: String, val coreCount: Int, - val coreSpeed: Float, + val coreSpeed: Double, val memCapacity: Long, ) diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostTableReader.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostTableReader.kt index 5f09e7f5..a5a862ce 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostTableReader.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/HostTableReader.kt @@ -71,22 +71,22 @@ public interface HostTableReader : Exportable { /** * The capacity of the CPUs in the host (in MHz). */ - public val cpuLimit: Float + public val cpuLimit: Double /** * The usage of all CPUs in the host (in MHz). */ - public val cpuUsage: Float + public val cpuUsage: Double /** * The demand of all vCPUs of the guests (in MHz) */ - public val cpuDemand: Float + public val cpuDemand: Double /** * The CPU utilization of the host. */ - public val cpuUtilization: Float + public val cpuUtilization: Double /** * The duration (in ms) that a CPU was active in the host. @@ -111,22 +111,22 @@ public interface HostTableReader : Exportable { /** * The current power draw of the host in W. */ - public val powerDraw: Float + public val powerDraw: Double /** * The total energy consumption of the host since last sample in J. */ - public val energyUsage: Float + public val energyUsage: Double /** * The current carbon intensity of the host in gCO2 / kW. */ - public val carbonIntensity: Float + public val carbonIntensity: Double /** * The current carbon emission since the last deadline in g. */ - public val carbonEmission: Float + public val carbonEmission: Double /** * The uptime of the host since last time in ms. diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/TaskTableReader.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/TaskTableReader.kt index bc6a4edd..825019e8 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/TaskTableReader.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/table/TaskTableReader.kt @@ -93,7 +93,7 @@ public interface TaskTableReader : Exportable { /** * The capacity of the CPUs of Host on which the task is running (in MHz). */ - public val cpuLimit: Float + public val cpuLimit: Double /** * The duration (in seconds) that a CPU was active in the task. diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt index 9e637b1b..3329f19c 100644 --- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt +++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt @@ -122,7 +122,7 @@ private fun HostJSONSpec.toHostSpecs( CpuModel( globalCoreId++, cpu.coreCount, - cpu.coreSpeed.toMHz().toFloat(), + cpu.coreSpeed.toMHz(), ) } diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt index f22bc1d1..786ed82f 100644 --- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt +++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt @@ -217,7 +217,7 @@ public class ComputeWorkloadLoader( usage: Double, cores: Int, ) { - totalLoad += (usage * duration.toMillis()) / 1000.0 // avg MHz * duration = MFLOPs + totalLoad += (usage * duration.toMillis()) / 1000 // avg MHz * duration = MFLOPs builder.add(duration.toMillis(), usage, cores) } diff --git a/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/ScenarioIntegrationTest.kt b/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/ScenarioIntegrationTest.kt index 41d18225..3fd27175 100644 --- a/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/ScenarioIntegrationTest.kt +++ b/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/ScenarioIntegrationTest.kt @@ -247,8 +247,8 @@ class ScenarioIntegrationTest { assertAll( { assertEquals(0, monitor.tasksTerminated) { "Idle time incorrect" } }, { assertEquals(1, monitor.tasksCompleted) { "Idle time incorrect" } }, - { assertEquals(4296000, monitor.idleTime) { "Idle time incorrect" } }, - { assertEquals(5004000, monitor.activeTime) { "Active time incorrect" } }, + { assertEquals(4297000, monitor.idleTime) { "Idle time incorrect" } }, + { assertEquals(5003000, monitor.activeTime) { "Active time incorrect" } }, { assertEquals(0, monitor.stealTime) { "Steal time incorrect" } }, { assertEquals(0, monitor.lostTime) { "Lost time incorrect" } }, { assertEquals(2860800.0, monitor.energyUsage, 1E4) { "Incorrect energy usage" } }, @@ -288,11 +288,11 @@ class ScenarioIntegrationTest { // Note that these values have been verified beforehand assertAll( - { assertEquals(1803918601, monitor.idleTime) { "Idle time incorrect" } }, - { assertEquals(787181585, monitor.activeTime) { "Active time incorrect" } }, + { assertEquals(1803918472, monitor.idleTime) { "Idle time incorrect" } }, + { assertEquals(787181528, monitor.activeTime) { "Active time incorrect" } }, { assertEquals(0, monitor.stealTime) { "Steal time incorrect" } }, { assertEquals(0, monitor.lostTime) { "Lost time incorrect" } }, - { assertEquals(6.756768E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } }, + { assertEquals(6.7565629E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } }, ) } @@ -335,11 +335,11 @@ class ScenarioIntegrationTest { { assertEquals(0, monitor.tasksActive, "All VMs should finish after a run") }, { assertEquals(0, monitor.attemptsFailure, "No VM should be unscheduled") }, { assertEquals(0, monitor.tasksPending, "No VM should not be in the queue") }, - { assertEquals(43101788258, monitor.idleTime) { "Incorrect idle time" } }, - { assertEquals(3489412702, monitor.activeTime) { "Incorrect active time" } }, + { assertEquals(43101787433, monitor.idleTime) { "Incorrect idle time" } }, + { assertEquals(3489412567, monitor.activeTime) { "Incorrect active time" } }, { assertEquals(0, monitor.stealTime) { "Incorrect steal time" } }, { assertEquals(0, monitor.lostTime) { "Incorrect lost time" } }, - { assertEquals(1.0016592256E10, monitor.energyUsage, 1E4) { "Incorrect energy usage" } }, + { assertEquals(1.0016123392181786E10, monitor.energyUsage, 1E4) { "Incorrect energy usage" } }, ) } 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 60c877e9..ac3bff74 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 @@ -38,17 +38,17 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer private final CpuPowerModel cpuPowerModel; - private float currentCpuDemand = 0.0f; // cpu capacity demanded by the mux - private float currentCpuUtilization = 0.0f; - private float currentPowerDemand = 0.0f; // power demanded of the psu - private float currentCpuSupplied = 0.0f; // cpu capacity supplied to the mux - private float currentPowerSupplied = 0.0f; // cpu capacity supplied by the psu + 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 currentPowerSupplied = 0.0f; // cpu capacity supplied by the psu - private float maxCapacity; + private double maxCapacity; private PerformanceCounters performanceCounters = new PerformanceCounters(); private long lastCounterUpdate; - private final float cpuFrequencyInv; + private final double cpuFrequencyInv; private FlowEdge muxEdge; private FlowEdge psuEdge; @@ -68,7 +68,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer } @Override - public float getCapacity() { + public double getCapacity() { return maxCapacity; } @@ -123,8 +123,8 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer updateCounters(now); // Calculate Power Demand and send to PSU - // TODO: look at the float / double thing - float powerDemand = (float) this.cpuPowerModel.computePower((double) this.currentCpuUtilization); + // TODO: look at the double / double thing + double powerDemand = (double) this.cpuPowerModel.computePower((double) this.currentCpuUtilization); if (powerDemand != this.currentPowerDemand) { this.pushDemand(this.psuEdge, powerDemand); @@ -133,7 +133,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer // Calculate the amount of cpu this can provide // TODO: This should be based on the provided power - float cpuSupply = this.currentCpuDemand; + double cpuSupply = this.currentCpuDemand; if (cpuSupply != this.currentCpuSupplied) { this.pushSupply(this.muxEdge, cpuSupply); @@ -158,11 +158,11 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer long delta = now - lastUpdate; if (delta > 0) { - float demand = this.currentCpuDemand; - float rate = this.currentCpuSupplied; - float capacity = this.maxCapacity; + double demand = this.currentCpuDemand; + double rate = this.currentCpuSupplied; + double capacity = this.maxCapacity; - final float factor = this.cpuFrequencyInv * delta; + final double factor = this.cpuFrequencyInv * delta; this.performanceCounters.addCpuActiveTime(Math.round(rate * factor)); this.performanceCounters.addCpuIdleTime(Math.round((capacity - rate) * factor)); @@ -182,7 +182,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer * Push new demand to the psu */ @Override - public void pushDemand(FlowEdge supplierEdge, float newPowerDemand) { + public void pushDemand(FlowEdge supplierEdge, double newPowerDemand) { this.psuEdge.pushDemand(newPowerDemand); } @@ -190,7 +190,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer * Push updated supply to the mux */ @Override - public void pushSupply(FlowEdge consumerEdge, float newCpuSupply) { + public void pushSupply(FlowEdge consumerEdge, double newCpuSupply) { updateCounters(); this.currentCpuSupplied = newCpuSupply; this.muxEdge.pushSupply(newCpuSupply); @@ -200,7 +200,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer * Handle new demand coming in from the mux */ @Override - public void handleDemand(FlowEdge consumerEdge, float newCpuDemand) { + public void handleDemand(FlowEdge consumerEdge, double newCpuDemand) { if (newCpuDemand == this.currentCpuDemand) { return; } @@ -216,7 +216,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer * Handle updated supply from the psu */ @Override - public void handleSupply(FlowEdge supplierEdge, float newPowerSupply) { + public void handleSupply(FlowEdge supplierEdge, double newPowerSupply) { // TODO: Implement this updateCounters(); this.currentPowerSupplied = newPowerSupply; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/PerformanceCounters.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/PerformanceCounters.java index b1e30e5c..f5b8d27d 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/PerformanceCounters.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/PerformanceCounters.java @@ -28,9 +28,9 @@ public class PerformanceCounters { private long cpuStealTime = 0; private long cpuLostTime = 0; - private float cpuCapacity = 0.0f; - private float cpuDemand = 0.0f; - private float cpuSupply = 0.0f; + private double cpuCapacity = 0.0f; + private double cpuDemand = 0.0f; + private double cpuSupply = 0.0f; public long getCpuActiveTime() { return cpuActiveTime; @@ -76,27 +76,27 @@ public class PerformanceCounters { this.cpuLostTime = cpuLostTime; } - public float getCpuCapacity() { + public double getCpuCapacity() { return cpuCapacity; } - public void setCpuCapacity(float cpuCapacity) { + public void setCpuCapacity(double cpuCapacity) { this.cpuCapacity = cpuCapacity; } - public float getCpuDemand() { + public double getCpuDemand() { return cpuDemand; } - public void setCpuDemand(float cpuDemand) { + public void setCpuDemand(double cpuDemand) { this.cpuDemand = cpuDemand; } - public float getCpuSupply() { + public double getCpuSupply() { return cpuSupply; } - public void setCpuSupply(float cpuSupply) { + public void setCpuSupply(double cpuSupply) { this.cpuSupply = cpuSupply; } } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java index 3bc3d2b4..21f59cf6 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java @@ -46,9 +46,9 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli private FlowEdge cpuEdge; // The edge to the cpu private FlowEdge workloadEdge; // The edge to the workload - private float cpuDemand; - private float cpuSupply; - private float cpuCapacity; + private double cpuDemand; + private double cpuSupply; + private double cpuCapacity; private PerformanceCounters performanceCounters = new PerformanceCounters(); @@ -66,19 +66,19 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli return activeWorkload; } - public float getDemand() { + public double getDemand() { return cpuDemand; } - public void setDemand(float demand) { + public void setDemand(double demand) { this.cpuDemand = demand; } - public float getCpuCapacity() { + public double getCpuCapacity() { return cpuCapacity; } - public void setCpuCapacity(float cpuCapacity) { + public void setCpuCapacity(double cpuCapacity) { this.cpuCapacity = cpuCapacity; } @@ -185,7 +185,7 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli * Push demand to the cpuMux if the demand has changed **/ @Override - public void pushDemand(FlowEdge supplierEdge, float newDemand) { + public void pushDemand(FlowEdge supplierEdge, double newDemand) { this.cpuEdge.pushDemand(newDemand); } @@ -193,15 +193,15 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli * Push supply to the workload if the supply has changed **/ @Override - public void pushSupply(FlowEdge consumerEdge, float newSupply) { - this.workloadEdge.pushDemand(newSupply); + public void pushSupply(FlowEdge consumerEdge, double newSupply) { + this.workloadEdge.pushSupply(newSupply); } /** * Handle new demand from the workload by sending it through to the cpuMux **/ @Override - public void handleDemand(FlowEdge consumerEdge, float newDemand) { + public void handleDemand(FlowEdge consumerEdge, double newDemand) { if (this.cpuDemand == newDemand) { return; } @@ -216,7 +216,7 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli * Handle a new supply pushed by the cpuMux by sending it through to the workload **/ @Override - public void handleSupply(FlowEdge supplierEdge, float newCpuSupply) { + public void handleSupply(FlowEdge supplierEdge, double newCpuSupply) { if (newCpuSupply == this.cpuSupply) { return; } @@ -234,7 +234,7 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli } @Override - public float getCapacity() { + public double getCapacity() { return this.cpuCapacity; } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/CpuModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/CpuModel.java index 88e17941..ab829bc4 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/CpuModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/CpuModel.java @@ -30,8 +30,8 @@ import java.util.Objects; public final class CpuModel { private final int id; private final int coreCount; - private final float coreSpeed; - private final float totalCapacity; + private final double coreSpeed; + private final double totalCapacity; private final String vendor; private final String modelName; @@ -47,7 +47,7 @@ public final class CpuModel { * @param modelName The name of the CPU * @param arch The architecture of the CPU */ - public CpuModel(int id, int coreCount, float coreSpeed, String vendor, String modelName, String arch) { + public CpuModel(int id, int coreCount, double coreSpeed, String vendor, String modelName, String arch) { this.id = id; this.coreCount = coreCount; this.coreSpeed = coreSpeed; @@ -57,7 +57,7 @@ public final class CpuModel { this.arch = arch; } - public CpuModel(int id, int coreCount, float coreSpeed) { + public CpuModel(int id, int coreCount, double coreSpeed) { this(id, coreCount, coreSpeed, "unkown", "unkown", "unkown"); } @@ -78,14 +78,14 @@ public final class CpuModel { /** * Return the clock rate of a single core of the CPU MHz. */ - public float getCoreSpeed() { + public double getCoreSpeed() { return coreSpeed; } /** * Return the clock rate of the CPU in MHz. */ - public float getTotalCapacity() { + public double getTotalCapacity() { return totalCapacity; } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java index 9b4d6a33..58a6b847 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java @@ -37,13 +37,13 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier { private long lastUpdate; - private float powerDemand = 0.0f; - private float powerSupplied = 0.0f; - private float totalEnergyUsage = 0.0f; + private double powerDemand = 0.0f; + private double powerSupplied = 0.0f; + private double totalEnergyUsage = 0.0f; private FlowEdge cpuEdge; - private float capacity = Long.MAX_VALUE; + private double capacity = Long.MAX_VALUE; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Basic Getters and Setters @@ -70,20 +70,20 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier { /** * Return the instantaneous power usage of the machine (in W) measured at the InPort of the power supply. */ - public float getPowerDraw() { + public double getPowerDraw() { return this.powerSupplied; } /** * Return the cumulated energy usage of the machine (in J) measured at the InPort of the powers supply. */ - public float getEnergyUsage() { + public double getEnergyUsage() { updateCounters(); return totalEnergyUsage; } @Override - public float getCapacity() { + public double getCapacity() { return this.capacity; } @@ -106,7 +106,7 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier { @Override public long onUpdate(long now) { updateCounters(); - float powerSupply = this.powerDemand; + double powerSupply = this.powerDemand; if (powerSupply != this.powerSupplied) { this.pushSupply(this.cpuEdge, powerSupply); @@ -129,7 +129,7 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier { long duration = now - lastUpdate; if (duration > 0) { // Compute the energy usage of the machine - this.totalEnergyUsage += (float) (this.powerSupplied * duration * 0.001); + this.totalEnergyUsage += (double) (this.powerSupplied * duration * 0.001); } } @@ -138,7 +138,7 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @Override - public void handleDemand(FlowEdge consumerEdge, float newPowerDemand) { + public void handleDemand(FlowEdge consumerEdge, double newPowerDemand) { if (newPowerDemand == this.powerDemand) { return; } @@ -148,7 +148,7 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier { } @Override - public void pushSupply(FlowEdge consumerEdge, float newSupply) { + public void pushSupply(FlowEdge consumerEdge, double newSupply) { if (newSupply == this.powerSupplied) { return; } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java index 8f0fb130..381a8754 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java @@ -35,14 +35,14 @@ import org.opendc.simulator.engine.FlowSupplier; public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer { private long lastUpdate; - private float powerDemand = 0.0f; - private float powerSupplied = 0.0f; - private float totalEnergyUsage = 0.0f; + private double powerDemand = 0.0; + private double powerSupplied = 0.0; + private double totalEnergyUsage = 0.0; private FlowEdge cpuEdge; private FlowEdge powerEdge; - private float capacity = Long.MAX_VALUE; + private double capacity = Long.MAX_VALUE; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Basic Getters and Setters @@ -69,20 +69,20 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer /** * Return the instantaneous power usage of the machine (in W) measured at the InPort of the power supply. */ - public float getPowerDraw() { + public double getPowerDraw() { return this.powerSupplied; } /** * Return the cumulated energy usage of the machine (in J) measured at the InPort of the powers supply. */ - public float getEnergyUsage() { + public double getEnergyUsage() { updateCounters(); return totalEnergyUsage; } @Override - public float getCapacity() { + public double getCapacity() { return this.capacity; } @@ -103,7 +103,7 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer @Override public long onUpdate(long now) { updateCounters(); - float powerSupply = this.powerDemand; + double powerSupply = this.powerDemand; if (powerSupply != this.powerSupplied) { this.pushSupply(this.cpuEdge, powerSupply); @@ -126,7 +126,7 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer long duration = now - lastUpdate; if (duration > 0) { // Compute the energy usage of the psu - this.totalEnergyUsage += (float) (this.powerSupplied * duration * 0.001); + this.totalEnergyUsage += (double) (this.powerSupplied * duration * 0.001); } } @@ -135,7 +135,7 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @Override - public void pushDemand(FlowEdge supplierEdge, float newDemand) { + public void pushDemand(FlowEdge supplierEdge, double newDemand) { if (newDemand == this.powerDemand) { return; } @@ -145,7 +145,7 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer } @Override - public void pushSupply(FlowEdge consumerEdge, float newSupply) { + public void pushSupply(FlowEdge consumerEdge, double newSupply) { if (newSupply == this.powerSupplied) { return; } @@ -155,7 +155,7 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer } @Override - public void handleDemand(FlowEdge consumerEdge, float newPowerDemand) { + public void handleDemand(FlowEdge consumerEdge, double newPowerDemand) { if (newPowerDemand == this.powerDemand) { return; } @@ -165,7 +165,7 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer } @Override - public void handleSupply(FlowEdge supplierEdge, float newPowerSupply) { + public void handleSupply(FlowEdge supplierEdge, double newPowerSupply) { if (newPowerSupply == this.powerSupplied) { return; } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java index 7f1cf060..f91c363d 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java @@ -35,13 +35,13 @@ final class SimChainWorkload extends SimWorkload implements FlowSupplier { private int workloadIndex; private SimWorkload activeWorkload; - private float demand = 0.0f; - private float supply = 0.0f; + private double demand = 0.0f; + private double supply = 0.0f; private FlowEdge workloadEdge; private FlowEdge machineEdge; - private float capacity = 0; + private double capacity = 0; private long checkpointInterval = 0; private long checkpointDuration = 0; @@ -55,7 +55,7 @@ final class SimChainWorkload extends SimWorkload implements FlowSupplier { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @Override - public float getCapacity() { + public double getCapacity() { return this.capacity; } @@ -194,7 +194,7 @@ final class SimChainWorkload extends SimWorkload implements FlowSupplier { * @param newDemand */ @Override - public void pushDemand(FlowEdge supplierEdge, float newDemand) { + public void pushDemand(FlowEdge supplierEdge, double newDemand) { this.machineEdge.pushDemand(newDemand); } @@ -205,7 +205,7 @@ final class SimChainWorkload extends SimWorkload implements FlowSupplier { * @param newSupply */ @Override - public void pushSupply(FlowEdge consumerEdge, float newSupply) { + public void pushSupply(FlowEdge consumerEdge, double newSupply) { this.workloadEdge.pushSupply(newSupply); } @@ -216,7 +216,7 @@ final class SimChainWorkload extends SimWorkload implements FlowSupplier { * @param newDemand */ @Override - public void handleDemand(FlowEdge consumerEdge, float newDemand) { + public void handleDemand(FlowEdge consumerEdge, double newDemand) { if (newDemand == this.demand) { return; } @@ -232,7 +232,7 @@ final class SimChainWorkload extends SimWorkload implements FlowSupplier { * @param newSupply */ @Override - public void handleSupply(FlowEdge supplierEdge, float newSupply) { + public void handleSupply(FlowEdge supplierEdge, double newSupply) { if (newSupply == this.supply) { return; } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java index b6f98344..59e38ce1 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java @@ -37,8 +37,8 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { private long startOfFragment; private FlowEdge machineEdge; - private float currentDemand; - private float currentSupply; + private double currentDemand; + private double currentSupply; private long checkpointInterval; private long checkpointDuration; @@ -98,7 +98,7 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { graph.addEdge(this, supplier); this.currentFragment = this.getNextFragment(); - pushDemand(machineEdge, (float) this.currentFragment.cpuUsage()); + pushDemand(machineEdge, (double) this.currentFragment.cpuUsage()); this.startOfFragment = now; } @@ -135,7 +135,7 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { this.startOfFragment = now - passedTime; // Change the cpu Usage to the new Fragment - pushDemand(machineEdge, (float) this.currentFragment.cpuUsage()); + pushDemand(machineEdge, (double) this.currentFragment.cpuUsage()); // Return the time when the current fragment will complete return this.startOfFragment + duration; @@ -190,7 +190,7 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { this.fragmentIndex = -1; this.currentFragment = getNextFragment(); - pushDemand(this.machineEdge, (float) this.currentFragment.cpuUsage()); + pushDemand(this.machineEdge, (double) this.currentFragment.cpuUsage()); this.startOfFragment = now; this.invalidate(); @@ -206,7 +206,7 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { // Start the first Fragment this.currentFragment = this.remainingFragments.pop(); - pushDemand(this.machineEdge, (float) this.currentFragment.cpuUsage()); + pushDemand(this.machineEdge, (double) this.currentFragment.cpuUsage()); this.startOfFragment = offset; this.invalidate(); @@ -223,7 +223,7 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { * @param newSupply */ @Override - public void handleSupply(FlowEdge supplierEdge, float newSupply) { + public void handleSupply(FlowEdge supplierEdge, double newSupply) { if (newSupply == this.currentSupply) { return; } @@ -238,7 +238,7 @@ public class SimTraceWorkload extends SimWorkload implements FlowConsumer { * @param newDemand */ @Override - public void pushDemand(FlowEdge supplierEdge, float newDemand) { + public void pushDemand(FlowEdge supplierEdge, double newDemand) { if (newDemand == this.currentDemand) { return; } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java index 115689df..8e068e1f 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java @@ -79,7 +79,7 @@ public class TraceWorkload implements Workload { } public static Builder builder() { - return builder(0L, 0L, 0L); + return builder(0L, 0L, 0.0); } public static Builder builder(long checkpointInterval, long checkpointDuration, double checkpointIntervalScaling) { 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 2b6a922e..173c60e7 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 @@ -22,18 +22,10 @@ package org.opendc.simulator.compute -import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.opendc.simulator.compute.cpu.CpuPowerModels -import org.opendc.simulator.compute.machine.SimMachine import org.opendc.simulator.compute.models.CpuModel import org.opendc.simulator.compute.models.MachineModel import org.opendc.simulator.compute.models.MemoryUnit -import org.opendc.simulator.compute.workload.TraceWorkload -import org.opendc.simulator.engine.FlowEngine -import org.opendc.simulator.kotlin.runSimulation -import java.util.concurrent.ThreadLocalRandom /** * Test suite for the [SimBareMetalMachine] class. @@ -48,7 +40,7 @@ class SimMachineTest { CpuModel( 0, 2, - 1000.0f, + 1000.0, "Intel", "Xeon", "amd64", @@ -75,33 +67,33 @@ class SimMachineTest { // assertEquals(1000, timeSource.millis()) // } - @Test - fun testTraceWorkload() = - runSimulation { - val random = ThreadLocalRandom.current() - val builder = TraceWorkload.builder() - repeat(100) { - builder.add(1000, random.nextDouble(0.0, 4500.0), 1) - } - val traceWorkload = builder.build() - - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val simMachine = - SimMachine( - graph, - machineModel, - CpuPowerModels.constant(0.0), - ) { cause -> - } - - val virtualMachine = - simMachine.startWorkload(traceWorkload) { cause -> - assertEquals(100000, timeSource.millis()) - } - - // Two cores execute 1000 MFlOps per second (1000 ms) - } +// @Test +// fun testTraceWorkload() = +// runSimulation { +// val random = ThreadLocalRandom.current() +// val builder = TraceWorkload.builder() +// repeat(100) { +// builder.add(1000, random.nextDouble(0.0, 4500.0), 1) +// } +// val traceWorkload = builder.build() +// +// val engine = FlowEngine.create(dispatcher) +// val graph = engine.newGraph() +// val simMachine = +// SimMachine( +// graph, +// machineModel, +// CpuPowerModels.constant(0.0), +// ) { cause -> +// } +// +// val virtualMachine = +// simMachine.startWorkload(traceWorkload) { cause -> +// assertEquals(100000, timeSource.millis()) +// } +// +// // Two cores execute 1000 MFlOps per second (1000 ms) +// } // @Test // fun testDualSocketMachine() = diff --git a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt deleted file mode 100644 index 0ab051a4..00000000 --- a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.simulator.flow2 - -import kotlinx.coroutines.launch -import org.opendc.simulator.flow2.mux.MaxMinFlowMultiplexer -import org.opendc.simulator.flow2.sink.SimpleFlowSink -import org.opendc.simulator.flow2.source.TraceFlowSource -import org.opendc.simulator.flow2.util.FlowTransformer -import org.opendc.simulator.flow2.util.FlowTransforms -import org.opendc.simulator.kotlin.runSimulation -import org.openjdk.jmh.annotations.Benchmark -import org.openjdk.jmh.annotations.Fork -import org.openjdk.jmh.annotations.Measurement -import org.openjdk.jmh.annotations.Scope -import org.openjdk.jmh.annotations.Setup -import org.openjdk.jmh.annotations.State -import org.openjdk.jmh.annotations.Warmup -import java.util.concurrent.ThreadLocalRandom -import java.util.concurrent.TimeUnit - -@State(Scope.Thread) -@Fork(1) -@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) -@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) -class FlowBenchmarks { - private lateinit var trace: TraceFlowSource.Trace - - @Setup - fun setUp() { - val random = ThreadLocalRandom.current() - val traceSize = 10_000_000 - trace = - TraceFlowSource.Trace( - LongArray(traceSize) { (it + 1) * 1000L }, - FloatArray(traceSize) { random.nextFloat(0.0f, 4500.0f) }, - traceSize, - ) - } - - @Benchmark - fun benchmarkSink() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val sink = SimpleFlowSink(graph, 4200.0f) - val source = TraceFlowSource(graph, trace) - graph.connect(source.output, sink.input) - } - } - - @Benchmark - fun benchmarkForward() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val sink = SimpleFlowSink(graph, 4200.0f) - val source = TraceFlowSource(graph, trace) - val forwarder = FlowTransformer(graph, FlowTransforms.noop()) - - graph.connect(source.output, forwarder.input) - graph.connect(forwarder.output, sink.input) - } - } - - @Benchmark - fun benchmarkMuxMaxMinSingleSource() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val switch = MaxMinFlowMultiplexer(graph) - - val sinkA = SimpleFlowSink(graph, 3000.0f) - val sinkB = SimpleFlowSink(graph, 3000.0f) - - graph.connect(switch.newOutPort(), sinkA.input) - graph.connect(switch.newOutPort(), sinkB.input) - - val source = TraceFlowSource(graph, trace) - graph.connect(source.output, switch.newInput()) - } - } - - @Benchmark - fun benchmarkMuxMaxMinTripleSource() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val switch = MaxMinFlowMultiplexer(graph) - - val sinkA = SimpleFlowSink(graph, 3000.0f) - val sinkB = SimpleFlowSink(graph, 3000.0f) - - graph.connect(switch.newOutPort(), sinkA.input) - graph.connect(switch.newOutPort(), sinkB.input) - - repeat(3) { - launch { - val source = TraceFlowSource(graph, trace) - graph.connect(source.output, switch.newInput()) - } - } - } - } -} diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java index 0af2499a..a87ded8d 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java @@ -34,26 +34,26 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer private ArrayList<FlowEdge> consumerEdges = new ArrayList<>(); private FlowEdge supplierEdge; - private ArrayList<Float> demands = new ArrayList<>(); // What is demanded by the consumers - private ArrayList<Float> supplies = new ArrayList<>(); // What is supplied to the consumers + private ArrayList<Double> demands = new ArrayList<>(); // What is demanded by the consumers + private ArrayList<Double> supplies = new ArrayList<>(); // What is supplied to the consumers - private float totalDemand; // The total demand of all the consumers - private float totalSupply; // The total supply from the supplier - private float capacity; // What is the max capacity + private double totalDemand; // The total demand of all the consumers + private double totalSupply; // The total supply from the supplier + private double capacity; // What is the max capacity public Multiplexer(FlowGraph graph) { super(graph); } - public float getTotalDemand() { + public double getTotalDemand() { return totalDemand; } - public float getTotalSupply() { + public double getTotalSupply() { return totalSupply; } - public float getCapacity() { + public double getCapacity() { return capacity; } @@ -67,7 +67,7 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer } } - float totalSupply = 0; + double totalSupply = 0; for (int i = 0; i < this.consumerEdges.size(); i++) { this.pushSupply(this.consumerEdges.get(i), this.supplies.get(i)); totalSupply += this.supplies.get(i); @@ -83,8 +83,8 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer return Long.MAX_VALUE; } - private static float redistributeSupply( - ArrayList<FlowEdge> consumerEdges, ArrayList<Float> supplies, float capacity) { + private static double redistributeSupply( + ArrayList<FlowEdge> consumerEdges, ArrayList<Double> supplies, double capacity) { final long[] consumers = new long[consumerEdges.size()]; for (int i = 0; i < consumers.length; i++) { @@ -94,24 +94,24 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer break; } - consumers[i] = ((long) Float.floatToRawIntBits(consumer.getDemand()) << 32) | (i & 0xFFFFFFFFL); + consumers[i] = (Double.doubleToRawLongBits(consumer.getDemand()) << 32) | (i & 0xFFFFFFFFL); } Arrays.sort(consumers); - float availableCapacity = capacity; + double availableCapacity = capacity; int inputSize = consumers.length; for (int i = 0; i < inputSize; i++) { long v = consumers[i]; int slot = (int) v; - float d = Float.intBitsToFloat((int) (v >> 32)); + double d = Double.longBitsToDouble((int) (v >> 32)); if (d == 0.0) { continue; } - float availableShare = availableCapacity / (inputSize - i); - float r = Math.min(d, availableShare); + double availableShare = availableCapacity / (inputSize - i); + double r = Math.min(d, availableShare); supplies.set(slot, r); // Update the rates availableCapacity -= r; @@ -128,8 +128,8 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer @Override public void addConsumerEdge(FlowEdge consumerEdge) { this.consumerEdges.add(consumerEdge); - this.demands.add(0f); - this.supplies.add(0f); + this.demands.add(0.0); + this.supplies.add(0.0); } @Override @@ -164,7 +164,7 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer } @Override - public void handleDemand(FlowEdge consumerEdge, float newDemand) { + public void handleDemand(FlowEdge consumerEdge, double newDemand) { int idx = consumerEdges.indexOf(consumerEdge); if (idx == -1) { @@ -172,14 +172,14 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer return; } - float prevDemand = demands.get(idx); + double prevDemand = demands.get(idx); demands.set(idx, newDemand); this.totalDemand += (newDemand - prevDemand); } @Override - public void handleSupply(FlowEdge supplierEdge, float newSupply) { + public void handleSupply(FlowEdge supplierEdge, double newSupply) { if (newSupply == this.totalSupply) { return; } @@ -188,22 +188,18 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer } @Override - public void pushDemand(FlowEdge supplierEdge, float newDemand) { + public void pushDemand(FlowEdge supplierEdge, double newDemand) { this.supplierEdge.pushDemand(newDemand); } @Override - public void pushSupply(FlowEdge consumerEdge, float newSupply) { + public void pushSupply(FlowEdge consumerEdge, double newSupply) { int idx = consumerEdges.indexOf(consumerEdge); if (idx == -1) { System.out.println("Error (Multiplexer): pushing supply to an unknown consumer"); } - if (newSupply == supplies.get(idx)) { - return; - } - supplies.set(idx, newSupply); consumerEdge.pushSupply(newSupply); } diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java index 7ba5dea7..ddb40794 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java @@ -24,9 +24,9 @@ package org.opendc.simulator.engine; public interface FlowConsumer { - void handleSupply(FlowEdge supplierEdge, float newSupply); + void handleSupply(FlowEdge supplierEdge, double newSupply); - void pushDemand(FlowEdge supplierEdge, float newDemand); + void pushDemand(FlowEdge supplierEdge, double newDemand); void addSupplierEdge(FlowEdge supplierEdge); diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java index 0edc9e68..d89740a2 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java @@ -32,10 +32,10 @@ public class FlowEdge { private FlowConsumer consumer; private FlowSupplier supplier; - private float demand = 0.0f; - private float supply = 0.0f; + private double demand = 0.0; + private double supply = 0.0; - private float capacity; + private double capacity; public FlowEdge(FlowConsumer consumer, FlowSupplier supplier) { if (!(consumer instanceof FlowNode)) { @@ -74,25 +74,22 @@ public class FlowEdge { return supplier; } - public float getCapacity() { + public double getCapacity() { return capacity; } - public float getDemand() { + public double getDemand() { return this.demand; } - public float getSupply() { + public double getSupply() { return this.supply; } /** * Push new demand from the Consumer to the Supplier */ - public void pushDemand(float newDemand) { - if (newDemand == this.demand) { - return; - } + public void pushDemand(double newDemand) { this.demand = newDemand; this.supplier.handleDemand(this, newDemand); @@ -102,10 +99,7 @@ public class FlowEdge { /** * Push new supply from the Supplier to the Consumer */ - public void pushSupply(float newSupply) { - if (newSupply == this.supply) { - return; - } + public void pushSupply(double newSupply) { this.supply = newSupply; this.consumer.handleSupply(this, newSupply); diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java index 87729fca..955f4943 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java @@ -24,13 +24,13 @@ package org.opendc.simulator.engine; public interface FlowSupplier { - void handleDemand(FlowEdge consumerEdge, float newDemand); + void handleDemand(FlowEdge consumerEdge, double newDemand); - void pushSupply(FlowEdge consumerEdge, float newSupply); + void pushSupply(FlowEdge consumerEdge, double newSupply); void addConsumerEdge(FlowEdge consumerEdge); void removeConsumerEdge(FlowEdge consumerEdge); - float getCapacity(); + double getCapacity(); } diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt index 2dd0c20f..70152b2c 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt @@ -326,7 +326,7 @@ public class OpenDCRunner( CpuModel( 0, cpu.numberOfCores, - cpu.clockRateMhz.toFloat(), + cpu.clockRateMhz, "Intel", "amd64", cpu.name, |
