From f13cda61c142ff3d1a2e75de2b05667bdb3ab3ae Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 28 Feb 2020 15:59:14 +0100 Subject: refactor: Create distinction between CPU node and core This change updates the terminology in the `opendc-compute` module to make a distinction between CPU node and CPU core, where we primarly work with CPU cores. However, if needed, we also provide information for the different CPU nodes. --- .../atlarge/opendc/compute/core/ProcessingNode.kt | 40 ++++++++++++++++++++++ .../atlarge/opendc/compute/core/ProcessingUnit.kt | 18 ++++------ .../compute/core/image/FlopsApplicationImage.kt | 2 +- .../compute/metal/driver/SimpleBareMetalDriver.kt | 15 ++++---- .../virt/driver/hypervisor/VmSchedulerImpl.kt | 2 +- 5 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingNode.kt (limited to 'opendc/opendc-compute/src/main') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingNode.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingNode.kt new file mode 100644 index 00000000..91f5dde9 --- /dev/null +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingNode.kt @@ -0,0 +1,40 @@ +/* + * MIT License + * + * Copyright (c) 2020 atlarge-research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.atlarge.opendc.compute.core + +/** + * A processing node/package/socket containing possibly several CPU cores. + * + * @property vendor The vendor string of the processor node. + * @property modelName The name of the processor node. + * @property arch The micro-architecture of the processor node. + * @property coreCount The number of logical CPUs in the processor node. + */ +data class ProcessingNode( + val vendor: String, + val arch: String, + val modelName: String, + val coreCount: Int +) diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt index 945b7061..dbf6d824 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt @@ -25,18 +25,14 @@ package com.atlarge.opendc.compute.core /** - * A processing unit of a compute resource, either virtual or physical. + * A single logical compute unit of processor node, either virtual or physical. * - * @property vendor The vendor string of the cpu. - * @property modelName The name of the cpu model. - * @property arch The architecture of the CPU. - * @property clockRate The clock speed of the cpu in MHz. - * @property cores The number of logical cores in the cpu. + * @property node The processing node containing the CPU core. + * @property id The identifier of the CPU core within the processing node. + * @property frequency The clock rate of the CPU. */ public data class ProcessingUnit( - public val vendor: String, - public val modelName: String, - public val arch: String, - public val clockRate: Double, - public val cores: Int + public val node: ProcessingNode, + public val id: Int, + public val frequency: Double ) diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt index 3576b488..de429d41 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt @@ -65,7 +65,7 @@ class FlopsApplicationImage( coroutineScope { for (cpu in ctx.cpus.take(cores)) { - launch { cpu.run(req, cpu.info.clockRate * utilization, Long.MAX_VALUE) } + launch { cpu.run(req, cpu.info.frequency * utilization, Long.MAX_VALUE) } } } } diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt index 1adc8652..e1b7b178 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt @@ -53,14 +53,14 @@ import kotlinx.coroutines.withContext * * @param uid The unique identifier of the machine. * @param name An optional name of the machine. - * @param cpuNodes The CPU nodes/packages available to the bare metal machine. + * @param cpus The CPUs available to the bare metal machine. * @param memoryUnits The memory units in this machine. * @param domain The simulation domain the driver runs in. */ public class SimpleBareMetalDriver( uid: UUID, name: String, - val cpuNodes: List, + val cpus: List, val memoryUnits: List, private val domain: Domain ) : BareMetalDriver { @@ -77,7 +77,7 @@ public class SimpleBareMetalDriver( /** * The flavor that corresponds to this machine. */ - private val flavor = Flavor(cpuNodes.sumBy { it.cores }, memoryUnits.map { it.size }.sum()) + private val flavor = Flavor(cpus.size, memoryUnits.map { it.size }.sum()) /** * The job that is running the image. @@ -141,7 +141,7 @@ public class SimpleBareMetalDriver( private data class ProcessorContextImpl(override val info: ProcessingUnit) : ProcessorContext { override suspend fun run(burst: Long, maxUsage: Double, deadline: Long): Long { val start = simulationContext.clock.millis() - val usage = min(maxUsage, info.clockRate) * 1_000_000 // Usage from MHz to Hz + val usage = min(maxUsage, info.frequency) * 1_000_000 // Usage from MHz to Hz try { val duration = min( @@ -161,11 +161,8 @@ public class SimpleBareMetalDriver( private val serverCtx = object : ServerManagementContext { private var initialized: Boolean = false - override val cpus: List = cpuNodes - .asSequence() - .flatMap { cpu -> - generateSequence { ProcessorContextImpl(cpu) }.take(cpu.cores) - } + override val cpus: List = this@SimpleBareMetalDriver.cpus + .map { ProcessorContextImpl(it) } .toList() override var server: Server diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmSchedulerImpl.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmSchedulerImpl.kt index 4cc5ac9e..f232d695 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmSchedulerImpl.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmSchedulerImpl.kt @@ -97,7 +97,7 @@ public class VmSchedulerImpl( for (vcpu in vcpus) { // Limit each vCPU to at most an equal share of the host CPU - vcpu.actualUsage = min(vcpu.requestedUsage, info.clockRate / vcpus.size) + vcpu.actualUsage = min(vcpu.requestedUsage, info.frequency / vcpus.size) // The duration that we want to run is that of the shortest request from a vCPU duration = min(duration, ceil(vcpu.requestedBurst / (vcpu.actualUsage * 1_000_000L)).toLong()) -- cgit v1.2.3