Re: [Mesa-dev] [PATCH shader-db 1/2] report.py: rework and update for cycle info

2015-10-09 Thread Matt Turner
On Fri, Oct 2, 2015 at 2:37 PM, Connor Abbott  wrote:
> Now that we have three separate things we want to measure (instructions,
> cycles, and loops), it's impractical to keep adding special code for
> changes in each thing. Instead, for each program in before and after we
> store a table of measurement -> value, and when reporting we loop over
> each measurement and report helped/hurt before reporting the gained/lost
> programs.
>
> Signed-off-by: Connor Abbott 
> ---
>  report.py | 140 
> ++
>  1 file changed, 67 insertions(+), 73 deletions(-)
>
> diff --git a/report.py b/report.py
> index 4c06714..bc3a640 100755
> --- a/report.py
> +++ b/report.py
> @@ -10,17 +10,22 @@ def get_results(filename):
>
>  results = {}
>
> -re_match = re.compile(r"(\S+) - (.S \S+) shader: (\S*) inst, (\S*) 
> loops")
> +re_match = re.compile(r"(\S+) - (.S \S+) shader: (\S*) inst, (\S*) 
> cycles, (\S*) loops")

I'd like to keep results files generated before your series working,
so to do that we'll have to move cycles after loops.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH shader-db 1/2] report.py: rework and update for cycle info

2015-10-09 Thread Erik Faye-Lund
On Fri, Oct 2, 2015 at 11:37 PM, Connor Abbott  wrote:
> Now that we have three separate things we want to measure (instructions,
> cycles, and loops), it's impractical to keep adding special code for
> changes in each thing. Instead, for each program in before and after we
> store a table of measurement -> value, and when reporting we loop over
> each measurement and report helped/hurt before reporting the gained/lost
> programs.
>
> Signed-off-by: Connor Abbott 
> ---
>  report.py | 140 
> ++
>  1 file changed, 67 insertions(+), 73 deletions(-)
>
> diff --git a/report.py b/report.py
> index 4c06714..bc3a640 100755
> --- a/report.py
> +++ b/report.py
> @@ -10,17 +10,22 @@ def get_results(filename):
>
>  results = {}
>
> -re_match = re.compile(r"(\S+) - (.S \S+) shader: (\S*) inst, (\S*) 
> loops")
> +re_match = re.compile(r"(\S+) - (.S \S+) shader: (\S*) inst, (\S*) 
> cycles, (\S*) loops")
>  for line in lines:
>  match = re.search(re_match, line)
>  if match is None:
>  continue
>
>  groups = match.groups()
> -count = int(groups[2])
> -loop = int(groups[3])
> -if count != 0:
> -results[(groups[0], groups[1])] = count, loop
> +inst_count = int(groups[2])
> +   cycle_count = int(groups[3])

Something's up with the indentation here...
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH shader-db 1/2] report.py: rework and update for cycle info

2015-10-02 Thread Connor Abbott
Now that we have three separate things we want to measure (instructions,
cycles, and loops), it's impractical to keep adding special code for
changes in each thing. Instead, for each program in before and after we
store a table of measurement -> value, and when reporting we loop over
each measurement and report helped/hurt before reporting the gained/lost
programs.

Signed-off-by: Connor Abbott 
---
 report.py | 140 ++
 1 file changed, 67 insertions(+), 73 deletions(-)

diff --git a/report.py b/report.py
index 4c06714..bc3a640 100755
--- a/report.py
+++ b/report.py
@@ -10,17 +10,22 @@ def get_results(filename):
 
 results = {}
 
-re_match = re.compile(r"(\S+) - (.S \S+) shader: (\S*) inst, (\S*) loops")
+re_match = re.compile(r"(\S+) - (.S \S+) shader: (\S*) inst, (\S*) cycles, 
(\S*) loops")
 for line in lines:
 match = re.search(re_match, line)
 if match is None:
 continue
 
 groups = match.groups()
-count = int(groups[2])
-loop = int(groups[3])
-if count != 0:
-results[(groups[0], groups[1])] = count, loop
+inst_count = int(groups[2])
+   cycle_count = int(groups[3])
+loop_count = int(groups[4])
+if inst_count != 0:
+results[(groups[0], groups[1])] = {
+"instructions": inst_count,
+"cycles": cycle_count,
+   "loops": loop_count
+}
 
 return results
 
@@ -50,76 +55,77 @@ def main():
 parser.add_argument("after", type=get_results, help="the output of the new 
code")
 args = parser.parse_args()
 
-total_before = 0
-total_after = 0
-total_before_loop = 0
-total_after_loop = 0
-affected_before = 0
-affected_after = 0
+for measurement in ["instructions", "cycles", "loops"]:
+total_before = 0
+total_after = 0
+affected_before = 0
+affected_after = 0
 
-helped = []
-hurt = []
-lost = []
-gained = []
-loop_change = []
-for p in args.before:
-(name, type) = p
-namestr = name + " " + type
-before_count = args.before[p][0]
-before_loop = args.before[p][1]
+helped = []
+hurt = []
+for p in args.before:
+before_count = args.before[p][measurement]
+
+if args.after.get(p) is None:
+continue
 
-if args.after.get(p) is not None:
-after_count = args.after[p][0]
-after_loop = args.after[p][1]
+# If the number of loops changed, then we may have unrolled some
+# loops, in which case other measurements will be misleading.
+if measurement != "loops" and args.before[p]["loops"] != 
args.after[p]["loops"]:
+continue
 
-total_before_loop += before_loop
-total_after_loop += after_loop
+after_count = args.after[p][measurement]
 
-if before_loop == after_loop:
-total_before += before_count
-total_after += after_count
+total_before += before_count
+total_after += after_count
 
 if before_count != after_count:
 affected_before += before_count
 affected_after += after_count
 
-if after_loop != before_loop:
-loop_change.append(p);
-elif after_count > before_count:
+if after_count > before_count:
 hurt.append(p)
 else:
 helped.append(p)
-else:
-lost.append(namestr)
 
-for p in args.after:
-if args.before.get(p) is None:
-gained.append(p[0] + " " + p[1])
+helped.sort(
+key=lambda k: float(args.before[k][measurement] - 
args.after[k][measurement]) / args.before[k][measurement])
+for p in helped:
+namestr = p[0] + " " + p[1]
+print(measurement + " helped:   " + get_result_string(
+namestr, args.before[p][measurement], 
args.after[p][measurement]))
+if len(helped) > 0:
+print("")
+
+hurt.sort(
+key=lambda k: float(args.after[k][measurement] - 
args.before[k][measurement]) / args.before[k][measurement])
+for p in hurt:
+namestr = p[0] + " " + p[1]
+print(measurement + " HURT:   " + get_result_string(
+namestr, args.before[p][measurement], 
args.after[p][measurement]))
+if len(hurt) > 0:
+print("")
+
+print("total {0} in shared programs: {1}\n"
+ "{0} in affected programs: {2}\n"
+ "helped: {3}\n"
+ "HURT: {4}\n".format(
+ measurement,
+ change(total_before, total_after),
+ change(affected_before, affected_after),
+ len(helped),
+ len(hurt)))
 
-helped.sort