From 788c53bc6ade3d2dbcb52380b553e7e13699ba00 Mon Sep 17 00:00:00 2001
From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Date: Tue, 13 Jun 2023 21:07:18 +0300
Subject: [PATCH] report-fossil: add a parameter to discard stats
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This adds a property to indicate that a statistic change makes all
other statistics uncomparable. This is quite useful on Intel where
shaders are compiled in different variants and a SIMD8 compute shader
cannot be compared to a SIMD16 variant. All that should be visible is
the change of SIMD width.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
---
 report-fossil.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/report-fossil.py b/report-fossil.py
index 7572ef1..4a2016b 100755
--- a/report-fossil.py
+++ b/report-fossil.py
@@ -74,6 +74,7 @@ class Statistic(typing.Generic[T]):
     display_name : str = attr.ib()
     more_is_better : bool = attr.ib(False)
     is_hash : bool = attr.ib(False)
+    change_discard_others : bool = attr.ib(False)
 
 
 statistics = [
@@ -126,7 +127,7 @@ statistics = [
     Statistic(internal_name='read_stalls', csv_names=['Read Stalls'], display_name='Read Stalls'),
 
     # Anv statistics
-    Statistic(internal_name='subgroup_size', csv_names=['Subgroup size'], display_name='Subgroup size', more_is_better=True),
+    Statistic(internal_name='subgroup_size', csv_names=['Subgroup size'], display_name='Subgroup size', more_is_better=True, change_discard_others=True),
     Statistic(internal_name='send_count', csv_names=['SEND Count'], display_name='Send messages'),
     Statistic(internal_name='loop_count', csv_names=['Loop Count'], display_name='Loop count'),
     Statistic(internal_name='cycle_count', csv_names=['Cycle Count'], display_name='Cycle count'),
@@ -311,10 +312,31 @@ class Report(ReportProtocol):
     def include(self, name: str, d0: Result, d1: Result) -> None:
         self.num_shaders += 1
 
+        # Figure out whether a given statistic change means we need to
+        # ignore all others.
+        discard_all_but = None
+        for stat in statistics:
+            m = stat.internal_name
+            d0_m: typing.Optional[int] = getattr(d0, m)
+            if d0_m is None:
+                continue
+            d1_m: typing.Optional[int] = getattr(d1, m)
+            if d1_m is None:
+                continue
+
+            if d0_m != d1_m and stat.change_discard_others:
+                discard_all_but = stat.internal_name
+                break
+
         affected = False
         stats: typing.List[typing.Tuple[Diff, int, int]] = []
         for stat in statistics:
             m = stat.internal_name
+
+            # Should this statistic be ignored?
+            if discard_all_but is not None and m != discard_all_but:
+                continue
+
             d0_m: typing.Optional[int] = getattr(d0, m)
             if d0_m is None:
                 continue
-- 
GitLab