Deleted Added
sdiff udiff text old ( 11250:3db78b2af869 ) new ( 11252:18bb597fc40c )
full compact
1#!/usr/bin/env python
2
3# Copyright (c) 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 ASCII traces of the instruction dependency
71# graph to protobuf 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,
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]:
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
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:

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

101 'src/proto/inst_dep_record.proto'])
102 if not error:
103 import inst_dep_record_pb2
104 print "Generated proto definitions for instruction dependency record"
105 else:
106 print "Failed to import proto definitions"
107 exit(-1)
108
109def main():
110 if len(sys.argv) != 3:
111 print "Usage: ", sys.argv[0], " <ASCII input> <protobuf output>"
112 exit(-1)
113
114 # Open the file in write mode
115 proto_out = open(sys.argv[2], 'wb')
116

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

128 # Add the packet header
129 header = inst_dep_record_pb2.InstDepRecordHeader()
130 header.obj_id = "Converted ASCII trace " + sys.argv[1]
131 # Assume the default tick rate
132 header.tick_freq = 1000000000
133 header.window_size = 120
134 protolib.encodeMessage(proto_out, header)
135
136 num_records = 0
137 # For each line in the ASCII trace, create a packet message and
138 # write it to the encoded output
139 for line in ascii_in:
140 inst_info_str, rob_dep_str, reg_dep_str = (line.strip()).split(':')
141 inst_info_list = inst_info_str.split(',')
142 dep_record = inst_dep_record_pb2.InstDepRecord()
143
144 dep_record.seq_num = long(inst_info_list[0])
145 dep_record.pc = long(inst_info_list[1])
146 dep_record.weight = long(inst_info_list[2])
147 dep_record.load = True if inst_info_list[3] == 'True' else False
148 dep_record.store = True if inst_info_list[4] == 'True' else False
149
150 # If the instruction is a load or store record the addr, size flags
151 # in addition to recording the computation delay
152 if dep_record.load or dep_record.store:
153 addr, size, flags, comp_delay = inst_info_list[5:9]
154 dep_record.addr = long(addr)
155 dep_record.size = int(size)
156 dep_record.flags = int(flags)
157 dep_record.comp_delay = long(comp_delay)
158 elif not dep_record.load and not dep_record.store:
159 comp_delay = inst_info_list[4]
160 dep_record.comp_delay = long(comp_delay)
161 else:
162 print "Fatal:", seq_num, "is both load and store"
163 exit(1)
164
165 # Parse the register and order dependencies both of which are
166 # repeated fields. An empty list is valid.
167 rob_deps = rob_dep_str.strip().split(',')
168 for a_dep in rob_deps:
169 # if the string is empty, split(',') returns 1 item: ''
170 # if the string is ",4", split(',') returns 2 items: '', '4'
171 # long('') gives error, so check if the item is non-empty

--- 18 unchanged lines hidden ---