summaryrefslogtreecommitdiff
path: root/opendc-experiments/opendc-experiments-tf20/src/test
diff options
context:
space:
mode:
authorWenchen Lai <wenchen.lai@hotmail.com>2021-05-09 19:47:17 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-09 19:48:26 +0200
commitf782fe21fe507f0dda74fe7b3932d44d0276a0e8 (patch)
tree986406f60871314d0db68eb6bc0a0cdb0369bd87 /opendc-experiments/opendc-experiments-tf20/src/test
parent052f2b4a80c737e0a3fc38c5facdec5472931aeb (diff)
exp: Model TensorFlow compute devices
Diffstat (limited to 'opendc-experiments/opendc-experiments-tf20/src/test')
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt62
1 files changed, 62 insertions, 0 deletions
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
new file mode 100644
index 00000000..28a2a319
--- /dev/null
+++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+package org.opendc.experiments.tf20.core
+
+import io.opentelemetry.api.metrics.MeterProvider
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.launch
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+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.LinearPowerModel
+import org.opendc.simulator.core.runBlockingSimulation
+import java.util.*
+
+/**
+ * Test suite for the [SimTFDevice] class.
+ */
+internal class SimTFDeviceTest {
+ @Test
+ fun testSmoke() = runBlockingSimulation {
+ val meterProvider: MeterProvider = MeterProvider.noop()
+ val meter = meterProvider.get("opendc-tf20")
+
+ 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, coroutineContext, clock, meter, pu, memory, LinearPowerModel(250.0, 100.0))
+
+ // Load 1 GiB into GPU memory
+ device.load(1000)
+ assertEquals(1140, clock.millis())
+
+ coroutineScope {
+ launch { device.compute(1e6) }
+ launch { device.compute(2e6) }
+ }
+ assertEquals(3681, clock.millis())
+ }
+}