summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-topology
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-compute/opendc-compute-topology')
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt3
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/TopologySpecs.kt50
2 files changed, 52 insertions, 1 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 c1617304..fd66ca11 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
@@ -32,6 +32,7 @@ import org.opendc.compute.topology.specs.HostSpec
import org.opendc.compute.topology.specs.PowerSourceSpec
import org.opendc.compute.topology.specs.TopologySpec
import org.opendc.compute.topology.specs.toDistributionPolicy
+import org.opendc.compute.topology.specs.toVirtualizationOverheadModel
import org.opendc.simulator.compute.models.CpuModel
import org.opendc.simulator.compute.models.GpuModel
import org.opendc.simulator.compute.models.MachineModel
@@ -171,6 +172,7 @@ 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) {
+ val virtualizationOverheadModel = gpu?.virtualizationOverHeadModel?.toVirtualizationOverheadModel()
GpuModel(
globalGpuId++,
gpu!!.coreCount,
@@ -180,6 +182,7 @@ private fun HostJSONSpec.toHostSpec(clusterName: String): HostSpec {
gpu.vendor,
gpu.modelName,
gpu.architecture,
+ virtualizationOverheadModel,
)
}
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 f5c8ab31..667e9cbd 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
@@ -35,6 +35,7 @@ import org.opendc.simulator.compute.power.batteries.policy.DoubleThresholdBatter
import org.opendc.simulator.compute.power.batteries.policy.RunningMeanBatteryPolicy
import org.opendc.simulator.compute.power.batteries.policy.RunningMeanPlusBatteryPolicy
import org.opendc.simulator.compute.power.batteries.policy.SingleThresholdBatteryPolicy
+import org.opendc.simulator.compute.virtualization.VirtualizationOverheadModelFactory.VirtualizationOverheadModelEnum
import org.opendc.simulator.engine.engine.FlowEngine
import org.opendc.simulator.engine.graph.distributionPolicies.FlowDistributorFactory.DistributionPolicy
@@ -69,8 +70,12 @@ public data class ClusterJSONSpec(
* @param name The name of the host.
* @param cpu The CPU available in this cluster
* @param memory The amount of RAM memory available in Byte
- * @param powerModel The power model used to determine the power draw of a host
* @param count The power model used to determine the power draw of a host
+ * @param gpu The GPU available in this cluster (optional)
+ * @param cpuPowerModel The power model used to determine the power draw of the CPU
+ * @param gpuPowerModel The power model used to determine the power draw of the GPU
+ * @param cpuDistributionPolicy The distribution policy used to distribute CPU resources
+ * @param gpuDistributionPolicy The distribution policy used to distribute GPU resources
*/
@Serializable
public data class HostJSONSpec(
@@ -133,6 +138,7 @@ public data class GPUJSONSpec(
val vendor: String = "unknown",
val modelName: String = "unknown",
val architecture: String = "unknown",
+ val virtualizationOverHeadModel: VirtualizationOverheadModelSpec = NoVirtualizationOverheadModelSpec(),
)
@Serializable
@@ -216,6 +222,48 @@ public data class MaxMinFairnessDistributionPolicySpec(
override val type: DistributionPolicy = DistributionPolicy.MAX_MIN_FAIRNESS,
) : DistributionPolicySpec
+@Serializable
+public sealed interface VirtualizationOverheadModelSpec {
+ public val type: VirtualizationOverheadModelEnum
+}
+
+@Serializable
+@SerialName("NONE")
+public data class NoVirtualizationOverheadModelSpec(
+ override val type: VirtualizationOverheadModelEnum =
+ VirtualizationOverheadModelEnum.NONE,
+) : VirtualizationOverheadModelSpec
+
+@Serializable
+@SerialName("CONSTANT")
+public data class ConstantVirtualizationOverheadModelSpec(
+ override val type: VirtualizationOverheadModelEnum = VirtualizationOverheadModelEnum.CONSTANT,
+ val percentageOverhead: Double? = -1.0,
+) : VirtualizationOverheadModelSpec
+
+@Serializable
+@SerialName("SHARE_BASED")
+public data class ShareBasedVirtualizationOverheadModelSpec(
+ override val type: VirtualizationOverheadModelEnum = VirtualizationOverheadModelEnum.SHARE_BASED,
+) : VirtualizationOverheadModelSpec
+
+public fun VirtualizationOverheadModelSpec.toVirtualizationOverheadModel(): VirtualizationOverheadModelEnum {
+ return when (this) {
+ is NoVirtualizationOverheadModelSpec -> VirtualizationOverheadModelEnum.NONE
+ is ConstantVirtualizationOverheadModelSpec ->
+ VirtualizationOverheadModelEnum.CONSTANT.apply {
+ if (percentageOverhead != null) {
+ // -1.0 is used to indicate that no percentage overhead is specified
+ if (percentageOverhead != -1.0 && (percentageOverhead < 0.0 || percentageOverhead > 1.0)) {
+ throw IllegalArgumentException("Percentage overhead must be between 0.0 and 1.0")
+ }
+ setProperty("percentageOverhead", percentageOverhead)
+ }
+ }
+ is ShareBasedVirtualizationOverheadModelSpec -> VirtualizationOverheadModelEnum.SHARE_BASED
+ }
+}
+
/**
* Definition of a power source used for JSON input.
*