1# Copyright (c) 2015-2016 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 21 unchanged lines hidden (view full) --- 30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35# 36# Authors: Andreas Hansson 37 |
38from __future__ import print_function 39 |
40import gzip 41import optparse 42import os 43 44import m5 45from m5.objects import * 46from m5.util import addToPath 47from m5.stats import periodicStatDump --- 9 unchanged lines hidden (view full) --- 57# configurations, in essence replicating the lmbench lat_mem_rd thrash 58# behaviour 59 60# import the packet proto definitions, and if they are not found, 61# attempt to generate them automatically 62try: 63 import packet_pb2 64except: |
65 print("Did not find packet proto definitions, attempting to generate") |
66 from subprocess import call 67 error = call(['protoc', '--python_out=configs/dram', 68 '--proto_path=src/proto', 'src/proto/packet.proto']) 69 if not error: |
70 print("Generated packet proto definitions") |
71 72 try: 73 import google.protobuf 74 except: |
75 print("Please install the Python protobuf module") |
76 exit(-1) 77 78 import packet_pb2 79 else: |
80 print("Failed to import packet proto definitions") |
81 exit(-1) 82 83parser = optparse.OptionParser() 84 85parser.add_option("--mem-type", type="choice", default="DDR3_1600_8x8", 86 choices=MemConfig.mem_names(), 87 help = "type of memory to use") 88parser.add_option("--mem-size", action="store", type="string", 89 default="16MB", 90 help="Specify the memory size") 91parser.add_option("--reuse-trace", action="store_true", 92 help="Prevent generation of traces and reuse existing") 93 94(options, args) = parser.parse_args() 95 96if args: |
97 print("Error: script doesn't take any positional arguments") |
98 sys.exit(1) 99 100# start by creating the system itself, using a multi-layer 2.0 GHz 101# crossbar, delivering 64 bytes / 3 cycles (one header cycle) which 102# amounts to 42.7 GByte/s per layer and thus per port 103system = System(membus = SystemXBar(width = 32)) 104system.clk_domain = SrcClockDomain(clock = '2.0GHz', 105 voltage_domain = --- 62 unchanged lines hidden (view full) --- 168 169# for every data point, we create a trace containing a random address 170# sequence, so that we can play back the same sequence for warming and 171# the actual measurement 172def create_trace(filename, max_addr, burst_size, itt): 173 try: 174 proto_out = gzip.open(filename, 'wb') 175 except IOError: |
176 print("Failed to open ", filename, " for writing") |
177 exit(-1) 178 179 # write the magic number in 4-byte Little Endian, similar to what 180 # is done in src/proto/protoio.cc 181 proto_out.write("gem5") 182 183 # add the packet header 184 header = packet_pb2.PacketHeader() --- 20 unchanged lines hidden (view full) --- 205 packet.tick = long(tick) 206 packet.addr = long(addr) 207 protolib.encodeMessage(proto_out, packet) 208 tick = tick + itt 209 210 proto_out.close() 211 212# this will take a while, so keep the user informed |
213print("Generating traces, please wait...") |
214 215nxt_range = 0 216nxt_state = 0 217period = long(itt * (max_range / burst_size)) 218 219# now we create the states for each range 220for r in ranges: 221 filename = os.path.join(m5.options.outdir, --- 79 unchanged lines hidden (view full) --- 301# run Forrest, run! 302root = Root(full_system = False, system = system) 303root.system.mem_mode = 'timing' 304 305m5.instantiate() 306m5.simulate(nxt_state * period) 307 308# print all we need to make sense of the stats output |
309print("lat_mem_rd with %d iterations, ranges:" % iterations) |
310for r in ranges: |
311 print(r) |