m5stats2streamline.py (9935:cc9dc514036e) | m5stats2streamline.py (10016:dffa80408656) |
---|---|
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# | 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) | 59# APC project generation based on Gator v17 (DS-5 v5.17) |
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 | 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) | 81 APC project generation based on Gator v17 (DS-5 v5.17) |
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 | 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 = [] | 201def packed32(x): 202 ret = [] |
203 more = True 204 while more: 205 b = x & 0x7f 206 x = x >> 7 207 if (((x == 0) and ((b & 0x40) == 0)) or \ 208 ((x == -1) and ((b & 0x40) != 0))): 209 more = False 210 else: 211 b = b | 0x80 212 ret.append(b) 213 return ret 214 215# For historical reasons, 32/64-bit versions of functions are presevered 216def packed64(x): 217 return packed32(x) 218 219# variable length packed 4-byte signed value 220def unsigned_packed32(x): 221 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 | 222 if ((x & 0xffffff80) == 0): 223 ret.append(x & 0x7f) 224 elif ((x & 0xffffc000) == 0): 225 ret.append((x | 0x80) & 0xff) 226 ret.append((x >> 7) & 0x7f) 227 elif ((x & 0xffe00000) == 0): 228 ret.append((x | 0x80) & 0xff) 229 ret.append(((x >> 7) | 0x80) & 0xff) --- 7 unchanged lines hidden (view full) --- 237 ret.append((x | 0x80) & 0xff) 238 ret.append(((x >> 7) | 0x80) & 0xff) 239 ret.append(((x >> 14) | 0x80) & 0xff) 240 ret.append(((x >> 21) | 0x80) & 0xff) 241 ret.append((x >> 28) & 0x0f) 242 return ret 243 244# variable length packed 8-byte signed value |
227def packed64(x): | 245def unsigned_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" | 246 ret = [] 247 if ((x & 0xffffffffffffff80) == 0): 248 ret.append(x & 0x7f) 249 elif ((x & 0xffffffffffffc000) == 0): 250 ret.append((x | 0x80) & 0xff) 251 ret.append((x >> 7) & 0x7f) 252 elif ((x & 0xffffffffffe00000) == 0): 253 ret.append((x | 0x80) & 0xff) --- 141 unchanged lines hidden (view full) --- 395 return ret 396 397 398# Summary frame 399# - timestamp: packed64 400# - uptime: packed64 401def summaryFrame(timestamp, uptime): 402 frame_type = "Summary" |
385 body = packed64(timestamp) + packed64(uptime) | 403 newline_canary = stringList("1\n2\r\n3\r4\n\r5") 404 monotonic_delta = packed64(0) 405 end_of_attr = stringList("") 406 body = newline_canary + packed64(timestamp) + packed64(uptime) 407 body += monotonic_delta + end_of_attr |
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 | 408 ret = addFrameHeader(frame_type, body, 0) 409 return ret 410 411# Backtrace frame 412# - not implemented yet 413def backtraceFrame(): 414 pass 415 --- 16 unchanged lines hidden (view full) --- 432 packed_code = packed32(2) 433 body = packed_code + timestampList(timestamp) + \ 434 packed32(thread_id) + stringList(name) 435 ret = addFrameHeader(frame_type, body, 0) 436 return ret 437 438# Core name message 439# - name: string |
418def coreNameFrame(name): | 440# - core_id: packed32 441# - cpuid: packed32 442def coreNameFrame(name, core_id, cpuid): |
419 frame_type = "Name" 420 packed_code = packed32(3) | 443 frame_type = "Name" 444 packed_code = packed32(3) |
421 body = packed_code + stringList(name) | 445 body = packed_code + packed32(core_id) + packed32(cpuid) + stringList(name) |
422 ret = addFrameHeader(frame_type, body, 0) 423 return ret 424 | 446 ret = addFrameHeader(frame_type, body, 0) 447 return ret 448 |
449# IRQ Cookie name message 450# - cookie: packed32 451# - name: string 452# - irq: packed32 453def irqCookieNameFrame(cookie, name, irq): 454 frame_type = "Name" 455 packed_code = packed32(5) 456 body = packed_code + packed32(cookie) + stringList(name) + packed32(irq) 457 ret = addFrameHeader(frame_type, body, 0) 458 return ret 459 |
|
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") | 460# Counter frame message 461# - timestamp: timestamp 462# - core: packed32 463# - key: packed32 464# - value: packed64 465def counterFrame(timestamp, core, key, value): 466 frame_type = "Counter" 467 body = timestampList(timestamp) + packed32(core) + packed32(key) + \ --- 561 unchanged lines hidden (view full) --- 1029 1030 1031# Create captured.xml file in .apc folder 1032def doCapturedXML(output_path, stats): 1033 captured_file = output_path + "/captured.xml" 1034 1035 xml = ET.Element("captured") 1036 xml.set("version", "1") |
1002 xml.set("protocol", "12") | 1037 xml.set("protocol", "17") 1038 xml.set("backtrace_processing", "none") |
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 --- | 1039 1040 target = ET.SubElement(xml, "target") 1041 target.set("name", "gem5") 1042 target.set("sample_rate", "1000") 1043 target.set("cores", str(num_cpus)) 1044 1045 counters = ET.SubElement(xml, "counters") 1046 for stat in stats.stats_list: --- 222 unchanged lines hidden --- |