From c7ee3931d5021e1454e96dac4bccdf3eb156ad59 Mon Sep 17 00:00:00 2001
From: Prakalp Srivastava <prakalps@gmail.com>
Date: Thu, 11 Jun 2015 10:29:54 -0500
Subject: [PATCH] Fixed a bug in calculating opencl timers average

---
 llvm/test/VISC/parboil/driver/options.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/llvm/test/VISC/parboil/driver/options.py b/llvm/test/VISC/parboil/driver/options.py
index 51a2eb776d..c1141a81e8 100644
--- a/llvm/test/VISC/parboil/driver/options.py
+++ b/llvm/test/VISC/parboil/driver/options.py
@@ -16,6 +16,7 @@ import StringIO
 import re
 import actions
 import csv
+import copy
 import globals
 
 def invalid_option_message(progname, cmd, args):
@@ -257,9 +258,9 @@ def time_options(progname, cmd, args):
         return val
 
     def compileTimings(timings):
+        label_f = 'Final'
+        label_pb = 'Parboil'
         if len(timings) == 4:
-            label_f = 'Final'
-            label_pb = 'Parboil'
             label_ptx = 'NVPTX_Timer'
             label_x86 = 'X86_Timer'
             label_gen = 'GenVISC_Timer'
@@ -279,13 +280,13 @@ def time_options(progname, cmd, args):
             timings[label_f]['WorkGroup Size Calculation'] = addTime([(label_ptx, 'Misc')], timings)
             timings[label_f]['Kernel'] = addTime([(label_ptx, 'Kernel')], timings)
             timings[label_f]['Read Output'] = addTime([(label_ptx, 'Read_Output'), (label_pb, 'Copy')], timings)
-            timings[label_f]['Free Memory'] = addTime([(label_ptx, 'Mem_Free'), (label_ptx, 'Mem_Untrack')], timings)
+            timings[label_f]['Free Memory'] = addTime([(label_ptx, 'Mem_Free'), (label_pb, 'Mem_Untrack')], timings)
             timings[label_f]['Clear Context'] = addTime([(label_ptx, 'Clear_Ctx')], timings)
+            timings[label_f]['Timer Wall Time'] = addTime([(label_pb, 'Timer Wall Time')], timings)
         else:
             if len(timings) == 1:
-                label_f = 'Final'
-                label_pb = 'Parboil'
-                timings[label_f] = timings[label_pb]
+                timings[label_f] = copy.deepcopy(timings[label_pb])
+        timings[label_f]['Timer Wall - IO'] = timings[label_f]['Timer Wall Time'] - timings[label_f]['IO']
 
     def parseLogForTimer():
         timings = {}
@@ -302,10 +303,13 @@ def time_options(progname, cmd, args):
                 if timerName != 'NVPTX_Timer' and timerName != 'X86_Timer' and timerName != 'GenVISC_Timer':
                     print "Warning: Found unknown timer " + timerName
                 continue
-            m = re.search('(?P<timerID>[a-zA-Z _]+) *: *(?P<value>[0-9]*\.[0-9]*) *$', line)
+            m = re.search('(?P<timerID>[a-zA-Z _/]+) *: *(?P<value>[0-9]*\.[0-9]*) *$', line)
             if m:
                 if timings[timerName] is not None:
                     timings[timerName][m.group('timerID').strip()] = float(m.group('value').strip())
+                    #print timings[timerName][m.group('timerID').strip()]
+                    #print m.group('value').strip()
+                    #print
                 else:
                     print "Error: Found unknown timer:" + timerName
         if timings is not {}:
-- 
GitLab