def iter_options(self):
        """Returns all the possible combination of:
            - projects,
            - toolchains,
            - families,
            - devices,
            - packages
            - boards.

        Example:
        - path structure:    src/<project>/<toolchain>/<family>_<device>_<package>_<board>.<constraint>
        - valid combination: src/oneblink/vpr/xc7_a35t_csg324-1_arty.pcf
        """

        projects = get_projects()
        toolchains = get_toolchains()

        combinations = set()
        for project, toolchain in list(product(projects, toolchains)):
            project_dict = get_project(project)

            if 'toolchains' in project_dict:
                toolchains_dict = project_dict['toolchains']
            else:
                continue

            if toolchain not in toolchains_dict:
                continue

            for board in toolchains_dict[toolchain]:
                combinations.add((project, toolchain, board))

        return combinations
Exemple #2
0
def parse_args():
    import argparse
    parser = argparse.ArgumentParser(
        description='Exhaustively try project-toolchain-board combinations')
    parser.add_argument('--project',
                        default=None,
                        nargs="+",
                        choices=get_projects(),
                        help='run given project(s) only (default: all)')
    parser.add_argument('--toolchain',
                        default=None,
                        nargs="+",
                        choices=get_toolchains(),
                        help='run given toolchain(s) only (default: all)')
    parser.add_argument('--board',
                        default=None,
                        nargs='+',
                        choices=get_boards(),
                        help='run given board(s) only (default: all)')
    parser.add_argument(
        '--out-prefix',
        default='build/_exhaust-runs',
        help='output directory prefix (default: build/_exhaust-runs)')
    parser.add_argument(
        '--build_type',
        default='generic',
        help=
        'Type of build that is performed (e.g. regression test, multiple options, etc.)'
    )
    parser.add_argument('--build', default=0, help='Build number')
    parser.add_argument('--parameters',
                        default=None,
                        help='Tool parameters json file')
    parser.add_argument('--seed',
                        default=None,
                        help='Seed to assign when running the tools')
    parser.add_argument('--run_config',
                        default=None,
                        help="Run configuration file in JSON format.")
    parser.add_argument('--fail', action='store_true', help='fail on error')
    parser.add_argument('--verbose',
                        action='store_true',
                        help='verbose output')
    parser.add_argument('--overwrite',
                        action='store_true',
                        help='deletes previous exhuast builds before running')
    parser.add_argument(
        '--only_required',
        action='store_true',
        help='runs only test/board/toolchain combinations that should pass')
    parser.add_argument(
        '--num-cpu',
        default=cpu_count(),
        type=int,
        choices=range(1, cpu_count()),
        help='Number of CPUs to use in parallel to run the tests')

    return parser.parse_args()
Exemple #3
0
def main():
    import argparse
    parser = argparse.ArgumentParser(
        description='Exhaustively try project-toolchain-board combinations')
    parser.add_argument('--project',
                        default=None,
                        nargs="+",
                        choices=get_projects(),
                        help='run given project(s) only (default: all)')
    parser.add_argument('--toolchain',
                        default=None,
                        nargs="+",
                        choices=get_toolchains(),
                        help='run given toolchain(s) only (default: all)')
    parser.add_argument('--board',
                        default=None,
                        nargs='+',
                        choices=get_boards(),
                        help='run given board(s) only (default: all)')
    parser.add_argument(
        '--out-prefix',
        default='build/_exhaust-runs',
        help='output directory prefix (default: build/_exhaust-runs)')
    parser.add_argument(
        '--build_type',
        default='generic',
        help=
        'Type of build that is performed (e.g. regression test, multiple options, etc.)'
    )
    parser.add_argument('--build', default=0, help='Build number')
    parser.add_argument('--parameters',
                        default=None,
                        help='Tool parameters json file')
    parser.add_argument('--seed',
                        default=None,
                        help='Seed to assign when running the tools')
    parser.add_argument('--run_config',
                        default=None,
                        help="Run configuration file in JSON format.")
    parser.add_argument('--fail', action='store_true', help='fail on error')
    parser.add_argument('--verbose',
                        action='store_true',
                        help='verbose output')
    parser.add_argument('--overwrite',
                        action='store_true',
                        help='deletes previous exhuast builds before running')

    args = parser.parse_args()

    if args.verbose:
        global logger
        logger = logging.getLogger('MyLogger')
        handler = logging.StreamHandler()
        formatter = logging.Formatter('%(levelname)s: %(message)s')
        handler.setFormatter(formatter)
        logger.addHandler(handler)
        logger.setLevel(logging.DEBUG)
    logger.debug("Parsing Arguments")

    tasks = Tasks(src_dir)

    assert args.run_config is None or args.run_config and not (args.project or
                                                               args.toolchain)

    args_dict = dict()
    seeds = list()
    if args.run_config:
        with open(args.run_config, 'r') as f:
            run_config = json.load(f)
            project = safe_get_dict_value(run_config, "project", None)
            toolchain = safe_get_dict_value(run_config, "toolchain", None)
            seeds = [
                int(i) for i in safe_get_dict_value(run_config, "seeds", [0])
            ]
            build_numbers = [
                int(i)
                for i in safe_get_dict_value(run_config, "build_number", [0])
            ]

            args_dict = {
                "project": project,
                "toolchain": toolchain,
                "board": args.board
            }

    else:
        args_dict = {
            "project": args.project,
            "toolchain": args.toolchain,
            "board": args.board
        }
        seeds = [int(args.seed)] if args.seed else [0]
        build_numbers = [int(args.build)] if args.build else [0]

    params_file = args.parameters
    params_strings = [None]
    if params_file:
        params_strings = []
        assert len(
            args.toolchain
        ) == 1, "A single toolchain can be selected when running multiple params."

        params_helper = ToolParametersHelper(args.toolchain[0], params_file)
        for params in params_helper.get_all_params_combinations():
            params_strings.append(" ".join(params))

    logger.debug("Getting Tasks")
    task_list = tasks.get_tasks(args_dict, seeds, build_numbers,
                                params_strings)

    runner = Runner(task_list, args.verbose, args.out_prefix, root_dir,
                    args.build_type, build_numbers, args.overwrite)

    logger.debug("Running Projects")
    runner.run()

    logger.debug("Collecting Results")
    runner.collect_results()

    logger.debug("Printing Summary Table")
    result = print_summary_table(args.out_prefix, args.project, args.toolchain,
                                 args.board, args.build_type, args.build)

    if not result and args.fail:
        print("ERROR: some tests have failed.")
        exit(1)
Exemple #4
0
 def test_get_toolchains(self):
     ts = fpgaperf.get_toolchains()
     assert 'vpr' in ts
     assert 'arachne' in ts
     assert 'radiant-synpro' in ts