Commit 77dabdef authored by Pierre Moreau's avatar Pierre Moreau Committed by Ilia Mirkin

nv-report: Add "shared" as a possible reported field

Signed-off-by: Pierre Moreau's avatarPierre Moreau <pierre.morrow@free.fr>
parent 7dae7f87
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
""" """
We're matching lines like We're matching lines like
5.shader_test - type: 1, local: 0, gpr: 4, inst: 7, bytes: 56 5.shader_test - type: 1, local: 0, shared: 0, gpr: 4, inst: 7, bytes: 56
11.shader_test - type: 1, local: 0, gpr: 4, inst: 1, bytes: 8 11.shader_test - type: 1, local: 0, shared: 0, gpr: 4, inst: 1, bytes: 8
although the order of the fields after the dash does not matter, and all although the order of the fields after the dash does not matter, and all
fields, except for the type, are optional. fields, except for the type, are optional.
...@@ -25,17 +25,20 @@ class Stat(object): ...@@ -25,17 +25,20 @@ class Stat(object):
def __init__(self, m=None): def __init__(self, m=None):
if m: if m:
self.local = getgroupvalue(m, "local") self.local = getgroupvalue(m, "local")
self.shared = getgroupvalue(m, "shared")
self.gpr = getgroupvalue(m, "gpr") self.gpr = getgroupvalue(m, "gpr")
self.inst = getgroupvalue(m, "inst") self.inst = getgroupvalue(m, "inst")
self.bytes = getgroupvalue(m, "bytes") self.bytes = getgroupvalue(m, "bytes")
else: else:
self.local = 0 self.local = 0
self.shared = 0
self.gpr = 0 self.gpr = 0
self.inst = 0 self.inst = 0
self.bytes = 0 self.bytes = 0
def __eq__(self, other): def __eq__(self, other):
return (self.local == other.local and return (self.local == other.local and
self.shared == other.shared and
self.gpr == other.gpr and self.gpr == other.gpr and
self.inst == other.inst and self.inst == other.inst and
self.bytes == other.bytes) self.bytes == other.bytes)
...@@ -45,6 +48,7 @@ class Stats(object): ...@@ -45,6 +48,7 @@ class Stats(object):
def __init__(self): def __init__(self):
self.stats = {} self.stats = {}
self.local = 0 self.local = 0
self.shared = 0
self.gpr = 0 self.gpr = 0
self.inst = 0 self.inst = 0
self.bytes = 0 self.bytes = 0
...@@ -52,13 +56,14 @@ class Stats(object): ...@@ -52,13 +56,14 @@ class Stats(object):
def record(self, name, stat): def record(self, name, stat):
assert name not in self.stats, name assert name not in self.stats, name
self.stats[name] = stat self.stats[name] = stat
for attr in ("local", "gpr", "inst", "bytes"): for attr in ("local", "shared", "gpr", "inst", "bytes"):
setattr(self, attr, getattr(self, attr) + getattr(stat, attr)) setattr(self, attr, getattr(self, attr) + getattr(stat, attr))
RE = { RE = {
"name": re.compile(r"^(.*) - "), "name": re.compile(r"^(.*) - "),
"type": re.compile(r"type: (\d+)"), "type": re.compile(r"type: (\d+)"),
"local": re.compile(r"local: (\d+)"), "local": re.compile(r"local: (\d+)"),
"shared": re.compile(r"shared: (\d+)"),
"gpr": re.compile(r"gpr: (\d+)"), "gpr": re.compile(r"gpr: (\d+)"),
"inst": re.compile(r"inst: (\d+)"), "inst": re.compile(r"inst: (\d+)"),
"bytes": re.compile(r"bytes: (\d+)") "bytes": re.compile(r"bytes: (\d+)")
...@@ -71,7 +76,7 @@ def analyze(fname): ...@@ -71,7 +76,7 @@ def analyze(fname):
if line.startswith("Thread "): if line.startswith("Thread "):
continue continue
m = {} m = {}
for attr in ("name", "type", "local", "gpr", "inst", "bytes"): for attr in ("name", "type", "local", "shared", "gpr", "inst", "bytes"):
m[attr] = RE[attr].search(line) m[attr] = RE[attr].search(line)
assert m["name"], line assert m["name"], line
assert m["type"], line assert m["type"], line
...@@ -101,7 +106,7 @@ def main(argv): ...@@ -101,7 +106,7 @@ def main(argv):
a = after.stats[key] a = after.stats[key]
b = before.stats[key] b = before.stats[key]
if a != b: if a != b:
for attr in ("local", "gpr", "inst", "bytes"): for attr in ("local", "shared", "gpr", "inst", "bytes"):
aa = getattr(a, attr) aa = getattr(a, attr)
ba = getattr(b, attr) ba = getattr(b, attr)
if aa == ba: if aa == ba:
...@@ -115,15 +120,16 @@ def main(argv): ...@@ -115,15 +120,16 @@ def main(argv):
print "total instructions in shared programs :", diff(before.inst, after.inst) print "total instructions in shared programs :", diff(before.inst, after.inst)
print "total gprs used in shared programs :", diff(before.gpr, after.gpr) print "total gprs used in shared programs :", diff(before.gpr, after.gpr)
print "total shared used in shared programs :", diff(before.shared, after.shared)
print "total local used in shared programs :", diff(before.local, after.local) print "total local used in shared programs :", diff(before.local, after.local)
print print
print "%10s %10s %10s %10s %10s " % ("", "local", "gpr", "inst", "bytes") print "%10s %10s %10s %10s %10s %10s " % ("", "local", "shared", "gpr", "inst", "bytes")
print "%10s " % "helped", print "%10s " % "helped",
for attr in ("local", "gpr", "inst", "bytes"): for attr in ("local", "shared", "gpr", "inst", "bytes"):
print "%10d " % getattr(helped, attr), print "%10d " % getattr(helped, attr),
print print
print "%10s " % "hurt", print "%10s " % "hurt",
for attr in ("local", "gpr", "inst", "bytes"): for attr in ("local", "shared", "gpr", "inst", "bytes"):
print "%10d " % getattr(hurt, attr), print "%10d " % getattr(hurt, attr),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment