adjusted test due to hidden operand dependencies

This commit is contained in:
JanLJL
2020-01-17 08:13:15 +01:00
parent 6d6d3b7ccb
commit 5b1c984552
4 changed files with 24 additions and 8 deletions

View File

@@ -2699,6 +2699,7 @@ instruction_forms:
source: true
destination: true
- name: vzeroall
operands: []
hidden_operands:
- class: "register"
name: "ymm0"
@@ -2765,6 +2766,7 @@ instruction_forms:
source: false
destination: true
- name: vzeroupper
operands: []
# TODO not quite correct:
# only upper half is zeroed, not the xmm part
hidden_operands:

View File

@@ -57,7 +57,10 @@ class MachineModel(object):
line = f.readline()
self._data = yaml.load(file_content)
self._data['instruction_forms'] = []
self._data['instruction_dict'] = self._convert_to_dict(self._data['instruction_forms'])
# For use with dict instead of list as DB
# self._data['instruction_dict'] = (
# self._convert_to_dict(self._data['instruction_forms'])
# )
def __getitem__(self, key):
"""Return configuration entry."""
@@ -71,6 +74,7 @@ class MachineModel(object):
def get_instruction(self, name, operands):
"""Find and return instruction data from name and operands."""
# For use with dict instead of list as DB
# return self.get_instruction_from_dict(name, operands)
if name is None:
return None
@@ -79,7 +83,10 @@ class MachineModel(object):
instruction_form
for instruction_form in self._data['instruction_forms']
if instruction_form['name'].upper() == name.upper()
and self._match_operands(instruction_form['operands'], operands)
and self._match_operands(
instruction_form['operands'] if 'operands' in instruction_form else [],
operands,
)
)
except StopIteration:
return None
@@ -256,6 +263,8 @@ class MachineModel(object):
def _get_key(self, name, operands):
key_string = name.lower() + '-'
if operands is None:
return key_string[:-1]
key_string += '_'.join([self._get_operand_hash(op) for op in operands])
return key_string
@@ -263,7 +272,10 @@ class MachineModel(object):
instruction_dict = {}
for instruction_form in instruction_forms:
instruction_dict[
self._get_key(instruction_form['name'], instruction_form['operands'])
self._get_key(
instruction_form['name'],
instruction_form['operands'] if 'operands' in instruction_form else None,
)
] = instruction_form
return instruction_dict

View File

@@ -49,7 +49,8 @@ class TestKerncraftAPI(unittest.TestCase):
)
self.assertEqual(kapi.get_port_occupation_cycles(), port_occupation)
self.assertEqual(kapi.get_total_throughput(), 2.0)
self.assertEqual(kapi.get_latency(), (1.0, 8.0))
# TODO: LCD 2 because of OF flag LCD --> still to discuss?
self.assertEqual(kapi.get_latency(), (2.0, 8.0))
def test_kerncraft_API_AArch64(self):
kapi = KerncraftAPI('tx2', self.code_AArch64)

View File

@@ -186,7 +186,7 @@ class TestSemanticTools(unittest.TestCase):
def test_loop_carried_dependency_x86(self):
lcd_id = 9
lcd_id2 = 6
lcd_id2 = 10
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,13 +198,14 @@ class TestSemanticTools(unittest.TestCase):
self.assertEqual(
lc_deps[lcd_id]['dependencies'][0], dg.dg.nodes(data=True)[lcd_id]['instruction_form']
)
# ID 6
# ursprünglich ID 6 mit LCD zu ID 6 (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']), 1)
self.assertEqual(len(lc_deps[lcd_id2]['dependencies']), 2)
self.assertEqual(
lc_deps[lcd_id2]['dependencies'][0],
lc_deps[lcd_id2]['dependencies'][1],
dg.dg.nodes(data=True)[lcd_id2]['instruction_form'],
)