Skip to content

Commit

Permalink
Made changes based on feedback from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
zohaib-c committed Aug 10, 2024
1 parent a2c3c3f commit a46ea88
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public record HostSystemStats(
Instant bootTime,
double powerDraw,
double energyUsage,
double temperatureC,
double cpuTemperature,
int guestsTerminated,
int guestsRunning,
int guestsError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public class SimHost(
localBootTime,
machine.psu.powerDraw,
machine.psu.energyUsage,
machine.psu.temperature,
machine.psu.cpuTemperature,
terminated,
running,
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public class ComputeMetricReader(
_cpuLostTime = table.cpuLostTime
_powerDraw = table.powerDraw
_energyUsage = table.energyUsage
_temperature = table.temperature
_cpuTemperature = table.cpuTemperature
_carbonIntensity = table.carbonIntensity
_carbonEmission = table.carbonEmission
_uptime = table.uptime
Expand Down Expand Up @@ -329,9 +329,9 @@ 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 cpuTemperature: Double
get() = _cpuTemperature
private var _cpuTemperature = 0.0

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

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

_powerDraw = 0.0
_energyUsage = 0.0
_temperature = 0.0
_cpuTemperature = 0.0
_carbonIntensity = 0.0
_carbonEmission = 0.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public class ParquetHostDataWriter(path: File, bufferSize: Int) :
consumer.addDouble(data.energyUsage)
consumer.endField("energy_usage", 19)

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

consumer.startField("carbon_intensity", 21)
consumer.addDouble(data.carbonIntensity)
Expand Down Expand Up @@ -262,7 +262,7 @@ public class ParquetHostDataWriter(path: File, bufferSize: Int) :
.named("energy_usage"),
Types
.required(PrimitiveType.PrimitiveTypeName.DOUBLE)
.named("temperature_C"),
.named("cpuTemperature"),
Types
.required(PrimitiveType.PrimitiveTypeName.DOUBLE)
.named("carbon_intensity"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public interface HostTableReader {
/**
* The current temperature of the host in degrees Celsius.
*/
public val temperature: Double
public val cpuTemperature: 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 @@ -58,6 +58,7 @@ public data class ClusterSpec(
* @param memory The amount of RAM memory available in Byte
* @param powerModel The power model used to determine the power draw of a host
* @param count The power model used to determine the power draw of a host
* @param thermalModel The thermal model used to determine the temperature of a host - defaults to Intel Xeon Platinum 8160
*/
@Serializable
public data class HostJSONSpec(
Expand Down
97 changes: 0 additions & 97 deletions opendc-experiments/opendc-experiments-scenario/build.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class SimPsu extends SimPowerInlet {
/**
* Return the temperature of the Host in degrees Celsius based on a power equation.
*/
public abstract double getTemperature();
public abstract double getCpuTemperature();

/**
* Set the temperature of the Host in degrees Celsius based on a power equation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public double getEnergyUsage() {
}

@Override
public double getTemperature() {
public double getCpuTemperature() {
return 0;
}

Expand Down Expand Up @@ -182,7 +182,7 @@ public void setTemperature() {
}

@Override
public double getTemperature() {
public double getCpuTemperature() {
return machineTemp;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@

package org.opendc.simulator.compute.thermal

// FIXME: This currently only works for RC models, we need to generalize this to support more models.

/**
* A factory for creating thermal models.
* @param modelType The type of the thermal model to create.
* @param rHS The thermal resistance between the heat source and the heat sink.
* @param rCase The thermal resistance between the heat sink and the ambient.
* @param minLeakageCurrent The minimum leakage current of the heat source.
* @param maxLeakageCurrent The maximum leakage current of the heat source.
* @param supplyVoltage The supply voltage of the heat source.
* @param ambientTemperature The ambient temperature of the heat source.
* @return The thermal model.
*/
public fun getThermalModel(
modelType: String,
rHS: Double,
Expand All @@ -42,10 +55,13 @@ public fun getThermalModel(
ambientTemperature,
)

else -> throw IllegalArgumentException("Unknown power modelType $modelType")
else -> throw IllegalArgumentException("Unknown thermal modelType $modelType")
}
}

/**
* The default factory for creating RC thermal model using the values from an Intel Xeon Platinum 8160.
*/
public fun getThermalModel(modelType: String): ThermalModel {
return when (modelType) {
"rcmodel" ->
Expand All @@ -57,9 +73,7 @@ public fun getThermalModel(modelType: String): ThermalModel {
1.8,
22.0,
)
"manufacturerModel" ->
ThermalModels.manufacturerModel(0.278, 47.0)

else -> throw IllegalArgumentException("Unknown power modelType $modelType")
else -> throw IllegalArgumentException("Unknown thermal modelType $modelType")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
public class ThermalModels {

public static ThermalModel rcmodel(
double rHS, double rCase, double minLeakageCurrent, double maxLeakageCurrent, double supplyVoltage, double ambientTemperature) {
double rHS,
double rCase,
double minLeakageCurrent,
double maxLeakageCurrent,
double supplyVoltage,
double ambientTemperature) {
return new RCModel(rHS, rCase, minLeakageCurrent, maxLeakageCurrent, supplyVoltage, ambientTemperature);
}

Expand Down Expand Up @@ -61,8 +66,8 @@ private RCModel(

private void setStaticPower(double dynamicPower, double minPower, double maxPower) {
currentStaticPower =
((maxLeakageCurrent - minLeakageCurrent) / (maxPower - minPower) * (dynamicPower - minPower))
+ minLeakageCurrent;
((maxLeakageCurrent - minLeakageCurrent) / (maxPower - minPower) * (dynamicPower - minPower))
+ minLeakageCurrent;
}

private void setThermalPower(double dynamicPower, double minPower) {
Expand All @@ -74,7 +79,7 @@ public double setTemperature(double dynamicPower, double minPower, double maxPow
setStaticPower(dynamicPower, minPower, maxPower);
setThermalPower(dynamicPower, minPower);

return ambientTemperature + (totalPowerDissipated * (rHS + rCase));
return ambientTemperature + (totalPowerDissipated * (rHS + rCase));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ThermalTest {
yield()
assertAll({
assertEquals(expectedPower, machine.psu.thermalPower, 0.0001, "The power draw should be $expectedPower W")
assertEquals(expectedTemperature, machine.psu.temperature, 0.0001, "The temperature should be $expectedTemperature C")
assertEquals(expectedTemperature, machine.psu.cpuTemperature, 0.0001, "The temperature should be $expectedTemperature C")
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,15 @@ public class OpenDCRunner(

val energyConsumptionW = machine.cpus.sumOf { it.energyConsumptionW }
val powerModel = CpuPowerModels.linear(2 * energyConsumptionW, energyConsumptionW * 0.5)
val thermalModel = ThermalModels.rcmodel(0.298, 0.00061, 0.00035, 0.0041, 22.0)
val thermalModel =
ThermalModels.rcmodel(
0.298,
0.00061,
0.00035,
0.0041,
1.8,
22.0,
)

val spec =
HostSpec(
Expand Down

0 comments on commit a46ea88

Please sign in to comment.