diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-09-16 11:29:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-16 11:29:26 +0200 |
| commit | 4a010c6b9e033314a2624a0756dcdc7f17010d9d (patch) | |
| tree | 70dc26e98cf8421eb5db7f62cf63d4ea2399c505 /opendc-simulator/opendc-simulator-compute/src/test | |
| parent | 5047e4a25a0814f96852882f02c4017e1d5f81e7 (diff) | |
All simulation are now run with a single CPU and single MemoryUnit. multi CPUs are combined into one. This is for performance and explainability. (#255)
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/test')
5 files changed, 80 insertions, 46 deletions
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 da8bb5d2..be6d289c 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 @@ -35,11 +35,10 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.opendc.simulator.compute.device.SimNetworkAdapter +import org.opendc.simulator.compute.model.Cpu import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit import org.opendc.simulator.compute.model.NetworkAdapter -import org.opendc.simulator.compute.model.ProcessingNode -import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.model.StorageDevice import org.opendc.simulator.compute.power.CpuPowerModels import org.opendc.simulator.compute.workload.SimTrace @@ -60,12 +59,17 @@ class SimMachineTest { @BeforeEach fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) - machineModel = MachineModel( - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) }, - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + Cpu( + 0, + 2, + 1000.0, + "Intel", + "Xeon", + "amd64", + ), + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), listOf(NetworkAdapter("Mellanox", "ConnectX-5", 25000.0)), listOf(StorageDevice("Samsung", "EVO", 1000.0, 250.0, 250.0)), ) @@ -121,11 +125,17 @@ class SimMachineTest { val engine = FlowEngine.create(dispatcher) val graph = engine.newGraph() - val cpuNode = machineModel.cpus[0].node + val cpuNode = machineModel.cpu val machineModel = MachineModel( - List(cpuNode.coreCount * 2) { ProcessingUnit(cpuNode, it % 2, 1000.0) }, - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + List(cpuNode.coreCount * 2) { + Cpu( + it, + cpuNode.coreCount, + 1000.0, + ) + }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) val machine = SimBareMetalMachine.create( @@ -179,10 +189,10 @@ class SimMachineTest { machine.runWorkload( object : SimWorkload { override fun onStart(ctx: SimMachineContext) { - val cpu = ctx.cpus[0] + val cpu = ctx.cpu - cpu.frequency = (cpu.model.frequency + 1000.0) - assertEquals(cpu.model.frequency, cpu.frequency) + cpu.frequency = (cpu.cpuModel.totalCapacity + 1000.0) + assertEquals(cpu.cpuModel.totalCapacity, cpu.frequency) cpu.frequency = -1.0 assertEquals(0.0, cpu.frequency) diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt index bef22699..6cebc46f 100644 --- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt +++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt @@ -33,10 +33,9 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.opendc.simulator.compute.SimBareMetalMachine import org.opendc.simulator.compute.kernel.cpufreq.ScalingGovernors import org.opendc.simulator.compute.kernel.interference.VmInterferenceModel +import org.opendc.simulator.compute.model.Cpu import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit -import org.opendc.simulator.compute.model.ProcessingNode -import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.runWorkload import org.opendc.simulator.compute.workload.SimTrace import org.opendc.simulator.compute.workload.SimTraceFragment @@ -53,13 +52,18 @@ internal class SimFairShareHypervisorTest { @BeforeEach fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 1) model = MachineModel( - // cpus - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.0) }, + Cpu( + 0, + 1, + 3200.0, + "Intel", + "Xeon", + "amd64", + ), // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) } @@ -167,13 +171,18 @@ internal class SimFairShareHypervisorTest { @Test fun testMultipleCPUs() = runSimulation { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) val model = MachineModel( - // cpus - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.0) }, + Cpu( + 0, + 2, + 3200.0, + "Intel", + "Xeon", + "amd64", + ), // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) val engine = FlowEngine.create(dispatcher) @@ -197,13 +206,18 @@ internal class SimFairShareHypervisorTest { @Test fun testInterference() = runSimulation { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) val model = MachineModel( - // cpus - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.0) }, + Cpu( + 0, + 2, + 3200.0, + "Intel", + "Xeon", + "amd64", + ), // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) val interferenceModel = diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt index b762acea..b4ae372c 100644 --- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt +++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt @@ -33,10 +33,9 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.opendc.simulator.compute.SimBareMetalMachine +import org.opendc.simulator.compute.model.Cpu import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit -import org.opendc.simulator.compute.model.ProcessingNode -import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.runWorkload import org.opendc.simulator.compute.workload.SimTrace import org.opendc.simulator.compute.workload.SimTraceFragment @@ -54,13 +53,18 @@ internal class SimSpaceSharedHypervisorTest { @BeforeEach fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 1) machineModel = MachineModel( - // cpus - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.0) }, + Cpu( + 0, + 1, + 3200.0, + "Intel", + "Xeon", + "amd64", + ), // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) } diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt index 33de7751..582635fc 100644 --- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt +++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimChainWorkloadTest.kt @@ -33,10 +33,9 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.opendc.simulator.compute.SimBareMetalMachine import org.opendc.simulator.compute.SimMachineContext +import org.opendc.simulator.compute.model.Cpu import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit -import org.opendc.simulator.compute.model.ProcessingNode -import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.runWorkload import org.opendc.simulator.flow2.FlowEngine import org.opendc.simulator.kotlin.runSimulation @@ -49,14 +48,18 @@ class SimChainWorkloadTest { @BeforeEach fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) - machineModel = MachineModel( - // cpus - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) }, + Cpu( + 0, + 2, + 1000.0, + "Intel", + "Xeon", + "amd64", + ), // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) } diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt index e40d4f8b..a53f6c65 100644 --- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt +++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt @@ -27,10 +27,9 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.opendc.simulator.compute.SimBareMetalMachine +import org.opendc.simulator.compute.model.Cpu import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit -import org.opendc.simulator.compute.model.ProcessingNode -import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.runWorkload import org.opendc.simulator.flow2.FlowEngine import org.opendc.simulator.kotlin.runSimulation @@ -43,14 +42,18 @@ class SimTraceWorkloadTest { @BeforeEach fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) - machineModel = MachineModel( - // cpus - List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) }, + Cpu( + 0, + 2, + 1000.0, + "Intel", + "Xeon", + "amd64", + ), // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, + MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000 * 4), ) } |
