diff options
Diffstat (limited to 'opendc-compute/opendc-compute-topology/src')
3 files changed, 66 insertions, 13 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 b6c945d2..b52608a9 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 @@ -31,10 +31,13 @@ import org.opendc.compute.topology.specs.HostJSONSpec import org.opendc.compute.topology.specs.HostSpec import org.opendc.compute.topology.specs.PowerSourceSpec import org.opendc.compute.topology.specs.TopologySpec -import org.opendc.simulator.compute.cpu.getPowerModel import org.opendc.simulator.compute.models.CpuModel +import org.opendc.simulator.compute.models.GpuModel import org.opendc.simulator.compute.models.MachineModel import org.opendc.simulator.compute.models.MemoryUnit +import org.opendc.simulator.compute.power.getPowerModel +import org.opendc.simulator.engine.graph.distributionPolicies.DistributionPolicyFactory +import org.opendc.simulator.engine.graph.distributionPolicies.DistributionPolicyFactory.DistributionPolicyType import java.io.File import java.io.InputStream @@ -166,29 +169,63 @@ private fun HostJSONSpec.toHostSpec(clusterName: String): HostSpec { } val unknownMemoryUnit = MemoryUnit(memory.vendor, memory.modelName, memory.memorySpeed.toMHz(), memory.memorySize.toMiB().toLong()) + val gpuUnits = + List(gpu?.count ?: 0) { + GpuModel( + globalCoreId++, + gpu!!.coreCount, + gpu.coreSpeed.toMHz(), + gpu.memoryBandwidth.toKibps(), + gpu.memorySize.toMiB().toLong(), + gpu.vendor, + gpu.modelName, + gpu.architecture, + ) + } + val machineModel = MachineModel( units, unknownMemoryUnit, + gpuUnits, + // TODO: Pass through + DistributionPolicyFactory.getDistributionStrategy(DistributionPolicyType.MaxMinFairness), + DistributionPolicyFactory.getDistributionStrategy(DistributionPolicyType.MaxMinFairness), ) - val powerModel = + val cpuPowerModel = getPowerModel( - powerModel.modelType, - powerModel.power.toWatts(), - powerModel.maxPower.toWatts(), - powerModel.idlePower.toWatts(), - powerModel.calibrationFactor, - powerModel.asymUtil, - powerModel.dvfs, + cpuPowerModel.modelType, + cpuPowerModel.power.toWatts(), + cpuPowerModel.maxPower.toWatts(), + cpuPowerModel.idlePower.toWatts(), + cpuPowerModel.calibrationFactor, + cpuPowerModel.asymUtil, + cpuPowerModel.dvfs, ) + val gpuPowerModel = + if (gpuUnits.isEmpty()) { + null + } else { + getPowerModel( + gpuPowerModel.modelType, + gpuPowerModel.power.toWatts(), + gpuPowerModel.maxPower.toWatts(), + gpuPowerModel.idlePower.toWatts(), + gpuPowerModel.calibrationFactor, + gpuPowerModel.asymUtil, + gpuPowerModel.dvfs, + ) + } + val hostSpec = HostSpec( createUniqueName(this.name, hostNames), clusterName, machineModel, - powerModel, + cpuPowerModel, + gpuPowerModel, ) return hostSpec } diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt index e4ec89e1..30a75896 100644 --- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt +++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt @@ -22,8 +22,8 @@ package org.opendc.compute.topology.specs -import org.opendc.simulator.compute.cpu.CpuPowerModel import org.opendc.simulator.compute.models.MachineModel +import org.opendc.simulator.compute.power.PowerModel /** * Description of a physical host that will be simulated by OpenDC and host the virtual machines. @@ -36,7 +36,8 @@ public data class HostSpec( val name: String, val clusterName: String, val model: MachineModel, - val cpuPowerModel: CpuPowerModel, + val cpuPowerModel: PowerModel, + val gpuPowerModel: PowerModel?, val embodiedCarbon: Double = 1000.0, val expectedLifetime: Double = 5.0, ) diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/TopologySpecs.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/TopologySpecs.kt index 8cbf818b..62c3906a 100644 --- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/TopologySpecs.kt +++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/TopologySpecs.kt @@ -24,6 +24,7 @@ package org.opendc.compute.topology.specs import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import org.opendc.common.units.DataRate import org.opendc.common.units.DataSize import org.opendc.common.units.Frequency import org.opendc.common.units.Power @@ -76,7 +77,9 @@ public data class HostJSONSpec( val cpu: CPUJSONSpec, val count: Int = 1, val memory: MemoryJSONSpec, - val powerModel: PowerModelSpec = PowerModelSpec.DFLT, + val gpu: GPUJSONSpec? = null, + val cpuPowerModel: PowerModelSpec = PowerModelSpec.DFLT, + val gpuPowerModel: PowerModelSpec = PowerModelSpec.DFLT, ) /** @@ -118,6 +121,18 @@ public data class MemoryJSONSpec( ) @Serializable +public data class GPUJSONSpec( + val count: Int = 1, + val coreCount: Int, + val coreSpeed: Frequency, + val memorySize: DataSize = DataSize.ofMiB(-1), + val memoryBandwidth: DataRate = DataRate.ofKibps(-1), + val vendor: String = "unknown", + val modelName: String = "unknown", + val architecture: String = "unknown", +) + +@Serializable public data class PowerModelSpec( val modelType: String, val power: Power = Power.ofWatts(400), |
