Tool: mp_mpt2trace
Overview
MicroprobeTest (mpt) to trace loop tool provides a command-line interface (CLI) to convert code snippets to execution trace format. Using a test definition format (Microprobe test (mpt) format), the user can specify the initial execution address, the code to be executed as well as the execution and memory access patterns to be generated in the trace.
Note
The microbenchmark generation policy implemented in this tool reproduces exactly the execution pattern and memory access patterns indicated via command line parameters or using decorators in the MPT definition file. This tools does not try to emulate what would be the execution pattern or the memory access pattern of the code. It is up to the user to provide the right pattern to be generated.
Trace formats
Format |
Extension |
Description |
---|---|---|
Qtrace |
|
Note
If the output filename provided ends with .gz
or .bz2
extensions,
the trace generated is automatically compressed using the format
specified.
Basic usage
> mp_mpt2trace -T TARGET -t MPT_DEFINITION_FILE -O TRACE_OUTPUT_FILE
where:
Flag/Argument |
Description |
---|---|
|
Target definition string. Check: Command line target definition scheme. |
|
Microprobe test definition file. Check: Microprobe test (mpt) format. |
|
Output file name. |
Full usage
mp_mpt2trace.py: INFO: Processing input arguments...
usage: mp_mpt2trace.py [-h] [-P SEARCH_PATH [SEARCH_PATH ...]] [-V] [-v] [-d]
[-c CONFIG_FILE [CONFIG_FILE ...]]
[-C FORCE_CONFIG_FILE]
[--dump-configuration-file OUTPUT_CONFIG_FILE]
[--dump-full-configuration-file OUTPUT_CONFIG_FILE]
[-A ARCHITECTURE_PATHS] [-M MICROARCHITECTURE_PATHS]
[-E ENVIRONMENT_PATHS] -T TARGET [--list-architectures]
[--list-microarchitectures] [--list-environments]
[--traceback] [--profile PROFILE_OUTPUT] -t
MPT_DEFINITION_FILE -O TRACE_OUTPUT_FILE
[--default-memory-access-pattern DEFAULT_MEMORY_ACCESS_PATTERN]
[--default-branch-pattern DEFAULT_BRANCH_PATTERN]
[--default-branch-indirect-target-pattern DEFAULT_BRANCH_INDIRECT_TARGET_PATTERN]
[--max-trace-size MAX_TRACE_SIZE] [--show-trace]
[--safe-bin]
MicroprobeTest (mpt) to TRACE tool
optional arguments:
-h, --help show this help message and exit
-P SEARCH_PATH [SEARCH_PATH ...], --default_paths SEARCH_PATH [SEARCH_PATH ...]
Default search paths for microprobe target definitions
-V, --version Show Microprobe version and exit
-v, --verbosity Verbosity level (Values: [0,1,2,3,4]). Each time this
argument is specified the verbosity level is
increased. By default, no logging messages are shown.
These are the four levels available:
-v (1): critical messages
-v -v (2): critical and error messages
-v -v -v (3): critical, error and warning messages
-v -v -v -v (4): critical, error, warning and info messages
Specifying more than four verbosity flags, will
default to the maximum of four. If you need extra
information, enable the debug mode (--debug or -d
flags).
-d, --debug Enable debug mode in Microprobe framework. Lots of
output messages will be generated
Configuration arguments:
Command arguments related to configuration file handling
-c CONFIG_FILE [CONFIG_FILE ...], --configuration CONFIG_FILE [CONFIG_FILE ...]
Configuration file. The configuration files will be
readed in order of appearance. Values are reset by the
last configuration file in case of non-list values.
List values will be appended (not reset)
-C FORCE_CONFIG_FILE, --force-configuration FORCE_CONFIG_FILE
Force configuration file. Use this configuration file
as the default start configuration. This disables any
system-wide, or user-provided configuration.
--dump-configuration-file OUTPUT_CONFIG_FILE
Dump a configuration file with the actual
configuration used
--dump-full-configuration-file OUTPUT_CONFIG_FILE
Dump a configuration file with the actual
configuration used plus all the configuration options
not set
Target path arguments:
Command arguments related to target paths
-A ARCHITECTURE_PATHS, --architecture-paths ARCHITECTURE_PATHS
Search path for architecture definitions. Microprobe
will search in these paths for architecture
definitions
-M MICROARCHITECTURE_PATHS, --microarchitecture-paths MICROARCHITECTURE_PATHS
Search path for microarchitecture definitions.
Microprobe will search in these paths for
microarchitecture definitions
-E ENVIRONMENT_PATHS, --environment-paths ENVIRONMENT_PATHS
Search path for environment definitions. Microprobe
will search in these paths for environment definitions
Target arguments:
Command arguments related to target specification and queries
-T TARGET, --target TARGET
Target tuple. Microprobe follows a GCC-like target
definition scheme, where a target is defined by a
tuple as following:
<arch-name>-<uarch-name>-<env-name>
where:
<arch-name>: is the name of the architecture
<uarch-name>: is the name of the microarchitecture
<env-name>: is the name of the environment
One can use --list-* options to get the list of
definitions available in the default search paths or
the paths specified by the different --*-paths options
--list-architectures Generate a list of architectures available in the
defined search paths and exit
--list-microarchitectures
Generate a list of microarchitectures available in the
defined search paths and exit
--list-environments Generate a list of environments available in the
defined search paths and exit
Debug arguments:
Command arguments related to debugging facilities
--traceback show a traceback and starts a python debugger (pdb)
when an error occurs. 'pdb' is an interactive python
shell that facilitates the debugging of errors
--profile PROFILE_OUTPUT
dump profiling information into given file (see
'pstats' module)
Microprobe Test arguments:
Command arguments related to Microprobe Test (mpt) generation
-t MPT_DEFINITION_FILE, --mpt-definition-file MPT_DEFINITION_FILE
Microprobe test (mpt) definition file
MPT to trace arguments:
Command arguments related to MPT to trace tool
-O TRACE_OUTPUT_FILE, --trace-output-file TRACE_OUTPUT_FILE
C output file name
Trace generation options:
Command arguments related to trace generation options
--default-memory-access-pattern DEFAULT_MEMORY_ACCESS_PATTERN
Memory access pattern for memory references that are
not modeled byMicroprobe or not modeled using 'MP'
decorator in MPT file. Format: comma separated list of
addresses or address ranges. If a file path is
provided, the file is readed to gather the list of
addresses. The format of the file should be one
address or range per line. Address range format is :
<start>-<end>-<strid>. E.g. 0x100-0x200-0x010 will
generate 0x100,0x110,0x120...0x1F0,0x200 pattern.
--default-branch-pattern DEFAULT_BRANCH_PATTERN
Branch pattern for branches that are not modeled
byMicroprobe or not modeled using 'BP' decorator in
MPT file. Format: string with T or N, for taken and
not taken branches, respectively. If a file path is
provided, the file is readed to gather the branch
pattern. The format of the file should be one string
providing the branch pattern (T and N characters).
--default-branch-indirect-target-pattern DEFAULT_BRANCH_INDIRECT_TARGET_PATTERN
Branch target pattern for branches that are not
modeled byMicroprobe or not modeled using 'BT'
decorator in MPT file. Format: comma separated list of
target addresses. If a file path is provided, the file
is readed to gather the list of addresses. The format
of the file should be one address per line.
--max-trace-size MAX_TRACE_SIZE
Maximum trace size in intructions. Default: 100000
--show-trace Show trace while being generated
--safe-bin Ignore unrecognized binary codifications (do notfail).
Useful when MPTs are generated by dumping directly
code pages, which contain padding zeros and other non-
code stuff)
Environment variables:
MICROPROBETEMPLATES Default path for microprobe templates
MICROPROBEDEBUG If set, enable debug
MICROPROBEDEBUGPASSES If set, enable debug during passes
MICROPROBEASMHEXFMT Assembly hexadecimal format. Options:
'all' -> All immediates in hex format
'address' -> Address immediates in hex format (default)
'none' -> All immediate in integer format
Example outputs
Example 1:
Command:
> mp_bin2trace -T power_v300-power9-ppc64_linux_gcc -i mpt2trace_test001.mpt --show-trace --default-memory-access-pattern 0x200000-0x200100-8
Input file:
[CODE] ; Section to specify the code
; Code section default address. Code will be placed from this address
; if the instruction address is not specified
default_address = 0x0000000010020000
; The code specified after 'instructions' entry (below) is the code that will be
; processed by microprobe. The instruction format is similar to GNU assembler
; format, it also allows the specification of labels (NOT case sensitive) and
; references to the declared variables. It is also possible to specify instruction
; addresses and to do code expansion by referencing other user
; defined entries. Check the example below to see examples of these features.
;
; *****************************************************************************
; ****** Although Microprobe performs some sanity checks, it is the ********
; ****** responsibility of the user to define correct code. ********
; ****** ********
; *****************************************************************************
instructions =
<ELF_ABI_START>:
BL c2mpt_function
BL ELF_ABI_EXIT
0x0000000010030000 <C2MPT_FUNCTION>:
ADDIS 9, 2, 0x2
LD 9, -0x7ef8(9)
CMPI 7, 1, 9, 0x0
BC 12, 30, C2MPT_FUNCTION+0X44 @ BP=N ; BP is the branch pattern decorator
; and specifies the branch behavior.
; In this particular case is always
; not taken. One can provide a list
; of T/N characters or a pointer to
; a file.
ADDIS 10, 2, 0x2
LD 10, -0x7eb0(10)
ORI 0, 0, 0
ORI 0, 0, 0
LD 8, 0x0(9) @ MA=0x200-0x240-0x8
LD 9, 0x8(9) @ MA=./mpt2trace_test001_addresses.txt
; MA is the memory access decorator
; and specifies the sequence of
; addresses accessed by this
; instruction. One can provide a
; list of values, a range (start-end-stride)
; or a pointer to a file with
; values or ranges.
CMPI 7, 1, 9, 0x0
ADD 10, 10, 8
BC 4, 30, C2MPT_FUNCTION+0X20 @ BP=TTTTTTTTTTTTTN
RLDICR 10, 10, 1, 62
ADDIS 9, 2, 0x2
STD 10, -0x7eb0(9)
BCLR 20, 0, 0 @ BT=0x10020004 BP=T ; BT is the branch target
; decorator. It is needed to know the
; the target of indirect branches. One
; can provide a comma separated lists
; of targets or a pointer to a file.
ADDIS 10, 2, 0x2
LD 10, -0x7eb0(10)
B C2MPT_FUNCTION+0X34
ORI 0, 0, 0
0x0000000010030060 <MY_SUBROUTINE>:
RLDICR 3, 3, 1, 62
ADDIS 9, 2, 0x2
STD 3, -0x7eb0(9)
BCLR 20, 0, 0 @ BT=0x10020004 BP=T
<ELF_ABI_EXIT>:
ORI 0, 0, 0
Output:
mp_mpt2trace.py: INFO: 0x0000000010020000: ELF_ABI_START:BL 0x10000
mp_mpt2trace.py: INFO: 0x0000000010030000: C2MPT_FUNCTION:ADDIS 9, 2, 0x2
mp_mpt2trace.py: INFO: 0x0000000010030004: LD 9, -0x7ef8(9) memref: 0x0000000000200000
mp_mpt2trace.py: INFO: 0x0000000010030008: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003000c: BC 12, 30, 0x38
mp_mpt2trace.py: INFO: 0x0000000010030010: ADDIS 10, 2, 0x2
mp_mpt2trace.py: INFO: 0x0000000010030014: LD 10, -0x7eb0(10) memref: 0x0000000000200008
mp_mpt2trace.py: INFO: 0x0000000010030018: ORI 0, 0, 0
mp_mpt2trace.py: INFO: 0x000000001003001c: ORI 0, 0, 0
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300000
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300100
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300200
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300300
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300400
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300500
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300600
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300700
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300800
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300900
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300000
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300100
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300200
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030020: LD 8, 0x0(9) memref: 0x0000000000000200
mp_mpt2trace.py: INFO: 0x0000000010030024: LD 9, 0x8(9) memref: 0x0000000000300300
mp_mpt2trace.py: INFO: 0x0000000010030028: CMPI 7, 1, 9, 0x0
mp_mpt2trace.py: INFO: 0x000000001003002c: ADD 10, 10, 8
mp_mpt2trace.py: INFO: 0x0000000010030030: BC 4, 30, -0x10
mp_mpt2trace.py: INFO: 0x0000000010030034: RLDICR 10, 10, 1, 62
mp_mpt2trace.py: INFO: 0x0000000010030038: ADDIS 9, 2, 0x2
mp_mpt2trace.py: INFO: 0x000000001003003c: STD 10, -0x7eb0(9) memref: 0x0000000000200010
mp_mpt2trace.py: INFO: 0x0000000010030040: BCLR 20, 0, 0
mp_mpt2trace.py: INFO: 0x0000000010020004: BL 0x1006c
mp_mpt2trace.py: INFO: 0x0000000010030070: ELF_ABI_EXIT:ORI 0, 0, 0