From 0bf2afd73cd384f847749b7407a1d2a627b9456f Mon Sep 17 00:00:00 2001 From: Jan Laukemann Date: Fri, 13 Oct 2017 15:43:47 +0200 Subject: [PATCH] added unittest --- tests/test_osaca.py | 26 ++++++++++++++++++++++++-- tests/test_osaca_iaca_asm.out | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/test_osaca_iaca_asm.out diff --git a/tests/test_osaca.py b/tests/test_osaca.py index 953d0fc..bfd9229 100755 --- a/tests/test_osaca.py +++ b/tests/test_osaca.py @@ -16,9 +16,31 @@ class TestOsaca(unittest.TestCase): osa = Osaca('IVB', curr_dir+'/testfiles/taxCalc-ivb-iaca', out) osa.inspect_with_iaca() result = out.getvalue() - print(result) result = '\n'.join(result.split('\n')[-27:]) -# print(result) with open(curr_dir+'/test_osaca_iaca.out', encoding='utf-8') as f: assertion = f.read() self.assertEqual(assertion, result) + + # Test ASM file with IACA marker in two lines + def testIACAasm1(self): + out = StringIO() + curr_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1]) + osa = Osaca('IVB', curr_dir+'/testfiles/taxCalc-ivb-iaca.S', out) + osa.inspect_with_iaca() + result = out.getvalue() + result = '\n'.join(result.split('\n')[-27:]) + with open(curr_dir+'/test_osaca_iaca_asm.out', encoding='utf-8') as f: + assertion = f.read() + self.assertEqual(assertion, result) + + # Test ASM file with IACA marker in four lines + def testIACAasm2(self): + out = StringIO() + curr_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1]) + osa = Osaca('IVB', curr_dir+'/testfiles/taxCalc-ivb-iaca2.S', out) + osa.inspect_with_iaca() + result = out.getvalue() + result = '\n'.join(result.split('\n')[-27:]) + with open(curr_dir+'/test_osaca_iaca_asm.out', encoding='utf-8') as f: + assertion = f.read() + self.assertEqual(assertion, result) diff --git a/tests/test_osaca_iaca_asm.out b/tests/test_osaca_iaca_asm.out new file mode 100644 index 0000000..bf06672 --- /dev/null +++ b/tests/test_osaca_iaca_asm.out @@ -0,0 +1,26 @@ +Port Binding in Cycles Per Iteration: +---------------------------------------------- +| Port | 0 | 1 | 2 | 3 | 4 | 5 | +---------------------------------------------- +| Cycles | 4.0 | 5.0 | 3.0 | 3.0 | 2.0 | 2.0 | +---------------------------------------------- + + + Ports Pressure in cycles +| 0 | 1 | 2 | 3 | 4 | 5 | +------------------------------------------- +| | | 1.00 | 1.00 | | | lea 1(%rax,%rax), %edx +| 0.50 | 1.00 | | | | 0.50 | vcvtsi2ss %edx, %xmm2, %xmm2 +| 1.00 | | | | | | vmulss %xmm2, %xmm0, %xmm3 +| | | 1.00 | 1.00 | | | lea 2(%rax,%rax), %ecx +| | 1.00 | | | | | vaddss %xmm3, %xmm1, %xmm4 +| 0.33 | 0.33 | | | | 0.33 | vxorps %xmm1, %xmm1, %xmm1 +| 0.50 | 1.00 | | | | 0.50 | vcvtsi2ss %ecx, %xmm1, %xmm1 +| 1.00 | | | | | | vmulss %xmm1, %xmm0, %xmm5 +| | | 0.50 | 0.50 | 1.00 | | vmovss %xmm4, 4(%rsp,%rax,8) +| | 1.00 | | | | | vaddss %xmm5, %xmm4, %xmm1 +| | | 0.50 | 0.50 | 1.00 | | vmovss %xmm1, 8(%rsp,%rax,8) +| 0.33 | 0.33 | | | | 0.33 | incq %rax +| 0.33 | 0.33 | | | | 0.33 | cmpq $499, %rax +| | | | | | | jb ..B1.4 +Total number of estimated throughput: 5.0