added test for optimal throughput assignment and invalid asmbench import files

This commit is contained in:
JanLJL
2020-02-20 16:34:11 +01:00
parent 5bdc61aa09
commit 03b4cd1686
2 changed files with 31 additions and 0 deletions

View File

@@ -115,6 +115,16 @@ class TestDBInterface(unittest.TestCase):
for _, e in entries.items():
self.assertIsNotNone(e['throughput'])
self.assertIsNotNone(e['latency'])
# remove empty line => no import since broken format
del input_data[3]
entries = dbi._get_asmbench_output(input_data, 'aarch64')
self.assertEqual(len(entries), 0)
with self.assertRaises(ValueError):
dbi.import_benchmark_output(
'csx', 'invalid_bench_type', self._find_file('asmbench_import_x86.dat')
)
with self.assertRaises(AssertionError):
dbi.import_benchmark_output('csx', 'ibench', 'invalid_file')
##################
# Helper functions

View File

@@ -5,6 +5,7 @@ Unit tests for Semantic Analysis
import os
import unittest
from copy import deepcopy
from subprocess import call
import networkx as nx
@@ -106,6 +107,26 @@ class TestSemanticTools(unittest.TestCase):
self.assertIsInstance(instruction_form['port_pressure'], list)
self.assertEqual(len(instruction_form['port_pressure']), port_num)
def test_optimal_throughput_assignment(self):
# x86
kernel_fixed = deepcopy(self.kernel_x86)
self.semantics_csx.add_semantics(kernel_fixed)
kernel_optimal = deepcopy(kernel_fixed)
self.semantics_csx.assign_optimal_throughput(kernel_optimal)
tp_fixed = self.semantics_csx.get_throughput_sum(kernel_fixed)
tp_optimal = self.semantics_csx.get_throughput_sum(kernel_optimal)
self.assertNotEqual(tp_fixed, tp_optimal)
self.assertTrue(max(tp_optimal) <= max(tp_fixed))
# arm
kernel_fixed = deepcopy(self.kernel_AArch64)
self.semantics_tx2.add_semantics(kernel_fixed)
kernel_optimal = deepcopy(kernel_fixed)
self.semantics_tx2.assign_optimal_throughput(kernel_optimal)
tp_fixed = self.semantics_tx2.get_throughput_sum(kernel_fixed)
tp_optimal = self.semantics_tx2.get_throughput_sum(kernel_optimal)
self.assertNotEqual(tp_fixed, tp_optimal)
self.assertTrue(max(tp_optimal) <= max(tp_fixed))
def test_kernelDG_x86(self):
#
# 4