0001
0002
0003 from __future__ import print_function
0004
0005 data = {}
0006 times = []
0007 threads = []
0008 cpus = []
0009
0010 def get_key(time, event, cpu, thread):
0011 return "%d-%s-%d-%d" % (time, event, cpu, thread)
0012
0013 def store_key(time, cpu, thread):
0014 if (time not in times):
0015 times.append(time)
0016
0017 if (cpu not in cpus):
0018 cpus.append(cpu)
0019
0020 if (thread not in threads):
0021 threads.append(thread)
0022
0023 def store(time, event, cpu, thread, val, ena, run):
0024
0025
0026
0027 store_key(time, cpu, thread)
0028 key = get_key(time, event, cpu, thread)
0029 data[key] = [ val, ena, run]
0030
0031 def get(time, event, cpu, thread):
0032 key = get_key(time, event, cpu, thread)
0033 return data[key][0]
0034
0035 def stat__cycles_k(cpu, thread, time, val, ena, run):
0036 store(time, "cycles", cpu, thread, val, ena, run);
0037
0038 def stat__instructions_k(cpu, thread, time, val, ena, run):
0039 store(time, "instructions", cpu, thread, val, ena, run);
0040
0041 def stat__cycles_u(cpu, thread, time, val, ena, run):
0042 store(time, "cycles", cpu, thread, val, ena, run);
0043
0044 def stat__instructions_u(cpu, thread, time, val, ena, run):
0045 store(time, "instructions", cpu, thread, val, ena, run);
0046
0047 def stat__cycles(cpu, thread, time, val, ena, run):
0048 store(time, "cycles", cpu, thread, val, ena, run);
0049
0050 def stat__instructions(cpu, thread, time, val, ena, run):
0051 store(time, "instructions", cpu, thread, val, ena, run);
0052
0053 def stat__interval(time):
0054 for cpu in cpus:
0055 for thread in threads:
0056 cyc = get(time, "cycles", cpu, thread)
0057 ins = get(time, "instructions", cpu, thread)
0058 cpi = 0
0059
0060 if ins != 0:
0061 cpi = cyc/float(ins)
0062
0063 print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins))
0064
0065 def trace_end():
0066 pass
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079