Example #1
0
    def _apply_deadline_cst(self, mapping):
        csts = []
        PE.init_apps_pe_by_mapping(self.app_list, mapping, self.pe_list)
        for idx, app in enumerate(self.app_list):
            if config.app_to_cst_dict[idx] == 'Deadline':
                csts.append(Deadline(self.app_list, app, self.pe_list))

        # if there is deadline constraint
        for idx, cst in enumerate(csts):
            penalty = cst.constraint_function(mapping)[0]
            if penalty != 0:
                self._one_bit_flip_local_optimization(mapping, penalty, cst)
                return False

        return True
Example #2
0
 def _apply_cpu_util_cst(self, mapping):
     if config.CPU_UTILIZATION != 100:
         PE.init_apps_pe_by_mapping(self.app_list, mapping, self.pe_list)
         cpu_util = CPU_utilization(self.app_list, None, self.pe_list)
         while cpu_util.constraint_function(mapping)[0] != 0:  # (penalty, util)
             for idx in range(len(mapping)):
                 l = self.layer_list[idx]
                 if not l.is_start_node and not l.is_end_node and l.pe.type == PEType.CPU:
                     best = float("inf")
                     best_pe_idx = None
                     for pe in self.pe_list:
                         target = l.time_list[pe.get_idx()]
                         if target < best:
                             best = target
                             best_pe_idx = pe.get_idx()
                     mapping[idx] = best_pe_idx
Example #3
0
    def calculate_fitness(self, mapping):
        PE.init_apps_pe_by_mapping(self.app_list, mapping, self.pe_list)

        objs = []
        for obj in self.objs:
            obj_temp = obj.objective_function(mapping)
            objs.append(obj_temp[0])

        for idx, cst in enumerate(self.csts):
            if cst is not None and isinstance(cst, Deadline):
                cst_temp = cst.constraint_function(mapping)
                objs[idx] += cst_temp[0]
            elif cst is not None:
                cst_temp = cst.constraint_function(mapping)
                objs = [v + cst_temp[0] for v in objs]

        return tuple(objs)
Example #4
0
    def _move_large2small(self, mapping):
        large = -float("inf")
        small = float("inf")
        large_pe = None
        small_pe = None
        PE.init_apps_pe_by_mapping(self.app_list, mapping, self.pe_list)
        for idx in range(0, self.num_pe):
            if self.cur_map_stat_per_pe[self.pe_list[idx].name] > large:
                large = self.cur_map_stat_per_pe[self.pe_list[idx].name]
                large_pe = self.pe_list[idx]
            if self.cur_map_stat_per_pe[self.pe_list[idx].name] < small:
                small = self.cur_map_stat_per_pe[self.pe_list[idx].name]
                small_pe = self.pe_list[idx]

        for idx in range(0, self.num_layer):
            if mapping[idx] == large_pe.get_idx():
                mapping[idx] = small_pe.get_idx()
                self.cur_map_stat_per_pe[large_pe.name] -= self.layer_list[idx].time_list[large_pe.get_idx()]
                self.cur_map_stat_per_pe[small_pe.name] += self.layer_list[idx].time_list[small_pe.get_idx()]
                break