Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added thermal model for hosts #238

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
zohaib-c marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public record HostSystemStats(
Instant bootTime,
double powerDraw,
double energyUsage,
double temperatureC,
int guestsTerminated,
int guestsRunning,
int guestsError,
Expand Down
zohaib-c marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public class SimHost(
localBootTime,
machine.psu.powerDraw,
machine.psu.energyUsage,
machine.psu.temperature,
terminated,
running,
error,
Expand Down
zohaib-c marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public class ComputeMetricReader(
_cpuLostTime = table.cpuLostTime
_powerDraw = table.powerDraw
_energyUsage = table.energyUsage
_temperature = table.temperature
_carbonIntensity = table.carbonIntensity
_carbonEmission = table.carbonEmission
_uptime = table.uptime
Expand Down Expand Up @@ -328,6 +329,10 @@ public class ComputeMetricReader(
private var _energyUsage = 0.0
private var previousPowerTotal = 0.0

override val temperature: Double
get() = _temperature
private var _temperature = 0.0

override val carbonIntensity: Double
get() = _carbonIntensity
private var _carbonIntensity = 0.0
Expand Down Expand Up @@ -378,6 +383,7 @@ public class ComputeMetricReader(
_cpuLostTime = hostCpuStats.lostTime
_powerDraw = hostSysStats.powerDraw
_energyUsage = hostSysStats.energyUsage
_temperature = hostSysStats.temperatureC
_carbonIntensity = carbonTrace.getCarbonIntensity(timestampAbsolute)

_carbonEmission = carbonIntensity * (energyUsage / 3600000.0) // convert energy usage from J to kWh
Expand Down Expand Up @@ -412,6 +418,7 @@ public class ComputeMetricReader(

_powerDraw = 0.0
_energyUsage = 0.0
_temperature = 0.0
_carbonIntensity = 0.0
_carbonEmission = 0.0
}
Expand Down
zohaib-c marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -152,34 +152,38 @@ public class ParquetHostDataWriter(path: File, bufferSize: Int) :
consumer.addDouble(data.energyUsage)
consumer.endField("energy_usage", 19)

consumer.startField("carbon_intensity", 20)
consumer.startField("temperature_C", 20)
consumer.addDouble(data.temperature)
consumer.endField("temperature_C", 20)

consumer.startField("carbon_intensity", 21)
consumer.addDouble(data.carbonIntensity)
consumer.endField("carbon_intensity", 20)
consumer.endField("carbon_intensity", 21)

consumer.startField("carbon_emission", 21)
consumer.startField("carbon_emission", 22)
consumer.addDouble(data.carbonEmission)
consumer.endField("carbon_emission", 21)
consumer.endField("carbon_emission", 22)

consumer.startField("uptime", 22)
consumer.startField("uptime", 23)
consumer.addLong(data.uptime)
consumer.endField("uptime", 22)
consumer.endField("uptime", 23)

consumer.startField("downtime", 23)
consumer.startField("downtime", 24)
consumer.addLong(data.downtime)
consumer.endField("downtime", 23)
consumer.endField("downtime", 24)

val bootTime = data.bootTime
if (bootTime != null) {
consumer.startField("boot_time", 24)
consumer.startField("boot_time", 25)
consumer.addLong(bootTime.toEpochMilli())
consumer.endField("boot_time", 24)
consumer.endField("boot_time", 25)
}

val bootTimeAbsolute = data.bootTimeAbsolute
if (bootTimeAbsolute != null) {
consumer.startField("boot_time_absolute", 25)
consumer.startField("boot_time_absolute", 26)
consumer.addLong(bootTimeAbsolute.toEpochMilli())
consumer.endField("boot_time_absolute", 25)
consumer.endField("boot_time_absolute", 26)
}

consumer.endMessage()
Expand Down Expand Up @@ -256,6 +260,9 @@ public class ParquetHostDataWriter(path: File, bufferSize: Int) :
Types
.required(PrimitiveType.PrimitiveTypeName.DOUBLE)
.named("energy_usage"),
Types
.required(PrimitiveType.PrimitiveTypeName.DOUBLE)
.named("temperature_C"),
Types
.required(PrimitiveType.PrimitiveTypeName.DOUBLE)
.named("carbon_intensity"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public interface HostTableReader {
*/
public val energyUsage: Double

/**
* The current temperature of the host in degrees Celsius.
*/
public val temperature: Double

/**
* The current carbon intensity of the host in gCO2 / kW.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ 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.getPowerModel
import org.opendc.simulator.compute.thermal.getThermalModel
import java.io.File
import java.io.InputStream
import java.util.SplittableRandom
Expand Down Expand Up @@ -130,6 +131,16 @@ private fun HostJSONSpec.toHostSpecs(
)

val powerModel = getPowerModel(powerModel.modelType, powerModel.power, powerModel.maxPower, powerModel.idlePower)
val thermalModel =
getThermalModel(
thermalModel.modelType,
thermalModel.rHS,
thermalModel.rCase,
thermalModel.minLeakageCurrent,
thermalModel.maxLeakageCurrent,
thermalModel.supplyVoltage,
thermalModel.ambientTemperature,
)

var hostName: String
if (name == null) {
Expand All @@ -144,7 +155,7 @@ private fun HostJSONSpec.toHostSpecs(
hostName,
mapOf("cluster" to clusterId),
machineModel,
SimPsuFactories.simple(powerModel),
SimPsuFactories.simple(powerModel, thermalModel),
)
hostId++

Expand Down
zohaib-c marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public data class HostJSONSpec(
val cpu: CPUSpec,
val memory: MemorySpec,
val powerModel: PowerModelSpec = PowerModelSpec("linear", 350.0, 400.0, 200.0),
val thermalModel: ThermalModelSpec =
ThermalModelSpec(
"rcmodel",
0.298,
0.00061,
0.00035,
0.0041,
1.8,
22.0,
),
val count: Int = 1,
)

Expand Down Expand Up @@ -116,3 +126,14 @@ public data class PowerModelSpec(
require(maxPower >= idlePower) { "The max power of a power model can not be less than the idle power" }
}
}

@Serializable
public data class ThermalModelSpec(
val modelType: String,
val rHS: Double,
val rCase: Double,
val minLeakageCurrent: Double,
val maxLeakageCurrent: Double,
val supplyVoltage: Double,
val ambientTemperature: Double,
)
97 changes: 97 additions & 0 deletions opendc-experiments/opendc-experiments-scenario/build.gradle.kts
zohaib-c marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

/*
* Copyright (c) 2019 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.
*/

description = "Experiments for the Scenario work"

// Build configuration
plugins {
`kotlin-library-conventions`
`kotlin-conventions`
`testing-conventions`
`jacoco-conventions`
`benchmark-conventions`
distribution
kotlin("plugin.serialization") version "1.9.22"
}

dependencies {
implementation(projects.opendcSimulator.opendcSimulatorCore)
implementation(projects.opendcSimulator.opendcSimulatorCompute)
implementation(projects.opendcCompute.opendcComputeSimulator)

implementation(libs.clikt)
implementation(libs.progressbar)
implementation(libs.kotlin.logging)

implementation(libs.jackson.module.kotlin)
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")

implementation(project(mapOf("path" to ":opendc-compute:opendc-compute-telemetry")))
implementation(project(mapOf("path" to ":opendc-compute:opendc-compute-topology")))
implementation(project(mapOf("path" to ":opendc-compute:opendc-compute-workload")))
implementation(project(mapOf("path" to ":opendc-experiments:opendc-experiments-base")))

runtimeOnly(libs.log4j.core)
runtimeOnly(libs.log4j.slf4j)
}

val createScenarioApp by tasks.creating(CreateStartScripts::class) {
dependsOn(tasks.jar)

applicationName = "scenario"
mainClass.set("org.opendc.experiments.scenario.ScenarioCli")
classpath = tasks.jar.get().outputs.files + configurations["runtimeClasspath"]
outputDir = project.buildDir.resolve("scripts")
}

// Create custom Greenifier distribution
distributions {
main {
distributionBaseName.set("scenario")

contents {
from("README.md")
from("LICENSE.txt")
from("../../LICENSE.txt") {
rename { "LICENSE-OpenDC.txt" }
}

into("bin") {
from(createScenarioApp)
}

into("lib") {
from(tasks.jar)
from(configurations["runtimeClasspath"])
}

into("resources") {
from("src/main/resources")
}

into("Python_scripts") {
from("src/main/Python_scripts")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public final class SimBareMetalMachine extends SimAbstractMachine {
private final Memory memory;
private final List<NetworkAdapter> net;
private final List<StorageDevice> disk;

/**
* Construct a {@link SimBareMetalMachine} instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public abstract class SimPsu extends SimPowerInlet {
*/
public abstract double getPowerDraw();

/**
* Return the temperature of the Host in degrees Celsius based on a power equation.
*/
public abstract double getTemperature();

/**
* Set the temperature of the Host in degrees Celsius based on a power equation.
*/
public abstract void setTemperature();

/**
* Return the cumulated energy usage of the machine (in J) measured at the inlet of the powers supply.
*/
Expand Down
Loading