예제 #1
0
    def test_enabled_exists(self):
        # Create the args object which could contain any attribute
        args = type('', (), {})()
        args.from_step = 'HLS'
        args.to_step = 'HLS'
        args.backend = 'xilinx'
        args.disable_IP_caching = False
        args.IP_cache_location = '/tmp'

        parser = ArgParser()
        parser.check_flow_args(args)

        self.assertTrue(True)  # Just check no errors are thrown
예제 #2
0
    def test_enabled_not_exists(self, msg_error):
        # Create the args object which could contain any attribute
        args = type('', (), {})()
        args.from_step = 'HLS'
        args.to_step = 'HLS'
        args.backend = 'xilinx'
        args.disable_IP_caching = False
        args.IP_cache_location = '/this-path-should-not-exist'

        parser = ArgParser()
        parser.is_default = MagicMock(return_value=False)
        parser.check_flow_args(args)

        parser.is_default.assert_called_with('IP_cache_location', args.backend)
        msg_error.assert_called_with(ANY)
예제 #3
0
    def test_enabled_default_exists(self):
        # Create the args object which could contain any attribute
        args = type('', (), {})()
        args.from_step = 'HLS'
        args.to_step = 'HLS'
        args.backend = 'xilinx'
        args.disable_IP_caching = False
        args.IP_cache_location = '/tmp/ait-test-folder'

        # Check PRE conditions
        if (not os.path.exists(args.IP_cache_location)):
            os.makedirs(args.IP_cache_location)

        parser = ArgParser()
        parser.is_default = MagicMock(return_value=True)
        parser.check_flow_args(args)

        # Check POST conditions
        self.assertTrue(os.path.exists(args.IP_cache_location))
        os.rmdir(args.IP_cache_location)
예제 #4
0
def ait_main():
    global args

    start_time = time.time()

    args = None

    parser = ArgParser()

    args = parser.parse_args()
    msg.setProjectName(args.name)
    msg.setPrintTime(args.verbose_info)
    msg.setVerbose(args.verbose)

    msg.info('Using ' + args.backend + ' backend')

    board = json.load(open(ait_path + '/backend/' + args.backend + '/board/' +
                           args.board + '/basic_info.json'),
                      object_hook=JSONObject)

    # Check vendor-related board arguments
    parser.vendor_parser[args.backend].check_board_args(args, board)

    if not int(board.frequency.min) <= args.clock <= int(board.frequency.max):
        msg.error('Clock frequency requested (' + str(args.clock) +
                  'MHz) is not within the board range (' +
                  str(board.frequency.min) + '-' + str(board.frequency.max) +
                  'MHz)')

    if (args.slr_slices is not None or args.floorplanning_constr
            is not None) and not hasattr(board.arch, 'slr'):
        msg.error(
            'Use of placement constraints is only available for boards with SLRs'
        )

    project_path = os.path.normpath(
        os.path.realpath(args.dir + '/' + args.name + '_ait'))
    project_backend_path = os.path.normpath(project_path + '/' + args.backend)

    # Add backend to python import path
    sys.path.insert(0, ait_path + '/backend/' + args.backend + '/scripts')

    # Check for backend support for the given board
    if not args.disable_board_support_check:
        check_board_support(board)

    sys.stdout = Logger(project_path)
    sys.stdout.log.write(
        os.path.basename(sys.argv[0]) + ' ' + ' '.join(sys.argv[1:]) + '\n\n')

    get_accelerators(project_path)

    parser.check_hardware_runtime_args(args, max(2, num_instances))

    project_args = {
        'path':
        os.path.normpath(
            os.path.realpath(args.dir) + '/' + args.name + '_ait'),
        'num_accs':
        num_accs,
        'num_instances':
        num_instances,
        'num_acc_creators':
        num_acc_creators,
        'accs':
        accs,
        'board':
        board,
        'args':
        args
    }

    for step in generation_steps[args.backend]:
        if generation_steps[args.backend].index(
                args.from_step) <= generation_steps[args.backend].index(
                    step) <= generation_steps[args.backend].index(
                        args.to_step):
            generation_step_package = os.path.basename(
                os.path.dirname(
                    glob.glob(ait_path + '/backend/' + args.backend +
                              '/scripts/*-' + step + '/')[0]))
            generation_step_module = '%s.%s' % (generation_step_package, step)
            module = importlib.import_module(generation_step_module)
            step_func = getattr(module, 'STEP_FUNC')
            msg.info('Starting \'' + step + '\' step')
            step_start_time = time.time()
            project_args['start_time'] = step_start_time
            step_func(project_args)
            msg.success(
                'Step \'' + step + '\' finished. ' +
                secondsToHumanReadable(int(time.time() - step_start_time)) +
                ' elapsed')
        else:
            msg.warning('Step \'' + step + '\' is disabled')

    msg.success('Accelerator automatic integration finished. ' +
                secondsToHumanReadable(int(time.time() - start_time)) +
                ' elapsed')