diff options
Diffstat (limited to 'opendc-experiments/opendc-experiments-tf20/src/test')
2 files changed, 132 insertions, 123 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 899aafc0..e3814175 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 @@ -41,114 +41,121 @@ class TensorFlowTest { * Smoke test that tests the capabilities of the TensorFlow application model in OpenDC. */ @Test - fun testSmokeAlexNet() = runSimulation { - val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json")) - val def = MLEnvironmentReader().readEnvironment(envInput).first() - - val device = SimTFDevice( - def.uid, - def.meta["gpu"] as Boolean, - dispatcher, - def.model.cpus[0], - def.model.memory[0], - CpuPowerModels.linear(250.0, 60.0) - ) - val strategy = OneDeviceStrategy(device) - val batchSize = 32 - val model = AlexNet(batchSize.toLong()) - model.use { - it.compile(strategy) - - it.fit(epochs = 9088 / batchSize, batchSize = batchSize) + fun testSmokeAlexNet() = + runSimulation { + val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json")) + val def = MLEnvironmentReader().readEnvironment(envInput).first() + + val device = + SimTFDevice( + def.uid, + def.meta["gpu"] as Boolean, + dispatcher, + def.model.cpus[0], + def.model.memory[0], + CpuPowerModels.linear(250.0, 60.0), + ) + val strategy = OneDeviceStrategy(device) + val batchSize = 32 + val model = getAlexNet(batchSize.toLong()) + model.use { + it.compile(strategy) + + it.fit(epochs = 9088 / batchSize, batchSize = batchSize) + } + + device.close() + + val stats = device.getDeviceStats() + assertAll( + { assertEquals(3309694252, timeSource.millis()) }, + { assertEquals(8.27423563E8, stats.energyUsage) }, + ) } - device.close() - - val stats = device.getDeviceStats() - assertAll( - { assertEquals(3309694252, timeSource.millis()) }, - { assertEquals(8.27423563E8, stats.energyUsage) } - ) - } - /** * Smoke test that tests the capabilities of the TensorFlow application model in OpenDC. */ @Test - fun testSmokeVGG() = runSimulation { - val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json")) - val def = MLEnvironmentReader().readEnvironment(envInput).first() - - val device = SimTFDevice( - def.uid, - def.meta["gpu"] as Boolean, - dispatcher, - def.model.cpus[0], - def.model.memory[0], - CpuPowerModels.linear(250.0, 60.0) - ) - val strategy = OneDeviceStrategy(device) - val batchSize = 128 - val model = VGG16(batchSize.toLong()) - model.use { - it.compile(strategy) - - it.fit(epochs = 9088 / batchSize, batchSize = batchSize) + fun testSmokeVGG() = + runSimulation { + val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json")) + val def = MLEnvironmentReader().readEnvironment(envInput).first() + + val device = + SimTFDevice( + def.uid, + def.meta["gpu"] as Boolean, + dispatcher, + def.model.cpus[0], + def.model.memory[0], + CpuPowerModels.linear(250.0, 60.0), + ) + val strategy = OneDeviceStrategy(device) + val batchSize = 128 + val model = getVGG16(batchSize.toLong()) + model.use { + it.compile(strategy) + + it.fit(epochs = 9088 / batchSize, batchSize = batchSize) + } + + device.close() + + val stats = device.getDeviceStats() + assertAll( + { assertEquals(176230328513, timeSource.millis()) }, + { assertEquals(4.405758212825E10, stats.energyUsage) }, + ) } - device.close() - - val stats = device.getDeviceStats() - assertAll( - { assertEquals(176230328513, timeSource.millis()) }, - { assertEquals(4.405758212825E10, stats.energyUsage) } - ) - } - /** * Smoke test that tests the capabilities of the TensorFlow application model in OpenDC. */ @Test - fun testSmokeDistribute() = runSimulation { - 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, - dispatcher, - def.model.cpus[0], - def.model.memory[0], - CpuPowerModels.linear(250.0, 60.0) - ) - - val deviceB = SimTFDevice( - UUID.randomUUID(), - def.meta["gpu"] as Boolean, - dispatcher, - def.model.cpus[0], - def.model.memory[0], - CpuPowerModels.linear(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) + fun testSmokeDistribute() = + runSimulation { + 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, + dispatcher, + def.model.cpus[0], + def.model.memory[0], + CpuPowerModels.linear(250.0, 60.0), + ) + + val deviceB = + SimTFDevice( + UUID.randomUUID(), + def.meta["gpu"] as Boolean, + dispatcher, + def.model.cpus[0], + def.model.memory[0], + CpuPowerModels.linear(250.0, 60.0), + ) + + val strategy = MirroredStrategy(listOf(deviceA, deviceB)) + val batchSize = 32 + val model = getAlexNet(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, timeSource.millis()) }, + { assertEquals(4.262485E8, statsA.energyUsage) }, + { assertEquals(4.262485E8, statsB.energyUsage) }, + ) } - - deviceA.close() - deviceB.close() - - val statsA = deviceA.getDeviceStats() - val statsB = deviceB.getDeviceStats() - assertAll( - { assertEquals(1704994000, timeSource.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 549c6f3e..76473868 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 @@ -39,36 +39,38 @@ import java.util.UUID */ internal class SimTFDeviceTest { @Test - fun testSmoke() = runSimulation { - val puNode = ProcessingNode("NVIDIA", "Tesla V100", "unknown", 1) - val pu = ProcessingUnit(puNode, 0, 960 * 1230.0) - val memory = MemoryUnit("NVIDIA", "Tesla V100", 877.0, 32_000) + fun testSmoke() = + runSimulation { + val puNode = ProcessingNode("NVIDIA", "Tesla V100", "unknown", 1) + val pu = ProcessingUnit(puNode, 0, 960 * 1230.0) + val memory = MemoryUnit("NVIDIA", "Tesla V100", 877.0, 32_000) - val device = SimTFDevice( - UUID.randomUUID(), - isGpu = true, - dispatcher, - pu, - memory, - CpuPowerModels.linear(250.0, 100.0) - ) + val device = + SimTFDevice( + UUID.randomUUID(), + isGpu = true, + dispatcher, + pu, + memory, + CpuPowerModels.linear(250.0, 100.0), + ) - // Load 1 GiB into GPU memory - device.load(1000) - assertEquals(1140, timeSource.millis()) + // Load 1 GiB into GPU memory + device.load(1000) + assertEquals(1140, timeSource.millis()) - coroutineScope { - launch { device.compute(1e6) } - launch { device.compute(2e6) } - } + coroutineScope { + launch { device.compute(1e6) } + launch { device.compute(2e6) } + } - device.close() + device.close() - val stats = device.getDeviceStats() + val stats = device.getDeviceStats() - assertAll( - { assertEquals(3681, timeSource.millis()) }, - { assertEquals(749.25, stats.energyUsage) } - ) - } + assertAll( + { assertEquals(3681, timeSource.millis()) }, + { assertEquals(749.25, stats.energyUsage) }, + ) + } } |
