diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-06-15 22:01:34 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-06-15 22:23:59 +0200 |
| commit | 282f199e6f16350123a915b06faff62ca82be91b (patch) | |
| tree | b2b698d85f7397ef67485d52128a9390f40f7252 /opendc-experiments/opendc-experiments-tf20/src/test | |
| parent | f51bf570f143faf69e3ae361cceac5f0c2420d88 (diff) | |
fix(sim/compute): Always recompute power usage
This change fixes an issue in the `SimBareMetalMachine` implementation
where the power usage was only updated after a non-zero duration. However,
this would mean that OpenDC would possibly report incorrect power usage
values when multiple convergence calls occured at the same timestamp.
Diffstat (limited to 'opendc-experiments/opendc-experiments-tf20/src/test')
2 files changed, 44 insertions, 3 deletions
diff --git a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt index 7d72b48d..328f1326 100644 --- a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt +++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt @@ -26,10 +26,12 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertAll import org.opendc.experiments.tf20.core.SimTFDevice +import org.opendc.experiments.tf20.distribute.MirroredStrategy import org.opendc.experiments.tf20.distribute.OneDeviceStrategy import org.opendc.experiments.tf20.util.MLEnvironmentReader import org.opendc.simulator.compute.power.LinearPowerModel import org.opendc.simulator.core.runBlockingSimulation +import java.util.* /** * Integration test suite for the TensorFlow application model in OpenDC. @@ -61,7 +63,7 @@ class TensorFlowTest { val stats = device.getDeviceStats() assertAll( { assertEquals(3309694252, clock.millis()) }, - { assertEquals(8.2520933087E8, stats.energyUsage) } + { assertEquals(8.27423563E8, stats.energyUsage) } ) } @@ -91,7 +93,46 @@ class TensorFlowTest { val stats = device.getDeviceStats() assertAll( { assertEquals(176230322904, clock.millis()) }, - { assertEquals(4.296544914744E10, stats.energyUsage) } + { assertEquals(4.4057580726E10, stats.energyUsage) } + ) + } + + /** + * Smoke test that tests the capabilities of the TensorFlow application model in OpenDC. + */ + @Test + fun testSmokeDistribute() = runBlockingSimulation { + val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json")) + val def = MLEnvironmentReader().readEnvironment(envInput).first() + + val deviceA = SimTFDevice( + def.uid, def.meta["gpu"] as Boolean, coroutineContext, clock, def.model.cpus[0], def.model.memory[0], + LinearPowerModel(250.0, 60.0) + ) + + val deviceB = SimTFDevice( + UUID.randomUUID(), def.meta["gpu"] as Boolean, coroutineContext, clock, def.model.cpus[0], def.model.memory[0], + LinearPowerModel(250.0, 60.0) + ) + + val strategy = MirroredStrategy(listOf(deviceA, deviceB)) + val batchSize = 32 + val model = AlexNet(batchSize.toLong()) + model.use { + it.compile(strategy) + + it.fit(epochs = 9088 / batchSize, batchSize = batchSize) + } + + deviceA.close() + deviceB.close() + + val statsA = deviceA.getDeviceStats() + val statsB = deviceB.getDeviceStats() + assertAll( + { assertEquals(1704994000, clock.millis()) }, + { assertEquals(4.262485E8, statsA.energyUsage) }, + { assertEquals(4.262485E8, statsB.energyUsage) } ) } } diff --git a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt index 21d30250..051d5730 100644 --- a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt +++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt @@ -69,7 +69,7 @@ internal class SimTFDeviceTest { assertAll( { assertEquals(3681, clock.millis()) }, - { assertEquals(325.75, stats.energyUsage) } + { assertEquals(749.25, stats.energyUsage) } ) } } |
