def _getTaskPriority_LowResFirst(self, Ti): OFFSET = 10 Ti_scheduled_dispatch_time = Ti.get_scheduledDispatchTime() Ti_gop_ix = Ti.get_frameIXinGOP() target_vid_resolution = Ti.get_frame_h() * Ti.get_frame_w() # stratergy : pri = (MAX_TASK_PRI - (w*h) + frame_ix_pri + (arr_time * offset)) priority = SimParams.MAX_TASK_PRIORITY - ( (target_vid_resolution - MPEG2FrameTask.calc_FramePriorityInsideGOP(Ti_gop_ix)) + (Ti_scheduled_dispatch_time * OFFSET)) return priority
def _get_pseudo_task(self, ix, pri, node_id, strm_specs, tid=0): pseudo_task = None if (SimParams.TASK_MODEL == TaskModel.TASK_MODEL_MHEG2_FRAME_ET_LEVEL): pseudo_task = MPEG2FrameTask(self.env, tid, frame_h = strm_specs['frame_h'], frame_w = strm_specs['frame_w'], frame_rate = strm_specs['fps'], frame_type = strm_specs['gop_struct'][ix], frame_ix_in_gop = ix, gop_struct = strm_specs['gop_struct'], video_stream_id = strm_specs['vid_strm_id'], wf_id = strm_specs['wf_id']) pseudo_task.set_processingCore(node_id) pseudo_task.set_priority(pri) pseudo_task.set_worstCaseComputationCost(self._get_wcc_of_frame(ix, strm_specs)) pseudo_task.set_avgCaseComputationCost(self._get_avgcc_of_frame(ix, strm_specs)) pseudo_task.set_period(pseudo_task.get_end_to_end_deadline()) elif (SimParams.TASKSET_MODEL in [TaskModel.TASK_MODEL_HEVC_FRAME_LEVEL,TaskModel.TASK_MODEL_HEVC_TILE_LEVEL] ): pseudo_task = HEVCFrameTask(env = self.env, id = tid, frame_type = strm_specs['gop_struct'][ix], frame_ix_in_gop = ix, gop_struct = strm_specs['gop_struct'], video_stream_id = strm_specs['vid_strm_id'], wf_id = strm_specs['wf_id'], frame_h = strm_specs['frame_h'], frame_w = strm_specs['frame_w'], priority = pri, num_slices_per_frame = -1, num_tiles_per_frame = -1, interleaved_slice_types = ["Is", "Bs", "Bs" , "Ps"], num_ctu_per_slice=-1, adaptiveGoP_Obj=None, load_data_from_file = False, construct_partitions = False, hevc_cc=0.0 ) pseudo_task.set_processingCore(node_id) pseudo_task.set_priority(pri) pseudo_task.set_worstCaseComputationCost(self._get_wcc_of_frame(ix, strm_specs)) pseudo_task.set_avgCaseComputationCost(self._get_avgcc_of_frame(ix, strm_specs)) pseudo_task.set_period(pseudo_task.get_end_to_end_deadline()) return pseudo_task
def get_ccr_range(enable_print=True): result_data = [] frame_h = res_list[0][0] frame_w = res_list[0][1] for cpu_exec_speed_ratio in [0.1]: #for cpu_exec_speed_ratio in np.arange(cpu_exec_rat_min,cpu_exec_rat_max,(cpu_exec_rat_max-cpu_exec_rat_min)/2): for noc_period in np.arange(noc_period_min, noc_period_max, (noc_period_max - noc_period_min) / 10): # computation cost (iframe_cc, pframe_cc, bframe_cc) = MPEG2FrameTask.getStaticComputationCost( frame_h, frame_w, cpu_exec_speed_ratio) mean_computation_cost = float(iframe_cc + pframe_cc + bframe_cc) / 3.0 # communication cost max_hop_count = (SimParams.NOC_W - 1) + (SimParams.NOC_H - 1) payload = ((frame_h * frame_w) * 16) / 8 arb_cost = noc_period * 7 noc_flow_cc = NoCFlow.getCommunicationCost(payload, max_hop_count, noc_period, arb_cost) # CCR : communication to computation ratio ccr = noc_flow_cc / mean_computation_cost # CCS : communication + computation (summation) ccs = noc_flow_cc + mean_computation_cost entry = { 'cpu_exec_speed_ratio': cpu_exec_speed_ratio, 'noc_period': noc_period, 'mean_computation_cost': mean_computation_cost, 'noc_flow_cc': noc_flow_cc, 'ccr': ccr, 'ccs': ccs, } result_data.append(entry) # print table of results if (enable_print == True): _report_ccr(result_data) return result_data
def _get_frame_pri(self, gopseq, fr_ix, strm_specs): if (SimParams.TASK_MODEL == TaskModel.TASK_MODEL_MHEG2_FRAME_ET_LEVEL): return MPEG2FrameTask.calc_FramePriorityInsideGOP(fr_ix) elif (SimParams.TASK_MODEL in [ TaskModel.TASK_MODEL_HEVC_FRAME_LEVEL, TaskModel.TASK_MODEL_HEVC_TILE_LEVEL ]): if "gop_tasks" in strm_specs: adaptivegop_obj = strm_specs["gop_tasks"][ 0].get_adaptiveGoP_Obj() else: adaptivegop_obj = None return HEVCFrameTask.calc_FramePriorityInsideGOP(fr_ix, adaptivegop_obj, gopseq=gopseq)
def generateMPEGGoP(self): task_start_id = self.task_start_id gop_id = self.gop_id unique_gop_start_id = gop_id frame_h = self.vid_res[0] frame_w = self.vid_res[1] priority_range = range(1, 100) # dummy strm_resolution = frame_h * frame_w gop_instance_frames = [] # reset unique_gop_id = gop_id self.gop_seq = SimParams.GOP_STRUCTURE # get num edges + nodes self.num_edges = (8 * 2) + (3 * 1) self.num_nodes = 12 # construct task ids gop_task_ids = range(task_start_id, task_start_id + len(self.gop_seq)) for fix, each_frame in enumerate(SimParams.GOP_STRUCTURE): frame_task = MPEG2FrameTask(env = self.env, \ id = gop_task_ids[fix], \ frame_type = str(each_frame), \ frame_ix_in_gop = fix, \ unique_gop_id = unique_gop_id, \ gop_id = gop_id, \ video_stream_id = 0, \ wf_id = 0, \ frame_h=frame_h, \ frame_w=frame_w, \ frame_rate=SimParams.FRAME_RATE, \ priority = priority_range[fix]) gop_instance_frames.append(frame_task) # save the generated frames self.mpeg_frames = gop_instance_frames # calculate some gop level stats self.calculateStats()
def _get_pseudo_task(self, ix, pri, node_id, strm_specs, tid=0): pseudo_task = MPEG2FrameTask(self.env, tid, frame_h = strm_specs['frame_h'], frame_w = strm_specs['frame_w'], \ frame_rate = strm_specs['fps'], \ frame_type = strm_specs['gop_struct'][ix], \ frame_ix_in_gop = ix, \ gop_struct = strm_specs['gop_struct'], \ video_stream_id = strm_specs['vid_strm_id'], \ wf_id = strm_specs['wf_id']) pseudo_task.set_processingCore(node_id) pseudo_task.set_priority(pri) pseudo_task.set_worstCaseComputationCost( self._get_wcc_of_frame(ix, strm_specs)) pseudo_task.set_avgCaseComputationCost( self._get_avgcc_of_frame(ix, strm_specs)) pseudo_task.set_period(pseudo_task.get_end_to_end_deadline()) return pseudo_task
def _gen_ccr(result_ccr_list, ccs_range, ccr_range, param_res_list): #cpu_exec_speed_ratio = random.choice(np.arange(cpu_exec_rat_min,cpu_exec_rat_max,(cpu_exec_rat_max-cpu_exec_rat_min)/10000)) #noc_period = random.choice(np.arange(noc_period_min,noc_period_max,(noc_period_max-noc_period_min)/10000)) # global_noc_period_list.append(noc_period) # while(noc_period in global_noc_period_list): # global_noc_period_list.append(noc_period) # noc_period = random.choice(np.arange(noc_period_min,noc_period_max,(noc_period_max-noc_period_min)/1000000)) cpu_exec_speed_ratio = 0.8 noc_period = random.uniform(noc_period_min, noc_period_max) list_mean_computation_cost = [] list_sum_computation_cost_all_tasks = [] list_mean_computation_cost_all_tasks = [] list_noc_flow_cc_all_edges = [] list_noc_flow_cc = [] list_ccr = [] list_ccs = [] for each_res in param_res_list: frame_h = each_res[0] frame_w = each_res[1] # computation cost (iframe_cc, pframe_cc, bframe_cc) = MPEG2FrameTask.getStaticComputationCost( frame_h, frame_w, cpu_exec_speed_ratio) mean_computation_cost = float(iframe_cc + pframe_cc + bframe_cc) / 3.0 sum_computation_cost_all_tasks = (iframe_cc * 1.0) + ( pframe_cc * 3.0) + (bframe_cc * 8.0) mean_computation_cost_all_tasks = ( sum_computation_cost_all_tasks) / 12.0 # communication cost noc_w = np.sqrt(len(param_res_list) - 3) max_hop_count = (noc_w) + (noc_w) payload = ((frame_h * frame_w) * 16) / 8 arb_cost = noc_period * 7 noc_flow_cc = NoCFlow.getCommunicationCost(payload, max_hop_count, noc_period, arb_cost) num_edges = 19 noc_flow_cc_all_edges = (noc_flow_cc * num_edges) # CCR : communication to computation #ccr = noc_flow_cc/mean_computation_cost ccr = (noc_flow_cc_all_edges / sum_computation_cost_all_tasks) # CCS : communication + computation (summation) #ccs = noc_flow_cc + mean_computation_cost ccs = (noc_flow_cc_all_edges + sum_computation_cost_all_tasks) list_mean_computation_cost.append(mean_computation_cost) list_noc_flow_cc.append(noc_flow_cc) list_sum_computation_cost_all_tasks.append( sum_computation_cost_all_tasks) list_mean_computation_cost_all_tasks.append( mean_computation_cost_all_tasks) list_noc_flow_cc_all_edges.append(noc_flow_cc_all_edges) list_ccr.append(ccr) list_ccs.append(ccs) if (((np.mean(list_ccs) >= float(ccs_range[0])) and (np.mean(list_ccs) <= float(ccs_range[1]))) and (round(np.mean(list_ccr), 3) not in result_ccr_list) and (round(np.mean(list_ccr), 3) in ccr_range)): entry = { 'cpu_exec_speed_ratio': cpu_exec_speed_ratio, 'noc_period': noc_period, 'mean_computation_cost': np.mean(list_mean_computation_cost), 'noc_flow_cc': np.mean(list_noc_flow_cc), 'ccr': np.mean(list_ccr), 'ccs': np.mean(list_ccs), } return entry else: return None
def get_specific_ccr(cpu_exec_speed_ratio, noc_period): list_ipb_frame_cost = [] list_mean_computation_cost = [] list_sum_computation_cost_all_tasks = [] list_mean_computation_cost_all_tasks = [] list_noc_flow_cc_all_edges = [] list_noc_flow_cc = [] list_ccr = [] list_ccs = [] for each_res in res_list: frame_h = each_res[0] frame_w = each_res[1] # computation cost (iframe_cc, pframe_cc, bframe_cc) = MPEG2FrameTask.getStaticComputationCost( frame_h, frame_w, cpu_exec_speed_ratio) mean_computation_cost = float(iframe_cc + pframe_cc + bframe_cc) / 3.0 sum_computation_cost_all_tasks = (iframe_cc * 1.0) + ( pframe_cc * 3.0) + (bframe_cc * 8.0) mean_computation_cost_all_tasks = (iframe_cc) + (pframe_cc) + ( bframe_cc) # communication cost max_hop_count = (SimParams.NOC_W - 1) + (SimParams.NOC_H - 1) payload = ((frame_h * frame_w) * 16) / 8 arb_cost = noc_period * 7 noc_flow_cc = NoCFlow.getCommunicationCost(payload, max_hop_count, noc_period, arb_cost) num_edges = 19 noc_flow_cc_all_edges = (noc_flow_cc * num_edges) # CCR : communication to computation #ccr = noc_flow_cc/mean_computation_cost ccr = (noc_flow_cc_all_edges / sum_computation_cost_all_tasks) # CCS : communication + computation (summation) #ccs = noc_flow_cc + mean_computation_cost ccs = (noc_flow_cc_all_edges + sum_computation_cost_all_tasks) list_mean_computation_cost.append(mean_computation_cost) list_noc_flow_cc.append(noc_flow_cc) list_sum_computation_cost_all_tasks.append( sum_computation_cost_all_tasks) list_mean_computation_cost_all_tasks.append( mean_computation_cost_all_tasks) list_noc_flow_cc_all_edges.append(noc_flow_cc_all_edges) list_ccr.append(ccr) list_ccs.append(ccs) list_ipb_frame_cost.append((iframe_cc, pframe_cc, bframe_cc)) # print list_ccr # print list_ccs entry = { 'cpu_exec_speed_ratio': cpu_exec_speed_ratio, 'noc_period': noc_period, 'mean_computation_cost': np.mean(list_mean_computation_cost), 'noc_flow_cc': np.mean(list_noc_flow_cc), 'sum_computation_cost_all_tasks': list_sum_computation_cost_all_tasks, 'mean_computation_cost_all_tasks': list_mean_computation_cost_all_tasks, 'noc_flow_cc_all_edges': list_noc_flow_cc_all_edges, 'list_ipb_frame_cost': list_ipb_frame_cost, 'list_ccr': list_ccr, 'list_ccs': list_ccs, 'mean_ccr': np.mean(list_ccr), 'mean_ccs': np.mean(list_ccs), 'ccr_v2': np.sum(list_noc_flow_cc_all_edges) / np.sum(list_mean_computation_cost_all_tasks), 'csr_v2': np.sum(list_noc_flow_cc_all_edges) + np.sum(list_mean_computation_cost_all_tasks) } pprint.pprint(entry)
def get_properties_fixed_ccs_fixed_ccr_range(ccs_range, ccr_range, enable_print=True): random.seed(1234) result_data = [] n = 0 count = 0 result_ccr_list = [] while (n < len(ccr_range)): #cpu_exec_speed_ratio = random.choice(np.arange(cpu_exec_rat_min,cpu_exec_rat_max,(cpu_exec_rat_max-cpu_exec_rat_min)/10000)) #noc_period = random.choice(np.arange(noc_period_min,noc_period_max,(noc_period_max-noc_period_min)/10000)) cpu_exec_speed_ratio = 0.8 noc_period = random.uniform(noc_period_min, noc_period_max) list_mean_computation_cost = [] list_sum_computation_cost_all_tasks = [] list_mean_computation_cost_all_tasks = [] list_noc_flow_cc_all_edges = [] list_noc_flow_cc = [] list_ccr = [] list_ccs = [] for each_res in res_list: frame_h = each_res[0] frame_w = each_res[1] # computation cost (iframe_cc, pframe_cc, bframe_cc) = MPEG2FrameTask.getStaticComputationCost( frame_h, frame_w, cpu_exec_speed_ratio) mean_computation_cost = float(iframe_cc + pframe_cc + bframe_cc) / 3.0 sum_computation_cost_all_tasks = (iframe_cc * 1.0) + ( pframe_cc * 3.0) + (bframe_cc * 8.0) mean_computation_cost_all_tasks = (iframe_cc) + (pframe_cc) + ( bframe_cc) # communication cost max_hop_count = (SimParams.NOC_W - 1) + (SimParams.NOC_H - 1) payload = ((frame_h * frame_w) * 16) / 8 arb_cost = noc_period * 7 noc_flow_cc = NoCFlow.getCommunicationCost(payload, max_hop_count, noc_period, arb_cost) num_edges = 19 noc_flow_cc_all_edges = (noc_flow_cc * num_edges) # CCR : communication to computation #ccr = noc_flow_cc/mean_computation_cost ccr = (noc_flow_cc_all_edges / sum_computation_cost_all_tasks) # CCS : communication + computation (summation) #ccs = noc_flow_cc + mean_computation_cost ccs = (noc_flow_cc_all_edges + sum_computation_cost_all_tasks) list_mean_computation_cost.append(mean_computation_cost) list_noc_flow_cc.append(noc_flow_cc) list_sum_computation_cost_all_tasks.append( sum_computation_cost_all_tasks) list_mean_computation_cost_all_tasks.append( mean_computation_cost_all_tasks) list_noc_flow_cc_all_edges.append(noc_flow_cc_all_edges) list_ccr.append(ccr) list_ccs.append(ccs) if (((np.mean(list_ccs) >= float(ccs_range[0])) and (np.mean(list_ccs) <= float(ccs_range[1]))) and (round(np.mean(list_ccr), 3) not in result_ccr_list) and (round(np.mean(list_ccr), 3) in ccr_range)): entry = { 'cpu_exec_speed_ratio': cpu_exec_speed_ratio, 'noc_period': noc_period, 'mean_computation_cost': np.mean(list_mean_computation_cost), 'noc_flow_cc': np.mean(list_noc_flow_cc), 'ccr': np.mean(list_ccr), 'ccs': np.mean(list_ccs), } result_data.append(entry) result_ccr_list.append(round(np.mean(list_ccr), 3)) n += 1 print n, np.mean(list_ccr) count += 1 # print table of results if (enable_print == True): # sort new_result_data = sorted(result_data, key=lambda k: k['ccr']) _report_ccr(new_result_data) ## write data file output fname = 'ccr_list_output_' + str(ccr_range[0]) + "_" + str( ccr_range[-1]) + ".js" _write_formatted_file(fname, new_result_data, "json") return result_data