decode_inst_dep_trace.py (11250:3db78b2af869) decode_inst_dep_trace.py (11252:18bb597fc40c)
1#!/usr/bin/env python
2
3# Copyright (c) 2013 - 2015 ARM Limited
4# All rights reserved
5#
6# The license below extends only to copyright in the software and shall
7# not be construed as granting a license to any other intellectual
8# property including but not limited to intellectual property relating

--- 57 unchanged lines hidden (view full) ---

66#
67# Authors: Radhika Jagtap
68#
69
70# This script is used to dump protobuf traces of the instruction dependency
71# graph to ASCII format.
72#
73# The ASCII trace format uses one line per instruction with the format
1#!/usr/bin/env python
2
3# Copyright (c) 2013 - 2015 ARM Limited
4# All rights reserved
5#
6# The license below extends only to copyright in the software and shall
7# not be construed as granting a license to any other intellectual
8# property including but not limited to intellectual property relating

--- 57 unchanged lines hidden (view full) ---

66#
67# Authors: Radhika Jagtap
68#
69
70# This script is used to dump protobuf traces of the instruction dependency
71# graph to ASCII format.
72#
73# The ASCII trace format uses one line per instruction with the format
74# instruction sequence number, (optional) pc, (optional) weight, load, store,
74# instruction sequence number, (optional) pc, (optional) weight, type
75# (optional) flags, (optional) addr, (optional) size, comp delay,
76# (repeated) order dependencies comma-separated, and (repeated) register
77# dependencies comma-separated.
78#
79# examples:
75# (optional) flags, (optional) addr, (optional) size, comp delay,
76# (repeated) order dependencies comma-separated, and (repeated) register
77# dependencies comma-separated.
78#
79# examples:
80# seq_num,[pc],[weight,]load,store,[address,size,flags,]comp_delay:[rob_dep]:
80# seq_num,[pc],[weight,]type,[address,size,flags,]comp_delay:[rob_dep]:
81# [reg_dep]
81# [reg_dep]
82# 1,1,False,False,8500::
83# 2,1,False,False,1000:,1:
84# 3,1,True,False,831248,4,74,500:,2:
85# 4,1,False,False,0:,2:
86# 5,1,False,False,500::,4
87# 6,1,False,True,831248,4,74,1000:,3:,4,5
82# 1,35652,1,COMP,8500::
83# 2,35656,1,COMP,0:,1:
84# 3,35660,1,LOAD,1748752,4,74,500:,2:
85# 4,35660,1,COMP,0:,3:
86# 5,35664,1,COMP,3000::,4
87# 6,35666,1,STORE,1748752,4,74,1000:,3:,4,5
88# 7,35666,1,COMP,3000::,4
89# 8,35670,1,STORE,1748748,4,74,0:,6,3:,7
90# 9,35670,1,COMP,500::,7
88
89import protolib
90import sys
91
92# Import the packet proto definitions. If they are not found, attempt
93# to generate them automatically. This assumes that the script is
94# executed from the gem5 root.
95try:

--- 37 unchanged lines hidden (view full) ---

133 header = inst_dep_record_pb2.InstDepRecordHeader()
134 protolib.decodeMessage(proto_in, header)
135
136 print "Object id:", header.obj_id
137 print "Tick frequency:", header.tick_freq
138
139 print "Parsing packets"
140
91
92import protolib
93import sys
94
95# Import the packet proto definitions. If they are not found, attempt
96# to generate them automatically. This assumes that the script is
97# executed from the gem5 root.
98try:

--- 37 unchanged lines hidden (view full) ---

136 header = inst_dep_record_pb2.InstDepRecordHeader()
137 protolib.decodeMessage(proto_in, header)
138
139 print "Object id:", header.obj_id
140 print "Tick frequency:", header.tick_freq
141
142 print "Parsing packets"
143
144 print "Creating enum value,name lookup from proto"
145 enumNames = {}
146 desc = inst_dep_record_pb2.InstDepRecord.DESCRIPTOR
147 for namestr, valdesc in desc.enum_values_by_name.items():
148 print '\t', valdesc.number, namestr
149 enumNames[valdesc.number] = namestr
150
141 num_packets = 0
142 num_regdeps = 0
143 num_robdeps = 0
144 packet = inst_dep_record_pb2.InstDepRecord()
145
146 # Decode the packet messages until we hit the end of the file
147 while protolib.decodeMessage(proto_in, packet):
148 num_packets += 1

--- 5 unchanged lines hidden (view full) ---

154 ascii_out.write(',%s' % (packet.pc))
155 else:
156 ascii_out.write(',0')
157 # Write to file the weight, default is 1
158 if packet.HasField('weight'):
159 ascii_out.write(',%s' % (packet.weight))
160 else:
161 ascii_out.write(',1')
151 num_packets = 0
152 num_regdeps = 0
153 num_robdeps = 0
154 packet = inst_dep_record_pb2.InstDepRecord()
155
156 # Decode the packet messages until we hit the end of the file
157 while protolib.decodeMessage(proto_in, packet):
158 num_packets += 1

--- 5 unchanged lines hidden (view full) ---

164 ascii_out.write(',%s' % (packet.pc))
165 else:
166 ascii_out.write(',0')
167 # Write to file the weight, default is 1
168 if packet.HasField('weight'):
169 ascii_out.write(',%s' % (packet.weight))
170 else:
171 ascii_out.write(',1')
162 # Write to file if it is a load and if it is a store
163 ascii_out.write(',%s,%s' % (packet.load, packet.store))
172 # Write to file the type of the record
173 try:
174 ascii_out.write(',%s' % enumNames[packet.type])
175 except KeyError:
176 print "Seq. num", packet.seq_num, "has unsupported type", \
177 packet.type
178 exit(-1)
164
179
180
165 # Write to file if it has the optional fields addr, size, flags
166 if packet.HasField('addr'):
167 ascii_out.write(',%s' % (packet.addr))
168 if packet.HasField('size'):
169 ascii_out.write(',%s' % (packet.size))
170 if packet.HasField('flags'):
171 ascii_out.write(',%s' % (packet.flags))
172

--- 28 unchanged lines hidden ---
181 # Write to file if it has the optional fields addr, size, flags
182 if packet.HasField('addr'):
183 ascii_out.write(',%s' % (packet.addr))
184 if packet.HasField('size'):
185 ascii_out.write(',%s' % (packet.size))
186 if packet.HasField('flags'):
187 ascii_out.write(',%s' % (packet.flags))
188

--- 28 unchanged lines hidden ---