Exemple #1
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe Objdump to DMA tool",
                  default_config_file="mp_objdump2dma.cfg")

    groupname = "Objdump to DMA arguments"

    cmdline.add_group(groupname,
                      "Command arguments related to Objdump to DMA tool")

    cmdline.add_option("input-objdump-file",
                       "i",
                       None,
                       "Objdump file to process",
                       group=groupname,
                       opt_type=existing_file,
                       required=True)

    cmdline.add_option("output-dma-file",
                       "O",
                       None,
                       "Output DMA file",
                       group=groupname,
                       opt_type=new_file,
                       required=True)

    cmdline.main(args, _main)
Exemple #2
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe Target definition query tool",
                  default_config_file="mp_target.cfg",
                  force_required=['target'])

    groupname = "Instruction"
    cmdline.add_group(groupname,
                      "Command arguments related to instruction information")

    cmdline.add_option(
        "instructions",
        "ins",
        None,
        "Comma separated list of instructions to obtain information",
        group=groupname,
        opt_type=str,
        required=False)

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #3
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI(
        "Microprobe Objdump to MPT tool",
        default_config_file="mp_objdump2mpt.cfg",
        force_required=['target']
    )

    groupname = "Objdump to MPT arguments"

    cmdline.add_group(
        groupname, "Command arguments related to Objdump to MPT tool"
    )

    cmdline.add_option(
        "input-objdump-file",
        "i",
        None,
        "Objdump file to process, if not provided, the input is read from"
        " standard input",
        group=groupname,
        opt_type=existing_file,
        required=False
    )

    cmdline.add_option(
        "output-mpt-file",
        "O",
        None,
        "Output file name",
        group=groupname,
        opt_type=new_file_ext(".mpt"),
        required=True
    )

    cmdline.add_flag(
        "strict",
        "S",
        "Be strict when parsing objdump input, if not set, silently skip "
        "unparsed elements",
        group=groupname
    )

    cmdline.add_option(
        "sections",
        "s", ['.text'],
        "Space separated CODE section names to interpret. "
        "(default: '.text' section)",
        group=groupname,
        nargs='+',
        required=False
    )

    cmdline.add_option(
        "from-address",
        "f",
        0x0,
        "If set, start interpreting from this address",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False
    )

    cmdline.add_option(
        "to-address",
        "t",
        float('+inf'),
        "If set, end interpreting at this address",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False
    )

    cmdline.add_option(
        "default-code-address",
        "X",
        None,
        "Default code address",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False
    )

    cmdline.add_option(
        "default-data-address",
        "D",
        None,
        "Default data address",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False
    )

    cmdline.add_flag(
        "elf-abi",
        None,
        "Ensure ELF Application Binary Interface (e.g. define stack, stack"
        " pointer, etc.)",
        group=groupname
    )

    cmdline.add_option(
        "stack-size",
        None,
        4096,
        "Stack size in bytes (Default: 4096)",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False
    )

    cmdline.add_option(
        "stack-name",
        None,
        None,
        "Stack name (Default: microprobe_stack)",
        group=groupname,
        opt_type=str,
        required=False
    )

    cmdline.add_option(
        "stack-address",
        None,
        None,
        "Stack address (Default: allocated in the data area)",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False
    )

    cmdline.add_option(
        "start-symbol",
        None,
        None,
        "Symbol to call after initializing the stack. If not specified, "
        "no call is performed",
        group=groupname,
        opt_type=str,
        required=False
    )

    cmdline.add_flag(
        "end-branch-to-itself",
        None,
        "A branch to itself instruction will be added at the end of the test",
        group=groupname
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #4
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI(
        "Microprobe C to MPT tool",
        compilation_options=True,
        default_config_file="mp_c2mpt.cfg",
        force_required=['target'],
    )

    groupname = "C to MPT arguments"

    cmdline.add_group(groupname, "Command arguments related to C to MPT tool")

    cmdline.add_option("input-c-file",
                       "i",
                       None,
                       "C file to process",
                       group=groupname,
                       opt_type=existing_file_ext(".c"),
                       required=False)

    cmdline.add_option("output-mpt-file",
                       "O",
                       None,
                       "Output file name",
                       group=groupname,
                       opt_type=new_file_ext(".mpt"),
                       required=True)

    cmdline.add_flag(
        "strict",
        "S", "Be strict when parsing objdump input, if not set, silently skip "
        "unparsed elements",
        group=groupname)

    cmdline.add_option("default-code-address",
                       "X",
                       0x10030000,
                       "Default code address (default: 0x10030000)",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_option("default-data-address",
                       "D",
                       0x10040000,
                       "Default data address (default: 0x10040000)",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_option("stack-size",
                       None,
                       4096,
                       "Stack size in bytes (Default: 4096)",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_option(
        "host-displacement",
        None,
        None,
        "Displacement between static objdump code and loaded image on the "
        "host. Default computed automatically",
        group=groupname,
        opt_type=int_type(0, float('+inf')),
        required=False)

    cmdline.add_flag(
        "fix-displacement",
        None,
        "If data contains addresses (such as pointers) to code or data "
        "regions, the tool will try to fix them adding the necessary "
        "displacement",
        group=groupname,
    )

    cmdline.add_option("stack-name",
                       None,
                       "microprobe_stack",
                       "Stack name (Default: microprobe_stack)",
                       group=groupname,
                       opt_type=str,
                       required=False)

    cmdline.add_option("stack-address",
                       None,
                       None,
                       "Stack address (Default: allocated in the data area)",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_flag(
        "no-data-initialization",
        None, "Do not run the compiled code locally to get the contents of"
        " registered variables before executing the *c2mpt_function*. Only "
        "statically specified variable contents will be dumped in the MPT"
        " generated",
        group=groupname)

    cmdline.add_flag(
        "save-temps",
        None,
        "Store the generated intermediate files permanently; place them in "
        "the input source file directory and name them based on the source "
        "file",
        group=groupname)

    cmdline.add_flag(
        "dump-c2mpt-template",
        None,
        "Dump a template C file, which can be used afterwards as an input "
        "file",
        group=groupname)

    cmdline.add_flag(
        "end-branch-to-itself",
        None,
        "A branch to itself instruction will be added at the end of the test",
        group=groupname)

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #5
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe epi tool",
                  default_config_file="mp_epi.cfg",
                  force_required=['target'])

    groupname = "EPI arguments"
    cmdline.add_group(groupname, "Command arguments related to EPI generation")

    cmdline.add_option("epi-output-file",
                       "O",
                       None,
                       "Output file name",
                       group=groupname,
                       opt_type=new_file,
                       required=False)

    cmdline.add_option("epi-output-dir",
                       "D",
                       None,
                       "Output directory name",
                       group=groupname,
                       opt_type=existing_dir,
                       required=False)

    cmdline.add_option(
        "instructions",
        "ins",
        None,
        "Comma separated list of instructions to generate a benchmark with",
        group=groupname,
        opt_type=str,
        required=False)

    cmdline.add_option("benchmark-size",
                       "B",
                       4096, "Size in instructions of the microbenchmark."
                       " If more instruction are needed, nested loops are "
                       "automatically generated",
                       group=groupname,
                       opt_type=int_type(1, 999999999999))

    cmdline.add_option(
        "dependency-distance",
        "dd",
        0, "Average dependency distance between instructions. A value"
        " below 1 means not dependency between instructions. A value of "
        "1 means a chain of dependent instructions.",
        group=groupname,
        opt_type=float_type(0, 999999999999))

    cmdline.add_option(
        "data-init",
        None,
        "random",
        "Data initialization values (memory and registers). It can be set"
        " to zero (all zeros) or to random. ",
        group=groupname,
        choices=["random", "zero"],
        opt_type=str)

    cmdline.add_flag(
        "reset",
        "R",
        "Reset the register contents on each loop iteration",
        group=groupname,
    )

    cmdline.add_flag(
        "parallel",
        "p",
        "Generate benchmarks in parallel",
        group=groupname,
    )

    cmdline.add_flag(
        "skip",
        "s",
        "Skip benchmarks already generated",
        group=groupname,
    )

    cmdline.add_flag(
        "ignore-errors",
        "ie",
        "Ignore error during code generation (continue in case of "
        "an error in a particular parameter combination)",
        group=groupname,
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #6
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe seq tool",
                  default_config_file="mp_seq.cfg",
                  force_required=['target'])

    groupname = "SEQ arguments"
    cmdline.add_group(groupname,
                      "Command arguments related to Sequence generation")

    cmdline.add_option("seq-output-dir",
                       "D",
                       None,
                       "Output directory name",
                       group=groupname,
                       opt_type=existing_dir,
                       required=True)

    cmdline.add_option(
        "instruction-slots",
        "is",
        4, "Number of instructions slots in the sequence. E.g. '-l 4' will "
        "generate sequences of length 4.",
        group=groupname,
        opt_type=int_type(1, 999999999999))

    cmdline.add_option(
        "instruction-groups",
        "ig",
        None, "Comma separated list of instruction candidates per group. E.g. "
        "-ins ins1,ins2 ins3,ins4. Defines two groups of instruction "
        "candidates: group 1: ins1,ins2 and group 2: ins3,ins4.",
        group=groupname,
        opt_type=str,
        action="append",
        nargs="+")

    cmdline.add_option(
        "instruction-map",
        "im",
        None,
        "Comma separated list specifying groups instruction candidate groups "
        "to be used on each instruction slot. The list length should match "
        "the number of instruction slots defined.  A -1 value means all groups"
        " can be used for that slot. E.g. -im 1 2,3 will generate sequences "
        "containing in slot 1 instructions from group 1, and in slot 2 "
        "instructions from groups 2 and 3.",
        group=groupname,
        opt_type=str,
        required=False,
        action="append",
        nargs="+")

    cmdline.add_option(
        "base-seq",
        "bs",
        None,
        "Comma separated list specifying the base instruction sequence",
        group=groupname,
        opt_type=str,
        required=False,
    )

    cmdline.add_option(
        "group-max",
        "gM",
        None,
        "Comma separated list specifying the maximum number of instructions "
        " of each group to be used. E.g. -gM 1,3 will generate sequences "
        "containing at most 1 instruction of group 1 and 3 instructions of "
        "group 2. A -1 value means no maximum. The list length should match "
        "the number of instruction groups defined.",
        group=groupname,
        opt_type=str,
        required=False,
        action="append",
        nargs="+")

    cmdline.add_option(
        "group-min",
        "gm",
        None,
        "Comma separated list specifying the minimum number of instructions "
        " of each group to be used. E.g. -gm 1,3 will generate sequences "
        "containing at least 1 instruction of group 1 and 3 instructions of "
        "group 2. A -1 value means no minimum. The list length should match "
        "the number of instruction groups defined.",
        group=groupname,
        opt_type=str,
        required=False,
        action="append",
        nargs="+")

    cmdline.add_option("benchmark-size",
                       "B",
                       4096, "Size in instructions of the microbenchmark."
                       " If more instruction are needed, nested loops are "
                       "automatically generated",
                       group=groupname,
                       opt_type=int_type(1, 999999999999))

    cmdline.add_option(
        "dependency-distance",
        "dd",
        0, "Average dependency distance between instructions. A value"
        " below 1 means not dependency between instructions. A value of "
        "1 means a chain of dependent instructions.",
        group=groupname,
        opt_type=float_type(0, 999999999999))

    cmdline.add_flag(
        "force-switch",
        "fs",
        "Force data switching in all instructions, fail if not supported.",
        group=groupname,
    )

    cmdline.add_flag(
        "reset",
        "R",
        "Reset the register contents on each loop iteration",
        group=groupname,
    )

    cmdline.add_flag(
        "parallel",
        "p",
        "Generate benchmarks in parallel",
        group=groupname,
    )

    cmdline.add_flag(
        "skip",
        "s",
        "Skip benchmarks already generated",
        group=groupname,
    )

    cmdline.add_flag(
        "count",
        "N",
        "Only count the number of sequence to generate. Do not generate "
        "anything",
        group=groupname,
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #7
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe COBOL lst to MPT tool",
                  default_config_file="mp_coblst2mpt.cfg",
                  force_required=['target'])

    groupname = "COBOL lst to MPT arguments"

    cmdline.add_group(groupname,
                      "Command arguments related to COBOL lst to MPT tool")

    cmdline.add_option(
        "input-coblst-file",
        "i",
        None,
        "COBOL lst file to process, if not provided, the input is read from"
        " standard input",
        group=groupname,
        opt_type=existing_file,
        required=False)

    cmdline.add_option("output-mpt-file",
                       "O",
                       None,
                       "Output file name",
                       group=groupname,
                       opt_type=new_file_ext(".mpt"),
                       required=True)

    cmdline.add_flag(
        "strict",
        "S", "Be strict when parsing objdump input, if not set, silently skip "
        "unparsed elements",
        group=groupname)

    cmdline.add_option("from-address",
                       "f",
                       0x0,
                       "If set, start interpreting from this address",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_option("to-address",
                       "t",
                       float('+inf'),
                       "If set, end interpreting at this address",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_option("default-code-address",
                       "X",
                       None,
                       "Default code address",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    cmdline.add_option("default-data-address",
                       "D",
                       None,
                       "Default data address",
                       group=groupname,
                       opt_type=int_type(0, float('+inf')),
                       required=False)

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe Binary to Objdump tool",
                  default_config_file="mp_bin2objdump.cfg",
                  force_required=['target'])

    groupname = "Binary to Objdump arguments"

    cmdline.add_group(groupname,
                      "Command arguments related to Binary to Objdump tool")

    cmdline.add_option("input-bin-file",
                       "i",
                       None,
                       "Binary file to process",
                       group=groupname,
                       opt_type=existing_file,
                       required=True)

    cmdline.add_option("od-bin",
                       "ob",
                       which("od"),
                       "'od' dump utility. Default: %s" % which("od"),
                       group=groupname,
                       opt_type=existing_file)

    cmdline.add_option("start-address",
                       "X",
                       0x0,
                       "Start address. Default: 0x0",
                       group=groupname,
                       opt_type=int_type(0, float("+inf")))

    cmdline.add_flag("strict",
                     "S",
                     "Check relative branches correctness",
                     group=groupname)

    cmdline.main(args, _main)
Exemple #9
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe Binary to Assembly tool",
                  default_config_file="mp_bin2asm.cfg",
                  force_required=['target'])

    groupname = "Binary to Assembly arguments"

    cmdline.add_group(groupname,
                      "Command arguments related to Binary to Assembly tool")

    cmdline.add_option("input-bin-file",
                       "i",
                       None,
                       "Binary file to process",
                       group=groupname,
                       opt_type=existing_file,
                       required=True)

    cmdline.add_option("od-bin",
                       "ob",
                       which("od"),
                       "'od' dump utility. Default: %s" % which("od"),
                       group=groupname,
                       opt_type=existing_file)

    cmdline.add_flag("safe",
                     "S",
                     "Do not fail on unknown decoded binaries",
                     group=groupname)

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #10
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI(
        "Microprobe seqtune tool",
        default_config_file="mp_seqtune.cfg",
        force_required=['target']
    )

    groupname = "SEQTUNE arguments"
    cmdline.add_group(
        groupname, "Command arguments related to Sequence tuner generator"
    )

    cmdline.add_option(
        "seq-output-dir",
        "D",
        None,
        "Output directory name",
        group=groupname,
        opt_type=existing_dir,
        required=True
    )

    cmdline.add_option(
        "sequence",
        "seq",
        None,
        "Base instruction sequence to modify (command separated list of "
        "instructions).",
        group=groupname,
        opt_type=str,
        required=True
    )

    cmdline.add_option(
        "replace-every",
        "re",
        None,
        "Replace every. String with the format 'INSTR1:INSTR2:RANGE' to "
        "specfy that INSTR1 will be replaced by INSTR2 every RANGE "
        "instructions. Range can be just an integer or a RANGE specifier of "
        "the form: #1:#2 to generate a range from #1 to #2, or #1:#2:#3 to "
        "generate a range between #1 to #2 with step #3. E.g. 10:20 generates "
        "10, 11, 12 ... 19, 20 and 10:20:2 generates 10, 12, 14, ... 18, 20.",
        group=groupname,
        opt_type=string_with_fields(":", 3, 3,
                                    [str, str, int_range(1, 10000)]),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "add-every",
        "ae",
        None,
        "Add every. String with the format 'INSTR1:RANGE' to "
        "specfy that INSTR1 will be added to the sequence every RANGE "
        "instructions. Range can be just an integer or a RANGE specifier of "
        "the form: #1-#2 to generate a range from #1 to #2, or #1-#2-#3 to "
        "generate a range between #1 to #2 with step #3. E.g. 10:20 generates "
        "10, 11, 12 ... 19, 20 and 10:20:2 generates 10, 12, 14, ... 18, 20.",
        group=groupname,
        opt_type=string_with_fields(":", 2, 2,
                                    [str, int_range(1, 10000)]),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "branch-every",
        "be",
        None,
        "Conditional branches are modeled not taken by default. Using this "
        "paratemeter, every N will be taken.",
        group=groupname,
        opt_type=int_range(1, 10000),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "branch-pattern",
        "bp",
        None,
        "Branch pattern (in binary) to be generated. E.g 0010 will model the "
        "conditional branches as NotTaken NotTaken Taken NotTaken in a round "
        "robin fashion. One can use 'L<range>' to generate all the patterns "
        "possible of length #. E.g. 'L2-5' will generate all unique possible "
        "branch patterns of length 2,3,4 and 5.",
        group=groupname,
        opt_type=str,
        required=False,
        action="append")

    cmdline.add_flag(
        "data-switch",
        "ds",
        "Enable data switching for instruction. It tries to maximize the "
        "data switching factor on inputs and outputs of instructions.",
        group=groupname,
    )

    cmdline.add_flag(
        "switch-branch",
        "sb",
        "Switch branch pattern in each iteration.",
        group=groupname,
    )

    cmdline.add_flag(
        "memory-switch",
        "ms",
        "Enable data switching for memory operations. It tries to maximize the"
        " data switching factor on loads and store operations.",
        group=groupname,
    )

    cmdline.add_option(
        "memory-stream",
        "me",
        None,
        "Memory stream definition. String with the format "
        "NUM:SIZE:WEIGHT:STRIDE:REGS where NUM is the number of streams of "
        "this type, SIZE is the working set size of the stream in bytes, "
        "WEIGHT is the probability of the stream. E.g. streams with the same"
        "weight will have same probability to be generated. "
        "STRIDE is the stride access patern between the elements of the "
        "stream and REGS is the number of register sets (address base + "
        "address index) to be used for each stream. All the elements of "
        "this format stream can be just a number or a range specfication "
        "(start-end) or (start-end-step). This flag can be specified "
        "multiple times",
        group=groupname,
        opt_type=string_with_fields(":", 5, 5,
                                    [int_range(1, 100),
                                     int_range(1, 2**32),
                                     int_range(1, 10000),
                                     int_range(1, 2**32),
                                     int_range(1, 10)
                                     ]
                                    ),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "benchmark-size",
        "B",
        [4096],
        "Size in instructions of the microbenchmark main loop.",
        group=groupname,
        opt_type=int_range(1, 999999999999),
    )

    cmdline.add_option(
        "dependency-distance",
        "dd",
        0,
        "Average dependency distance between instructions. A value"
        " below 1 means not dependency between instructions. A value of "
        "1 means a chain of dependent instructions.",
        group=groupname,
        opt_type=float_type(0, 999999999999)
    )

    cmdline.add_flag(
        "reset",
        "R",
        "Reset the register contents on each loop iteration",
        group=groupname,
    )

    cmdline.add_flag(
        "parallel",
        "p",
        "Generate benchmarks in parallel",
        group=groupname,
    )

    cmdline.add_flag(
        "skip",
        "s",
        "Skip benchmarks already generated",
        group=groupname,
    )

    cmdline.add_flag(
        "count",
        "N",
        "Only count the number of sequence to generate. Do not generate "
        "anything",
        group=groupname,
    )

    cmdline.add_option(
        "max-memory",
        "Mm",
        999999999999,
        "Maximum memory for all the streams generated",
        group=groupname,
        opt_type=int_type(0, 999999999999)
    )

    cmdline.add_option(
        "min-memory",
        "mm",
        0,
        "Minimum memory for all the streams generated",
        group=groupname,
        opt_type=int_type(0, 999999999999)
    )

    cmdline.add_option(
        "max-regsets",
        "Mr",
        999999999999,
        "Maximum number of regsets for all the streams generated",
        group=groupname,
        opt_type=int_type(1, 999999999999)
    )

    cmdline.add_flag(
        "ignore-errors",
        "ie",
        "Ignore error during code generation (continue in case of "
        "an error in a particular parameter combination)",
        group=groupname,
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #11
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI(
        "Microprobe seqtune tool",
        default_config_file="mp_seqtune.cfg",
        force_required=['target']
    )

    groupname = "SEQTUNE arguments"
    cmdline.add_group(
        groupname, "Command arguments related to Sequence tuner generator"
    )

    cmdline.add_option(
        "seq-output-dir",
        "D",
        None,
        "Output directory name",
        group=groupname,
        opt_type=existing_dir,
        required=True
    )

    cmdline.add_option(
        "sequence",
        "seq",
        None,
        "Base instruction sequence to modify (command separated list of "
        "instructions). If multiple sequences are provided (separated by"
        " a space) they are combined (product).",
        group=groupname,
        opt_type=str,
        required=True,
        nargs="+"
    )

    cmdline.add_option(
        "repeat",
        "r",
        1,
        "If multiple sequences are provided in --sequence, this parameter"
        " specifies how many of them are concated to generate the final "
        "sequence.",
        group=groupname,
        opt_type=int_type(1, 999999999999),
    )

    cmdline.add_option(
        "replace-every",
        "re",
        None,
        "Replace every. String with the format 'INSTR1:INSTR2:RANGE' to "
        "specfy that INSTR1 will be replaced by INSTR2 every RANGE "
        "instructions. Range can be just an integer or a RANGE specifier of "
        "the form: #1:#2 to generate a range from #1 to #2, or #1:#2:#3 to "
        "generate a range between #1 to #2 with step #3. E.g. 10:20 generates "
        "10, 11, 12 ... 19, 20 and 10:20:2 generates 10, 12, 14, ... 18, 20.",
        group=groupname,
        opt_type=string_with_fields(":", 3, 3,
                                    [str, str, int_range(1, 10000)]),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "add-every",
        "ae",
        None,
        "Add every. String with the format 'INSTR1:RANGE' to "
        "specfy that INSTR1 will be added to the sequence every RANGE "
        "instructions. Range can be just an integer or a RANGE specifier of "
        "the form: #1-#2 to generate a range from #1 to #2, or #1-#2-#3 to "
        "generate a range between #1 to #2 with step #3. E.g. 10:20 generates "
        "10, 11, 12 ... 19, 20 and 10:20:2 generates 10, 12, 14, ... 18, 20.",
        group=groupname,
        opt_type=string_with_fields(":", 2, 2,
                                    [str, int_range(1, 10000)]),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "branch-every",
        "be",
        None,
        "Conditional branches are modeled not taken by default. Using this "
        "paratemeter, every N will be taken.",
        group=groupname,
        opt_type=int_range(1, 10000),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "branch-pattern",
        "bp",
        None,
        "Branch pattern (in binary) to be generated. E.g 0010 will model the "
        "conditional branches as NotTaken NotTaken Taken NotTaken in a round "
        "robin fashion. One can use 'L<range>' to generate all the patterns "
        "possible of length #. E.g. 'L2-5' will generate all unique possible "
        "branch patterns of length 2,3,4 and 5.",
        group=groupname,
        opt_type=str,
        required=False,
        action="append")

    cmdline.add_flag(
        "data-switch",
        "ds",
        "Enable data switching for instruction. It tries to maximize the "
        "data switching factor on inputs and outputs of instructions.",
        group=groupname,
    )

    cmdline.add_flag(
        "switch-branch",
        "sb",
        "Switch branch pattern in each iteration.",
        group=groupname,
    )

    cmdline.add_flag(
        "memory-switch",
        "ms",
        "Enable data switching for memory operations. It tries to maximize the"
        " data switching factor on loads and store operations.",
        group=groupname,
    )

    cmdline.add_option(
        "memory-stream",
        "me",
        None,
        "Memory stream definition. String with the format "
        "NUM:SIZE:WEIGHT:STRIDE:REGS:RND:LOC1:LOC2 where NUM is the number "
        "of streams of "
        "this type, SIZE is the working set size of the stream in bytes, "
        "WEIGHT is the probability of the stream. E.g. streams with the same"
        "weight will have same probability to be generated. "
        "STRIDE is the stride access patern between the elements of the "
        "stream and REGS is the number of register sets (address base + "
        "address index) to be used for each stream. "
        "RND controls the randomess of the generated memory access "
        "stream. -1 is full randomness, 0 is not randomness, and any "
        "value above 0 control the randomness range. E.g. a value of "
        "1024 randomizes the accesses within 1024 bytes memory ranges."
        "LOC1 and LOC2 control the temporal locality of the memory access "
        "stream in the following way: the last LOC1 accesses are going "
        "to be accessed again LOC2 times before moving forward to the "
        "next addresses. If LOC2 is 0 not temporal locality is generated "
        "besides the implicit one from the memory access stream definition. "
        "All the elements of "
        "this format stream can be just a number or a range specfication "
        "(start-end) or (start-end-step). This flag can be specified "
        "multiple times",
        group=groupname,
        opt_type=string_with_fields(":", 8, 8,
                                    [int_range(1, 100),
                                     int_range(1, 2**32),
                                     int_range(1, 10000),
                                     int_range(1, 2**32),
                                     int_range(1, 10),
                                     int_range(-1, 2**32),
                                     int_range(1, 2**32),
                                     int_range(0, 2**32),
                                     ]
                                    ),
        required=False,
        action="append"
    )

    cmdline.add_option(
        "benchmark-size",
        "B",
        [4096],
        "Size in instructions of the microbenchmark main loop.",
        group=groupname,
        opt_type=int_range(1, 999999999999),
    )

    cmdline.add_option(
        "dependency-distance",
        "dd",
        0,
        "Average dependency distance between instructions. A value"
        " below 1 means not dependency between instructions. A value of "
        "1 means a chain of dependent instructions.",
        group=groupname,
        opt_type=float_type(0, 999999999999)
    )

    cmdline.add_flag(
        "reset",
        "R",
        "Reset the register contents on each loop iteration",
        group=groupname,
    )

    cmdline.add_flag(
        "endless",
        "e",
        "Some backends allow the control to wrap the sequence generated in an"
        " endless loop. Depending on the target specified, this flag will "
        "force to generate sequences in an endless loop (some targets "
        " might ignore it)",
        group=groupname,
    )

    cmdline.add_flag(
        "parallel",
        "p",
        "Generate benchmarks in parallel",
        group=groupname,
    )

    cmdline.add_option(
        "batch-number",
        "bn",
        1,
        "Batch number to generate. Check --num-batches option for more "
        "details",
        group=groupname,
        opt_type=int_type(1, 10000)
    )

    cmdline.add_option(
        "num-batches",
        "nb",
        1,
        "Number of batches. The number of microbenchmark to generate "
        "is divided by this number, and the number the batch number "
        "specified using -bn option is generated. This is useful to "
        "split the generation of many test cases in various batches.",
        group=groupname,
        opt_type=int_type(1, 10000)
    )

    cmdline.add_flag(
        "skip",
        "s",
        "Skip benchmarks already generated",
        group=groupname,
    )

    cmdline.add_flag(
        "shortnames",
        "sn",
        "Use short output names",
        group=groupname,
    )

    cmdline.add_flag(
        "compress",
        "CC",
        "Compress output files",
        group=groupname,
    )

    cmdline.add_flag(
        "count",
        "N",
        "Only count the number of sequence to generate. Do not generate "
        "anything",
        group=groupname,
    )

    cmdline.add_option(
        "max-memory",
        "Mm",
        999999999999,
        "Maximum memory for all the streams generated",
        group=groupname,
        opt_type=int_type(0, 999999999999)
    )

    cmdline.add_option(
        "min-memory",
        "mm",
        0,
        "Minimum memory for all the streams generated",
        group=groupname,
        opt_type=int_type(0, 999999999999)
    )

    cmdline.add_option(
        "max-regsets",
        "Mr",
        999999999999,
        "Maximum number of regsets for all the streams generated",
        group=groupname,
        opt_type=int_type(1, 999999999999)
    )

    cmdline.add_flag(
        "ignore-errors",
        "ie",
        "Ignore error during code generation (continue in case of "
        "an error in a particular parameter combination)",
        group=groupname,
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
Exemple #12
0
def main():
    """
    Program main
    """
    args = sys.argv[1:]
    cmdline = CLI("Microprobe DMA to Objdump tool",
                  default_config_file="mp_dma2objdump.cfg",
                  force_required=['target'])

    groupname = "DMA to Objdump arguments"

    cmdline.add_group(groupname,
                      "Command arguments related to DMA to Objdump tool")

    cmdline.add_option("input-dma-file",
                       "i",
                       None,
                       "DMA file to process",
                       group=groupname,
                       opt_type=existing_file,
                       required=True)

    cmdline.add_option(
        "width-bytes",
        "w",
        8,
        "Maximum data width in bytes",
        group=groupname,
        opt_type=int_type(0, 32),
    )

    cmdline.add_flag(
        "strict",
        "s",
        "Do not allow unrecognized binary",
        group=groupname,
    )

    cmdline.main(args, _main)