Skip to content

Commit

Permalink
toplev: Improve test suite. Improve handling of fixed counters
Browse files Browse the repository at this point in the history
Check level 1 grouping
  • Loading branch information
Andi Kleen committed Feb 3, 2015
1 parent 3f40cb0 commit d04e1a8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
45 changes: 25 additions & 20 deletions tl-tester
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,47 @@ LOAD="-- gcc -o /dev/null hello.c"

set -o pipefail

EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py $LOAD
DIRECT_MSR=1 EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py $LOAD
ALLCPUS="snb ivb ivt hsw hsx bdw slm"

EVENTMAP=${cpus[ivb]} FORCECPU=$j $WRAP ./toplev.py $LOAD
DIRECT_MSR=1 EVENTMAP=${cpus[ivb]} FORCECPU=$j $WRAP ./toplev.py $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d -l4 $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -v -d -l4 $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -x, -v -d -l4 $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py --metrics -x, -v -d -l4 $LOAD
EVENTMAP=${cpus[ivt]} FORCECPU=ivt $WRAP ./toplev.py -d --all --kernel $LOAD
EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d --all $LOAD
EVENTMAP=${cpus[jkt]} FORCECPU=jkt $WRAP ./toplev.py -d --all -l5 $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all -l5 $LOAD
# fixme: need event list with missing events
#EVENTMAP=${cpus[hsx]} FORCECPU=hsx $WRAP ./toplev.py -d --all -l5 $LOAD
#EVENTMAP=${cpus[hsx]} FORCECPU=hsx $WRAP ./toplev.py -d --all $LOAD
EVENTMAP=${cpus[ivt]} FORCECPU=ivt $WRAP ./toplev.py -d --all $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --metrics -l4 $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d --all --kernel $LOAD

for j in $ALLCPUS ; do
EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d -l1 $LOAD
EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d --all $LOAD
EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d --all -l5 $LOAD
done

EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --metrics --no-multiplex -l4 $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --power -l4 $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all --no-group $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all --user $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --sw -l4 $LOAD
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py --graph -o x.png -d --metrics -l4 $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d -l4 -I 100 sleep 1
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d -l4 --user $LOAD | tee log
EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py --all -l5 $LOAD
EVENTMAP=${cpus[slm]} FORCECPU=slm $WRAP ./toplev.py --all $LOAD
EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py --all -l5 $LOAD
grep :u log
EVENTMAP=${cpus[slm]} FORCECPU=slm $WRAP ./toplev.py -d --all $LOAD

# test L1 uses a single group
onegroup() {
tr -cd '{}' | awk ' { if ($1 != "{}") { print "more than one group for L1" ; exit(1); } '
}

for j in $ALLCPUS ; do
EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -l1 true $LOAD | onegroup
done

# need new perf
# test other perf output formats
EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-core sleep 1
EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-socket sleep 1
EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a -A sleep 1
# need force smt off first
#EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-core sleep 1
#EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-socket sleep 1
#EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a -A sleep 1

trap "" ERR 0

Expand Down
15 changes: 11 additions & 4 deletions toplev.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
tsx_cpus = ("hsw", "hsx", "bdw")

ingroup_events = frozenset(["cycles", "instructions", "ref-cycles",
"cpu/event=0x0,umask=0x3,any=1/",
"cpu/event=0x3c,umask=0x00,any=1/",
"cpu/event=0x3c,umask=0x0,any=1/",
"cpu/event=0x00,umask=0x1/",
Expand Down Expand Up @@ -407,8 +408,10 @@ def wait(self):

fixed_counters = {
"CPU_CLK_UNHALTED.THREAD": "cycles",
"CPU_CLK_UNHALTED.THREAD:amt1": "cpu/event=0x3c,umask=0x0,any=1/",
"INST_RETIRED.ANY": "instructions",
"CPU_CLK_UNHALTED.REF_TSC": "ref-cycles"
"CPU_CLK_UNHALTED.REF_TSC": "ref-cycles",
"CPU_CLK_UNHALTED.REF_TSC:amt1": "cpu/event=0x0,umask=0x3,any=1/",
}

fixed_set = frozenset(fixed_counters.keys())
Expand All @@ -429,7 +432,9 @@ def raw_event(i):
if i in fixed_counters:
i = fixed_counters[i]
if filter_string():
i += ":" + filter_string()
if ":" not in i:
i += ":"
i += filter_string()
return i
e = emap.getevent(i)
if e is None:
Expand Down Expand Up @@ -646,10 +651,12 @@ def ev_append(ev, level, obj):

def canon_event(e):
m = re.match(r"(.*?):(.*)", e)
if m and m.group(2) != "amt1":
e = m.group(1)
if e in fixed_counters:
return fixed_counters[e]
if m:
e = m.group(1)
if e.upper() in fixed_counters:
return fixed_counters[e.upper()]
if e.endswith("_0"):
e = e[:-2]
return e.lower()
Expand Down

0 comments on commit d04e1a8

Please sign in to comment.