示例#1
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)
示例#2
0
def main():
    """Program main."""
    args = sys.argv[1:]
    cmdline = microprobe.utils.cmdline.CLI(
        "MicroprobeTest (mpt) to ELF tool",
        mpt_options=True,
        default_config_file="mp_mpt2elf.cfg",
        force_required=['target'],
    )

    group_name = "MPT to ELF arguments"
    cmdline.add_group(
        group_name, "Command arguments related to MPT to ELF tool",
    )

    cmdline.add_option(
        "elf-output-file",
        "O",
        None,
        "ELF output file name",
        group=group_name,
        opt_type=new_file_ext(".s"),
        required=True,
    )

    cmdline.add_option(
        "compiler",
        None,
        None,
        "Path to the compiler",
        group=group_name,
    )

    cmdline.add_option(
        "compiler-flags",
        None,
        "",
        "Compiler flags to use, if compiler is provided",
        group=group_name,
    )

    group_name = "Fixing options"
    cmdline.add_group(
        group_name,
        "Command arguments related to fixing options",
    )
    cmdline.add_flag(
        "fix-indirect-branches", None, "Fix branches without known target",
        group_name,
    )
    cmdline.add_flag(
        "fix-branch-next", None, "Force target of branches to be the next "
                                 "sequential instruction",
        group_name,
    )
    cmdline.add_flag(
        "fix-memory-references", None,
        "Ensure that registers used by instructions accessing "
        "storage are initialized to valid locations", group_name,
    )
    cmdline.add_flag(
        "fix-memory-registers", None,
        "Fix non-storage instructions touching registers used for"
        " storage address computations (implies "
        "--fix-memory-references flag)", group_name,
    )
    cmdline.add_flag(
        "fix-flatten-code", None,
        "All code is flatten using consecutive addresses",
        group_name,
    )
    cmdline.add_flag(
        "safe-bin", None, "Ignore unrecognized binary codifications (do not"
                          "fail). Useful when MPTs are generated by dumping "
                          "directly code "
                          "pages, which contain padding zeros and other "
                          "non-code stuff)",
        group_name,
    )
    cmdline.add_flag(
        "raw-bin", None, "Process all instruction entries together. They "
                         "all shoud be binary entries. Implies --safe-bin "
                         "flag. Useful when MPTs are generated by dumping "
                         "directly code "
                         "pages, which contain padding zeros and other "
                         "non-code stuff)",
        group_name,
    )
    cmdline.add_flag(
        "fix-long-jump", None,
        "Sometimes the generated code is unable compile due a long jump "
        "displacement required to jump to the start insturction.",
        group_name,
    )

    cmdline.add_option(
        "fix-start-address",
        "S",
        None,
        "Sometimes the user requires the main start point to be on specific "
        "address to avoid compilation issues or comply with the execution "
        "environment requirements. This flag forces the main entry point of "
        "execution to be at the specified address. It is up to the user to "
        "define a proper entry point that does not clash with existing code.",
        group=group_name,
        opt_type=int_type(0, 2**64)
    )

    group_name = "Wrapping options"
    cmdline.add_group(
        group_name,
        "Command arguments related to wrapping options",
    )
    cmdline.add_flag(
        "no-wrap-test", None, "By default the code is wrapped like it was "
                              "a function call, use this flag to disable the "
                              "wrapping",
        group_name,
    )
    cmdline.add_flag(
        "wrap-endless", None, "Use this flag to wrap the code in an endless "
                              "loop assuming it is a function. "
                              "If needed (--reset option), additional "
                              "instructions are added to reset the "
                              "the initial state between loop iterations. ",
        group_name,
    )
    cmdline.add_option(
        "wrap-endless-threshold",
        None,
        1,
        "Maximum percentage of instructions allowed in the reset code if "
        "--wrap-endless and --reset is used. I.e. if 10 is set, the tool will "
        "fail if the reset code required is more than 10%% of the actual "
        "code of the test case."
        " Default is 1%%.",
        group=group_name,
        opt_type=float_type(0, 1000),
        required=False,
    )
    cmdline.add_flag(
        "reset", None, "Use this flag to enable the generation of reset "
                       "code if wrap-endless is enabled.",
        group_name,
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)
示例#3
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)
def main_setup():
    """
    Set up the command line interface (CLI) with the arguments required by
    this command line tool.
    """

    args = sys.argv[1:]

    # Get the target definition
    try:
        target = import_definition("power_v206-power7-ppc64_linux_gcc")
    except MicroprobeTargetDefinitionError as exc:
        print_error("Unable to import target definition")
        print_error("Exception message: %s" % str(exc))
        exit(-1)

    func_units = {}
    valid_units = [elem.name for elem in target.elements.values()]

    for instr in target.isa.instructions.values():
        if instr.execution_units == "None":
            LOG.debug("Execution units for: '%s' not defined", instr.name)
            continue

        for unit in instr.execution_units:
            if unit not in valid_units:
                continue

            if unit not in func_units:
                func_units[unit] = [
                    elem for elem in target.elements.values()
                    if elem.name == unit
                ][0]

    # Create the CLI interface object
    cmdline = microprobe.utils.cmdline.CLI("ISA power v206 profile example",
                                           config_options=False,
                                           target_options=False,
                                           debug_options=False)

    # Add the different parameters for this particular tool
    cmdline.add_option("functional_unit",
                       "f", [func_units['ALU']],
                       "Functional units to stress. Default: ALU",
                       required=False,
                       nargs="+",
                       choices=func_units,
                       opt_type=dict_key(func_units),
                       metavar="FUNCTIONAL_UNIT_NAME")

    cmdline.add_option(
        "output_prefix",
        None,
        "POWER_V206_FU_STRESS",
        "Output prefix of the generated files. Default: POWER_V206_FU_STRESS",
        opt_type=str,
        required=False,
        metavar="PREFIX")

    cmdline.add_option("output_path",
                       "O",
                       "./",
                       "Output path. Default: current path",
                       opt_type=existing_dir,
                       metavar="PATH")

    cmdline.add_option(
        "size",
        "S",
        64, "Benchmark size (number of instructions in the endless loop). "
        "Default: 64 instructions",
        opt_type=int_type(1, 2**20),
        metavar="BENCHMARK_SIZE")

    cmdline.add_option("dependency_distance",
                       "D",
                       1000,
                       "Average dependency distance between the instructions. "
                       "Default: 1000 (no dependencies)",
                       opt_type=int_type(1, 1000),
                       metavar="DEPENDECY_DISTANCE")

    cmdline.add_option("average_latency",
                       "L",
                       2, "Average latency of the selected instructins. "
                       "Default: 2 cycles",
                       opt_type=float_type(1, 1000),
                       metavar="AVERAGE_LATENCY")

    # Start the main
    print_info("Processing input arguments...")
    cmdline.main(args, _main)
示例#5
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)
示例#6
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)
示例#7
0
def main():
    """Program main."""
    args = sys.argv[1:]
    cmdline = microprobe.utils.cmdline.CLI(
        "MicroprobeTest (mpt) to BIN tool",
        mpt_options=True,
        avp_options=False,
        default_config_file="mp_mpt2bin.cfg",
        force_required=['target'],
    )

    group_name = "MPT to BIN arguments"
    cmdline.add_group(
        group_name, "Command arguments related to MPT to BIN tool",
    )

    cmdline.add_option(
        "bin-output-file",
        "O",
        None,
        "BIN output file name",
        group=group_name,
        opt_type=new_file_ext(".bin"),
        required=True,
    )
    cmdline.add_flag(
        "big-endian", None, "Test case in big endian (default is little "
                            "endian)",
        group_name,
    )

    group_name = "Fixing options"
    cmdline.add_group(
        group_name,
        "Command arguments related to fixing options",
    )
    cmdline.add_flag(
        "fix-indirect-branches", None, "Fix branches without known target",
        group_name,
    )
    cmdline.add_flag(
        "fix-branch-next", None, "Force target of branches to be the next "
                                 "sequential instruction",
        group_name,
    )
    cmdline.add_flag(
        "fix-memory-references", None,
        "Ensure that registers used by instructions accessing "
        "storage are initialized to valid locations", group_name,
    )
    cmdline.add_flag(
        "fix-memory-registers", None,
        "Fix non-storage instructions touching registers used for"
        " storage address computations (implies "
        "--fix-memory-references flag)", group_name,
    )
    cmdline.add_flag(
        "fix-flatten-code", None,
        "All code is flatten using consecutive addresses",
        group_name,
    )
    cmdline.add_flag(
        "safe-bin", None, "Ignore unrecognized binary codifications (do not"
                          "fail). Useful when MPTs are generated by dumping "
                          "directly code "
                          "pages, which contain padding zeros and other "
                          "non-code stuff)",
        group_name,
    )

    group_name = "Wrapping options"
    cmdline.add_group(
        group_name,
        "Command arguments related to wrapping options",
    )
    cmdline.add_flag(
        "no-wrap-test", None, "By default the code is wrapped like it was "
                              "a function call, use this flag to disable the "
                              "wrapping",
        group_name,
    )
    cmdline.add_flag(
        "wrap-endless", None, "Use this flag to wrap the code in an endless "
                              "loop assuming it is a function. "
                              "If needed, additional instructions are "
                              "added to reset the "
                              "the initial state between loop iterations. ",
        group_name,
    )
    cmdline.add_option(
        "wrap-endless-threshold",
        None,
        1,
        "Maximum percentage of instructions allowed in the reset code if "
        "--wrap-endless loop is used. I.e. if 10 is set, the tool will "
        "fail if the reset code required is more than 10%% of the actual "
        "code of the test case."
        " Default is 1%%.",
        group=group_name,
        opt_type=float_type(0, 1000),
        required=False,
    )
    cmdline.add_flag(
        "endless", None, "Use this flag to wrap the code in an endless "
                         "loop.",
        group_name,
    )

    print_info("Processing input arguments...")
    cmdline.main(args, _main)