From 5574a93a5efc743d6a01189a9d563b7f9d680245 Mon Sep 17 00:00:00 2001 From: JanLJL Date: Wed, 29 Jan 2020 13:03:43 +0100 Subject: [PATCH] made detection of flag dependencies as opt_in for now --- osaca/semantics/arch_semantics.py | 14 ++++++++++++++ osaca/semantics/kernel_dg.py | 4 ++-- tests/test_kerncraftAPI.py | 4 ++-- tests/test_semantics.py | 9 +++++---- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/osaca/semantics/arch_semantics.py b/osaca/semantics/arch_semantics.py index 268baa8..cd3c841 100755 --- a/osaca/semantics/arch_semantics.py +++ b/osaca/semantics/arch_semantics.py @@ -249,6 +249,20 @@ class ArchSemantics(ISASemantics): else 0 ) latency_wo_load = instruction_data_reg['latency'] + # add latency of ADD if post- or pre-indexed load + # TODO more investigation: check dot-graph, wrong latency distribution! + # if ( + # latency_wo_load == 0 + # and self._isa == 'aarch64' + # and any( + # [ + # 'post_indexed' in op['memory'] or 'pre_indexed' in op['memory'] + # for op in instruction_form['operands'] + # if 'memory' in op + # ] + # ) + # ): + # latency_wo_load = 1.0 instruction_form['port_pressure'] = [ sum(x) for x in zip( diff --git a/osaca/semantics/kernel_dg.py b/osaca/semantics/kernel_dg.py index 6b46156..7257b8a 100755 --- a/osaca/semantics/kernel_dg.py +++ b/osaca/semantics/kernel_dg.py @@ -147,7 +147,7 @@ class KernelDG(nx.DiGraph): # split to DAG raise NotImplementedError('Kernel is cyclic.') - def find_depending(self, instruction_form, kernel, include_write=False): + def find_depending(self, instruction_form, kernel, include_write=False, flag_dependencies=False): if instruction_form.semantic_operands is None: return for dst in chain(instruction_form.semantic_operands.destination, @@ -166,7 +166,7 @@ class KernelDG(nx.DiGraph): if include_write: yield instr_form break - if 'flag' in dst: + if 'flag' in dst and flag_dependencies: # Check for read of flag until overwrite for instr_form in kernel: if self.is_read(dst.flag, instr_form): diff --git a/tests/test_kerncraftAPI.py b/tests/test_kerncraftAPI.py index ed6a01c..a6cc7aa 100755 --- a/tests/test_kerncraftAPI.py +++ b/tests/test_kerncraftAPI.py @@ -49,8 +49,8 @@ class TestKerncraftAPI(unittest.TestCase): ) self.assertEqual(kapi.get_port_occupation_cycles(), port_occupation) self.assertEqual(kapi.get_total_throughput(), 2.0) - # TODO: LCD 2 because of OF flag LCD --> still to discuss? - self.assertEqual(kapi.get_latency(), (2.0, 8.0)) + # TODO: LCD would be 2 with OF flag LCD --> still to discuss + self.assertEqual(kapi.get_latency(), (1.0, 8.0)) def test_kerncraft_API_AArch64(self): kapi = KerncraftAPI('tx2', self.code_AArch64) diff --git a/tests/test_semantics.py b/tests/test_semantics.py index b162bb7..34ba97a 100755 --- a/tests/test_semantics.py +++ b/tests/test_semantics.py @@ -186,7 +186,7 @@ class TestSemanticTools(unittest.TestCase): def test_loop_carried_dependency_x86(self): lcd_id = 8 - lcd_id2 = 9 + lcd_id2 = 5 dg = KernelDG(self.kernel_x86, self.parser_x86, self.machine_model_csx) lc_deps = dg.get_loopcarried_dependencies() self.assertEqual(len(lc_deps), 2) @@ -198,14 +198,15 @@ class TestSemanticTools(unittest.TestCase): self.assertEqual( lc_deps[lcd_id]['dependencies'][0], dg.dg.nodes(data=True)[lcd_id]['instruction_form'] ) - # ID 9 ursprünglich ID 5 mit LCD zu ID 5 (len=1) + # w/ flag dependencies: ID 9 w/ len=2 + # w/o flag dependencies: ID 5 w/ len=1 # TODO discuss self.assertEqual( lc_deps[lcd_id2]['root'], dg.dg.nodes(data=True)[lcd_id2]['instruction_form'] ) - self.assertEqual(len(lc_deps[lcd_id2]['dependencies']), 2) + self.assertEqual(len(lc_deps[lcd_id2]['dependencies']), 1) self.assertEqual( - lc_deps[lcd_id2]['dependencies'][1], + lc_deps[lcd_id2]['dependencies'][0], dg.dg.nodes(data=True)[lcd_id2]['instruction_form'], )