diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2020-03-13 17:58:55 +0100 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2020-03-13 17:58:55 +0100 |
| commit | ccde4082af2d32da0332b6b87741a73d9b01f587 (patch) | |
| tree | 3aca479525d1c1557c56d873941399556d3088fe /opendc/opendc-compute/src | |
| parent | daa82a52928adfa79394ffe89ec3758d9f2257ee (diff) | |
| parent | 04bf648ce13f36a39e7ca6b41f4fbab281bb9392 (diff) | |
Merge branch 'refactor/units' into '2.x'
Change burst to mega FLOPs
See merge request opendc/opendc-simulator!42
Diffstat (limited to 'opendc/opendc-compute/src')
7 files changed, 11 insertions, 18 deletions
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 dbf6d824..ba148ee0 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 @@ -29,7 +29,7 @@ package com.atlarge.opendc.compute.core * * @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. + * @property frequency The clock rate of the CPU in MHz. */ public data class ProcessingUnit( public val node: ProcessingNode, 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 27d8091a..107237ea 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 @@ -38,7 +38,7 @@ import kotlin.math.min * @property uid The unique identifier of this image. * @property name The name of this image. * @property tags The tags attached to the image. - * @property flops The number of floating point operations to perform for this task. + * @property flops The number of floating point operations to perform for this task in MFLOPs. * @property cores The number of cores that the image is able to utilize. * @property utilization A model of the CPU utilization of the application. */ 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 cd3e9a48..c7dc74cf 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 @@ -199,10 +199,10 @@ public class SimpleBareMetalDriver( // Determine the duration of the first CPU to finish for (i in 0 until min(cpus.size, burst.size)) { val cpu = cpus[i] - val usage = min(limit[i], cpu.frequency) * 1_000_000 // Usage from MHz to Hz + val usage = min(limit[i], cpu.frequency) val cpuDuration = ceil(burst[i] / usage * 1000).toLong() // Convert from seconds to milliseconds - totalUsage += usage / (cpu.frequency * 1_000_000) + totalUsage += usage / cpu.frequency if (cpuDuration != 0L) { // We only wait for processor cores with a non-zero burst duration = min(duration, cpuDuration) @@ -229,7 +229,7 @@ public class SimpleBareMetalDriver( // Write back the remaining burst time for (i in 0 until min(cpus.size, burst.size)) { - val usage = min(limit[i], cpus[i].frequency) * 1_000_000 + val usage = min(limit[i], cpus[i].frequency) val granted = ceil((end - start) / 1000.0 * usage).toLong() burst[i] = max(0, burst[i] - granted) } diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt index 1f9c8a80..7cd48bc3 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt @@ -137,7 +137,7 @@ class HypervisorVirtDriver( availableUsage -= grantedUsage // The duration that we want to run is that of the shortest request from a vCPU - duration = min(duration, req.burst / (req.allocatedUsage * 1_000_000L)) + duration = min(duration, req.burst / req.allocatedUsage) deadline = min(deadline, req.vm.deadline) } @@ -153,7 +153,7 @@ class HypervisorVirtDriver( val grantedUsage = min(hostContext.cpus[i].frequency, availableShare) usage[i] = grantedUsage - burst[i] = (duration * grantedUsage * 1_000_000L).toLong() + burst[i] = (duration * grantedUsage).toLong() availableUsage -= grantedUsage } @@ -182,7 +182,7 @@ class HypervisorVirtDriver( val fraction = req.allocatedUsage / totalUsage // Derive the burst that was allocated to this vCPU - val allocatedBurst = ceil(duration * req.allocatedUsage * 1_000_000L).toLong() + val allocatedBurst = ceil(duration * req.allocatedUsage).toLong() // Compute the burst time that the VM was actually granted val grantedBurst = (performanceScore * (allocatedBurst - ceil(totalRemainder * fraction))).toLong() diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt index f036e370..17960186 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt @@ -43,11 +43,6 @@ class SimpleVirtProvisioningService( */ internal val activeImages: MutableSet<ImageView> = mutableSetOf() - /** - * The images hosted on each server. - */ - internal val imagesByServer: MutableMap<Server, MutableSet<ImageView>> = mutableMapOf() - init { ctx.domain.launch { val provisionedNodes = provisioningService.nodes().toList() @@ -101,8 +96,6 @@ class SimpleVirtProvisioningService( imageInstance.flavor ) activeImages += imageInstance - imagesByServer.putIfAbsent(imageInstance.server!!, mutableSetOf()) - imagesByServer[imageInstance.server!!]!!.add(imageInstance) } catch (e: InsufficientMemoryOnServerException) { println("Unable to deploy image due to insufficient memory") } diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt index f3796028..b8882eda 100644 --- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt +++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt @@ -63,7 +63,7 @@ internal class SimpleBareMetalDriverTest { finalState = server.state } } - val image = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", emptyMap(), 1_000_000_000, 2) + val image = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", emptyMap(), 1_000, 2) // Batch driver commands withContext(dom.coroutineContext) { diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt index adc476a7..254ad5fe 100644 --- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt +++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt @@ -69,8 +69,8 @@ internal class HypervisorTest { println("Hello World!") } }) - val workloadA = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", emptyMap(), 1_000_000_000, 1) - val workloadB = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", emptyMap(), 2_000_000_000, 1) + val workloadA = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", emptyMap(), 1_000, 1) + val workloadB = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", emptyMap(), 2_000, 1) val monitor = object : ServerMonitor { override suspend fun onUpdate(server: Server, previousState: ServerState) { println("[${simulationContext.clock.millis()}]: $server") |
