summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-topology
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-04-22 14:32:53 +0200
committerGitHub <noreply@github.com>2024-04-22 14:32:53 +0200
commit7ffa97502d2725c1fe0a84677a654a5ea12cb454 (patch)
tree7f08b88a8e5bd1d39585b9cfcb530bd43f1a4733 /opendc-compute/opendc-compute-topology
parentd4c1d8468a17eb7adf8bf20949c2fdc4b2f93fec (diff)
Updated the power models and added tests (#222)
* Updated the power models and added tests * Updated test topologies
Diffstat (limited to 'opendc-compute/opendc-compute-topology')
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt6
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt10
2 files changed, 11 insertions, 5 deletions
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 e6b36dba..f8c7afbd 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
@@ -111,7 +111,7 @@ private fun HostJSONSpec.toHostSpecs(
): HostSpec {
val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpus.sumOf { it.coreCount })
- val units = cpus.flatMap { cpu -> List(cpu.count) { cpu.toProcessingUnit(unknownProcessingNode) }.flatten() }
+ val units = cpus.flatMap { cpu -> List(cpu.count) { cpu.toProcessingUnits(unknownProcessingNode) }.flatten() }
val unknownMemoryUnit = MemoryUnit(memory.vendor, memory.modelName, memory.memorySpeed, memory.memorySize)
val machineModel =
@@ -140,7 +140,9 @@ private fun HostJSONSpec.toHostSpecs(
*/
private var globalCoreId = 0
-private fun CPUJSONSpec.toProcessingUnit(unknownProcessingNode: ProcessingNode): List<ProcessingUnit> {
+private fun CPUJSONSpec.toProcessingUnits(unknownProcessingNode: ProcessingNode): List<ProcessingUnit> {
val units = List(coreCount) { ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed) }
return units
+
+// return listOf(ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed))
}
diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt
index 5e0af541..8f73f524 100644
--- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt
+++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt
@@ -64,7 +64,7 @@ public data class HostJSONSpec(
val name: String = "Host",
val cpus: List<CPUJSONSpec>,
val memory: MemoryJSONSpec,
- val powerModel: PowerModelJSONSpec = PowerModelJSONSpec("linear", 350.0, 200.0, 400.0),
+ val powerModel: PowerModelJSONSpec = PowerModelJSONSpec("linear", 350.0, 400.0, 200.0),
val count: Int = 1,
)
@@ -109,6 +109,10 @@ public data class MemoryJSONSpec(
public data class PowerModelJSONSpec(
val modelType: String,
val power: Double = 400.0,
- val idlePower: Double,
val maxPower: Double,
-)
+ val idlePower: Double,
+) {
+ init {
+ require(maxPower >= idlePower) { "The max power of a power model can not be less than the idle power" }
+ }
+}