Skip to content

Commit

Permalink
Fixed several cpu related bugs, changed input topology (atlarge-resea…
Browse files Browse the repository at this point in the history
  • Loading branch information
DanteNiewenhuis committed Apr 29, 2024
1 parent d8ac0fd commit e5ccc62
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,20 @@ public class VCpuFilter(private val allocationRatio: Double) : HostFilter {
host: HostView,
server: Server,
): Boolean {
val requested = server.flavor.coreCount
val totalCores = host.host.model.coreCount
val limit = totalCores * allocationRatio
val requestedCores = server.flavor.coreCount
val availableCores = host.host.model.coreCount

// Do not allow an instance to overcommit against itself, only against other instances
if (requested > totalCores) {
if (requestedCores > availableCores) {
return false
}

val availableCores = limit - host.provisionedCores
return availableCores >= requested
val limit = availableCores * allocationRatio
val free = limit - host.provisionedCores

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class SimHost(

override fun canFit(server: Server): Boolean {
val sufficientMemory = model.memoryCapacity >= server.flavor.memorySize
val enoughCpus = model.cpuCount >= server.flavor.coreCount
val enoughCpus = model.coreCount >= server.flavor.coreCount
val canFit = hypervisor.canFit(server.flavor.toMachineModel())

return sufficientMemory && enoughCpus && canFit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package org.opendc.compute.topology

import org.opendc.compute.topology.specs.CPUSpec
import org.opendc.compute.topology.specs.ClusterSpec
import org.opendc.compute.topology.specs.ClusterJSONSpec
import org.opendc.compute.topology.specs.HostJSONSpec
import org.opendc.compute.topology.specs.HostSpec
import org.opendc.compute.topology.specs.TopologySpec
Expand Down Expand Up @@ -114,14 +115,14 @@ private fun ClusterSpec.toHostSpecs(random: RandomGenerator): List<HostSpec> {
* Helper method to convert a [HostJSONSpec] into a [HostSpec]s.
*/
private var hostId = 0
private var globalCoreId = 0

private fun HostJSONSpec.toHostSpecs(
clusterId: Int,
random: RandomGenerator,
): HostSpec {
val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpus.sumOf { it.coreCount })

val units = cpus.flatMap { cpu -> List(cpu.count) { cpu.toProcessingUnits(unknownProcessingNode) }.flatten() }
val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpu.coreCount)
val units = List(cpu.count) { ProcessingUnit(unknownProcessingNode, globalCoreId++, cpu.coreSpeed) }

val unknownMemoryUnit = MemoryUnit(memory.vendor, memory.modelName, memory.memorySpeed, memory.memorySize)
val machineModel =
Expand All @@ -144,15 +145,3 @@ private fun HostJSONSpec.toHostSpecs(

return hostSpec
}

/**
* Helper method to convert a [CPUSpec] into a list of [ProcessingUnit]s.
*/
private var globalCoreId = 0

private fun CPUSpec.toProcessingUnits(unknownProcessingNode: ProcessingNode): List<ProcessingUnit> {
val units = List(coreCount) { ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed) }
return units

// return listOf(ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed))
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import kotlinx.serialization.Serializable
* @param clusters List of the clusters in this topology
*/
@Serializable
public data class TopologySpec(
val clusters: List<ClusterSpec>,
public data class TopologyJSONSpec(
val clusters: List<ClusterJSONSpec>,
val schemaVersion: Int = 1,
)

Expand All @@ -43,7 +43,7 @@ public data class TopologySpec(
* @param location Location of the cluster. This can impact the carbon intensity
*/
@Serializable
public data class ClusterSpec(
public data class ClusterJSONSpec(
val name: String = "Cluster",
val count: Int = 1,
val hosts: List<HostJSONSpec>,
Expand All @@ -54,17 +54,17 @@ public data class ClusterSpec(
* Definition of a compute host modeled in the simulation.
*
* @param name The name of the host.
* @param cpus List of the different CPUs available in this cluster
* @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
*/
@Serializable
public data class HostJSONSpec(
val name: String = "Host",
val cpus: List<CPUSpec>,
val memory: MemorySpec,
val powerModel: PowerModelSpec = PowerModelSpec("linear", 350.0, 400.0, 200.0),
val cpu: CPUJSONSpec,
val memory: MemoryJSONSpec,
val powerModel: PowerModelJSONSpec = PowerModelJSONSpec("linear", 350.0, 400.0, 200.0),
val count: Int = 1,
)

Expand All @@ -78,7 +78,7 @@ public data class HostJSONSpec(
* @param coreSpeed The speed of the cores in Mhz
*/
@Serializable
public data class CPUSpec(
public data class CPUJSONSpec(
val vendor: String = "unknown",
val modelName: String = "unknown",
val arch: String = "unknown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ class ScenarioIntegrationTest {
{ assertEquals(0, monitor.serversActive, "All VMs should finish after a run") },
{ assertEquals(0, monitor.attemptsFailure, "No VM should be unscheduled") },
{ assertEquals(0, monitor.serversPending, "No VM should not be in the queue") },
{ assertEquals(223379991650, monitor.idleTime) { "Incorrect idle time" } },
{ assertEquals(66977091124, monitor.activeTime) { "Incorrect active time" } },
{ assertEquals(3160267873, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(36256553309, monitor.idleTime) { "Incorrect idle time" } },
{ assertEquals(10404414534, monitor.activeTime) { "Incorrect active time" } },
{ assertEquals(54402726811, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(0, monitor.lostTime) { "Incorrect lost time" } },
{ assertEquals(2.0774585843587227E7, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(6.232122296636381E9, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
{ assertEquals(3.804398939214319E7, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(1.141307641744099E10, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
)
}

Expand Down Expand Up @@ -163,12 +163,12 @@ class ScenarioIntegrationTest {

// Note that these values have been verified beforehand
assertAll(
{ assertEquals(10996730092, monitor.idleTime) { "Idle time incorrect" } },
{ assertEquals(9741285381, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(152, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(873236440, monitor.idleTime) { "Idle time incorrect" } },
{ assertEquals(1719015528, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(8022269916, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, monitor.lostTime) { "Lost time incorrect" } },
{ assertEquals(2539987.394500494, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(7.619825262052509E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
{ assertEquals(2874229.394500494, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(8.622534568334692E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
)
}

Expand Down Expand Up @@ -213,8 +213,8 @@ class ScenarioIntegrationTest {

/**
* Test a small simulation setup with failures.
* FIXME: Currently failures do not work. reactivate this test when Failures are implemented again
*/
@Test
fun testFailures() =
runSimulation {
val seed = 0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
[
{
"name": "H01",
"cpus":
[
{
"coreCount": 32,
"coreSpeed": 3200
}
],
"cpu":
{
"coreCount": 32,
"coreSpeed": 3200
},
"memory": {
"memorySize": 256000
}
Expand All @@ -27,13 +25,11 @@
{
"name": "H02",
"count": 6,
"cpus":
[
{
"coreCount": 8,
"coreSpeed": 2930
}
],
"cpu":
{
"coreCount": 8,
"coreSpeed": 2930
},
"memory": {
"memorySize": 64000
}
Expand All @@ -47,13 +43,11 @@
{
"name": "H03",
"count": 2,
"cpus":
[
{
"coreCount": 16,
"coreSpeed": 3200
}
],
"cpu":
{
"coreCount": 16,
"coreSpeed": 3200
},
"memory": {
"memorySize": 128000
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
[
{
"name": "H01",
"cpus":
[
{
"coreCount": 8,
"coreSpeed": 3200
}
],
"cpu":
{
"coreCount": 8,
"coreSpeed": 3200
},
"memory": {
"memorySize": 128000
}
Expand Down
12 changes: 6 additions & 6 deletions site/docs/documentation/Input/Topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ In the following section, we describe the different components of the schema.

### Host

| variable | type | required? | default | description |
|-------------|-----------------------------|-----------|---------|--------------------------------------------------------------------------------|
| name | string | no | Host | The name of the host. This is only important for debugging and post-processing |
| count | integer | no | 1 | The amount of hosts of this type are in the cluster |
| cpus | List[[CPU](#cpu)] | yes | N/A | A list of the hosts in a cluster. |
| memory | [Memory](#memory) | yes | N/A | The memory used by the host |
| variable | type | required? | default | description |
|------------|-----------------------|-----------|---------|--------------------------------------------------------------------------------|
| name | string | no | Host | The name of the host. This is only important for debugging and post-processing |
| count | integer | no | 1 | The amount of hosts of this type are in the cluster |
| cpu | [CPU](#cpu) | yes | N/A | The CPUs in the host |
| memory | [Memory](#memory) | yes | N/A | The memory used by the host |
| power model | [Power Model](#power-model) | yes | N/A | The power model used to determine the power draw of the host |

### CPU
Expand Down
Loading

0 comments on commit e5ccc62

Please sign in to comment.