Deleted Added
sdiff udiff text old ( 9935:cc9dc514036e ) new ( 10016:dffa80408656 )
full compact
1#!/usr/bin/env python
2
3# Copyright (c) 2012 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

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

51# util/streamline.
52# NOTE: this is NOT the gem5 config.ini file.
53#
54# <gem5 run folder>: Path to gem5 run folder (must contain config.ini,
55# stats.txt[.gz], and system.tasks.txt.)
56#
57# <dest .apc folder>: Destination .apc folder path
58#
59# APC project generation based on Gator v12 (DS-5 v5.13)
60# Subsequent versions should be backward compatible
61
62import re, sys, os
63from ConfigParser import ConfigParser
64import gzip
65import xml.etree.ElementTree as ET
66import xml.dom.minidom as minidom
67import shutil

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

73 formatter_class=argparse.RawDescriptionHelpFormatter,
74 description="""
75 Converts gem5 runs to ARM DS-5 Streamline .apc project file.
76 (NOTE: Requires gem5 runs to be run with ContextSwitchStatsDump
77 enabled and some patches applied to the target Linux kernel.)
78
79 Visit http://www.gem5.org/Streamline for more details.
80
81 APC project generation based on Gator v12 (DS-5 v5.13)
82 Subsequent versions should be backward compatible
83 """)
84
85parser.add_argument("stat_config_file", metavar="<stat_config.ini>",
86 help=".ini file that describes which stats to be included \
87 in conversion. Sample .ini files can be found in \
88 util/streamline. NOTE: this is NOT the gem5 config.ini \
89 file.")

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

193
194############################################################
195# Types used in APC Protocol
196# - packed32, packed64
197# - int32
198# - string
199############################################################
200
201# variable length packed 4-byte signed value
202def packed32(x):
203 ret = []
204 if ((x & 0xffffff80) == 0):
205 ret.append(x & 0x7f)
206 elif ((x & 0xffffc000) == 0):
207 ret.append((x | 0x80) & 0xff)
208 ret.append((x >> 7) & 0x7f)
209 elif ((x & 0xffe00000) == 0):
210 ret.append((x | 0x80) & 0xff)
211 ret.append(((x >> 7) | 0x80) & 0xff)

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

219 ret.append((x | 0x80) & 0xff)
220 ret.append(((x >> 7) | 0x80) & 0xff)
221 ret.append(((x >> 14) | 0x80) & 0xff)
222 ret.append(((x >> 21) | 0x80) & 0xff)
223 ret.append((x >> 28) & 0x0f)
224 return ret
225
226# variable length packed 8-byte signed value
227def packed64(x):
228 ret = []
229 if ((x & 0xffffffffffffff80) == 0):
230 ret.append(x & 0x7f)
231 elif ((x & 0xffffffffffffc000) == 0):
232 ret.append((x | 0x80) & 0xff)
233 ret.append((x >> 7) & 0x7f)
234 elif ((x & 0xffffffffffe00000) == 0):
235 ret.append((x | 0x80) & 0xff)

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

377 return ret
378
379
380# Summary frame
381# - timestamp: packed64
382# - uptime: packed64
383def summaryFrame(timestamp, uptime):
384 frame_type = "Summary"
385 body = packed64(timestamp) + packed64(uptime)
386 ret = addFrameHeader(frame_type, body, 0)
387 return ret
388
389# Backtrace frame
390# - not implemented yet
391def backtraceFrame():
392 pass
393

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

410 packed_code = packed32(2)
411 body = packed_code + timestampList(timestamp) + \
412 packed32(thread_id) + stringList(name)
413 ret = addFrameHeader(frame_type, body, 0)
414 return ret
415
416# Core name message
417# - name: string
418def coreNameFrame(name):
419 frame_type = "Name"
420 packed_code = packed32(3)
421 body = packed_code + stringList(name)
422 ret = addFrameHeader(frame_type, body, 0)
423 return ret
424
425# Counter frame message
426# - timestamp: timestamp
427# - core: packed32
428# - key: packed32
429# - value: packed64
430def counterFrame(timestamp, core, key, value):
431 frame_type = "Counter"
432 body = timestampList(timestamp) + packed32(core) + packed32(key) + \

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

994
995
996# Create captured.xml file in .apc folder
997def doCapturedXML(output_path, stats):
998 captured_file = output_path + "/captured.xml"
999
1000 xml = ET.Element("captured")
1001 xml.set("version", "1")
1002 xml.set("protocol", "12")
1003
1004 target = ET.SubElement(xml, "target")
1005 target.set("name", "gem5")
1006 target.set("sample_rate", "1000")
1007 target.set("cores", str(num_cpus))
1008
1009 counters = ET.SubElement(xml, "counters")
1010 for stat in stats.stats_list:

--- 222 unchanged lines hidden ---