From 44215bd668c5fa3efe2f57fc577824478b00af57 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 1 Sep 2022 14:38:34 +0200 Subject: refactor(sim/compute): Re-implement using flow2 This change re-implements the OpenDC compute simulator framework using the new flow2 framework for modelling multi-edge flow networks. The re-implementation is written in Java and focusses on performance and clean API surface. --- .../experiments/capelin/topology/TopologyFactories.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'opendc-experiments/opendc-experiments-capelin/src/main') diff --git a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt index 08d4a7e0..0b4cafa6 100644 --- a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt +++ b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/topology/TopologyFactories.kt @@ -25,13 +25,13 @@ package org.opendc.experiments.capelin.topology import org.opendc.experiments.compute.topology.HostSpec +import org.opendc.simulator.compute.SimPsuFactories 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.power.LinearPowerModel -import org.opendc.simulator.compute.power.PowerModel -import org.opendc.simulator.compute.power.SimplePowerDriver +import org.opendc.simulator.compute.power.CpuPowerModel +import org.opendc.simulator.compute.power.CpuPowerModels import java.io.File import java.io.InputStream import java.util.Random @@ -48,7 +48,7 @@ private val reader = ClusterSpecReader() */ fun clusterTopology( file: File, - powerModel: PowerModel = LinearPowerModel(350.0, idlePower = 200.0), + powerModel: CpuPowerModel = CpuPowerModels.linear(350.0, 200.0), random: Random = Random(0) ): List { return clusterTopology(reader.read(file), powerModel, random) @@ -59,7 +59,7 @@ fun clusterTopology( */ fun clusterTopology( input: InputStream, - powerModel: PowerModel = LinearPowerModel(350.0, idlePower = 200.0), + powerModel: CpuPowerModel = CpuPowerModels.linear(350.0, 200.0), random: Random = Random(0) ): List { return clusterTopology(reader.read(input), powerModel, random) @@ -68,14 +68,14 @@ fun clusterTopology( /** * Construct a topology from the given list of [clusters]. */ -fun clusterTopology(clusters: List, powerModel: PowerModel, random: Random = Random(0)): List { +fun clusterTopology(clusters: List, powerModel: CpuPowerModel, random: Random = Random(0)): List { return clusters.flatMap { it.toHostSpecs(random, powerModel) } } /** * Helper method to convert a [ClusterSpec] into a list of [HostSpec]s. */ -private fun ClusterSpec.toHostSpecs(random: Random, powerModel: PowerModel): List { +private fun ClusterSpec.toHostSpecs(random: Random, powerModel: CpuPowerModel): List { val cpuSpeed = cpuSpeed val memoryPerHost = memCapacityPerHost.roundToLong() @@ -92,7 +92,7 @@ private fun ClusterSpec.toHostSpecs(random: Random, powerModel: PowerModel): Lis "node-$name-$it", mapOf("cluster" to id), machineModel, - SimplePowerDriver(powerModel) + SimPsuFactories.simple(powerModel) ) } } -- cgit v1.2.3