Example #1
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()
Example #2
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)
def generate_index_html(index_template: jinja2.Template,
                        data_template: jinja2.Template,
                        results: List[ProjectResults]):
    print('Generating index page...')

    cur_dir = os.path.dirname(os.path.abspath(__file__))
    root_dir = os.path.join(cur_dir, '..')
    tasks = Tasks(root_dir)
    combinations = sorted(tasks.get_all_combinations(),
                          key=lambda tup: (tup[3], tup[1], tup[2]))

    devices = dict()
    projects = set()
    device_data = dict()
    toolchains_data = dict()

    all_boards = get_boards()

    for _, project, toolchain, board in combinations:
        if "fasm2bels" in toolchain:
            continue

        board = all_boards[board]
        device = f"{board['family']}-{board['device']}"
        device = device.upper()

        if device not in devices:
            devices[device] = dict()

        device_dict = devices[device]
        if project not in device_dict:
            device_dict[project] = dict(all_failed=True)

        proj_dict = device_dict[project]

        proj_dict[toolchain] = "skip"

        if device not in toolchains_data:
            toolchains_data[device] = set()

        toolchains_data[device].add(toolchain)

        projects.add(project)

    for project_results in results:
        entries = project_results.entries
        project = project_results.project_name

        for device, toolchains in entries.items():
            all_failed = True
            for toolchain in toolchains.keys():
                if "fasm2bels" in toolchain:
                    continue

                status = entries[device][toolchain][0].status
                devices[device][project][toolchain] = status

                all_failed &= status != "succeeded"

            devices[device][project]["all_failed"] = all_failed

        device_data[project] = generate_device_data(project_results)

    # Remove project entry if all tests are skipped
    del_proj = set()
    for device, prjs in devices.items():
        for project, toolchains in prjs.items():
            if all([
                    v == "skip" or k == "all_failed"
                    for k, v in toolchains.items()
            ]):
                del_proj.add((device, project))

    for d, p in del_proj:
        del devices[d][p]

    for device, tool_list in toolchains_data.items():
        toolchains_data[device] = sorted(list(tool_list))

    devices_list = [k for k, v in devices.items() if v]

    index_page = index_template.render(devices=devices,
                                       devices_list=sorted(devices_list),
                                       device_data=device_data,
                                       toolchains=toolchains_data,
                                       projects=sorted(projects))

    data_page = data_template.render(devices_data=device_data)

    return index_page, data_page
Example #4
0
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from fpgaperf import get_boards

import subprocess
import sys

if len(sys.argv) < 3:
    print("Usage {} <tool> <board>".format(sys.argv[0]))
    sys.exit(1)

tool = sys.argv[1]
board = get_boards()[sys.argv[2]]

symbiflow = ["vpr", "vpr-fasm2bels"]
vivado = ["vivado", "yosys-vivado", "yosys-vivado-uhdm"]
nextpnr = [
    "nextpnr-ice40", "nextpnr-nexus", "nextpnr-xilinx",
    "nextpnr-xilinx-fasm2bels"
]
interchange = ["nextpnr-fpga-interchange"]
quicklogic = ["quicklogic"]

toolchain = ""
install = ""
if tool in symbiflow:
    toolchain = "symbiflow"
    board_device = board["device"] if board["device"] != "a35t" else "a50t"