summaryrefslogtreecommitdiff
path: root/opendc/opendc-compute/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-02-28 15:59:14 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-02-28 15:59:14 +0100
commitf13cda61c142ff3d1a2e75de2b05667bdb3ab3ae (patch)
tree90b977f7a9c3584c24787d0769ff6b5d9ef0323a /opendc/opendc-compute/src/main
parentac6e6f7c611fa7d10fff5467c4a61af932e4c171 (diff)
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.
Diffstat (limited to 'opendc/opendc-compute/src/main')
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingNode.kt40
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt18
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt2
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt15
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmSchedulerImpl.kt2
5 files changed, 55 insertions, 22 deletions
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<ProcessingUnit>,
+ val cpus: List<ProcessingUnit>,
val memoryUnits: List<MemoryUnit>,
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<ProcessorContextImpl> = cpuNodes
- .asSequence()
- .flatMap { cpu ->
- generateSequence { ProcessorContextImpl(cpu) }.take(cpu.cores)
- }
+ override val cpus: List<ProcessorContextImpl> = 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())