def commit_generate( self ): self.force_result = SysUtils.ifthen( SysUtils.success( self.force_retcode ), "PASS", "FAIL" ) self.force_level = SummaryLevel.Any if SysUtils.failed( self.force_retcode ): self.force_level = SummaryLevel.Fail Msg.lout( self, "user" , "Performance Summary Item Commit Generate" ) if SysUtils.success( self.force_retcode ): self.instruction_counts( ) Msg.info( "Instructions: %d, Default: %d, Secondary: %d, Elapsed Time: %0.5f Seconds\n\n" % ( self.count, self.default, self.secondary, self.force_end - self.force_start )) return 1 return 0
def load_item_values(self, arg_item_dict): my_options = arg_item_dict.get(CtrlItmKeys.options, CtrlItmDefs.options) my_parent_vals = arg_item_dict.get(CtrlItmKeys.parent_vals, {}) Msg.lout(my_parent_vals, "dbg", "Parent Values from Control Item") Msg.lout(self.parent_data, "dbg", "Persistent Data") # Control File Location self.fctrl_dir = my_options.get( CtrlItmKeys.fdir, SysUtils.ifthen(self.parent_data.work_dir is None, CtrlItmDefs.fctrl_dir, self.parent_data.work_dir)) # Populated from control item options self.iterations = my_options.get(CtrlItmKeys.iterations, CtrlItmDefs.iterations) # Populated from control item options or parent self.exit_loop = my_options.get( CtrlItmKeys.exit_loop, my_parent_vals.get(CtrlItmKeys.exit_loop, CtrlItmDefs.exit_loop)) self.group = my_options.get( CtrlItmKeys.group, my_parent_vals.get(CtrlItmKeys.group, CtrlItmDefs.group)) self.min_instr = my_options.get( CtrlItmKeys.min_instr, my_parent_vals.get(CtrlItmKeys.min_instr, CtrlItmDefs.min_instr)) self.max_instr = my_options.get( CtrlItmKeys.max_instr, my_parent_vals.get(CtrlItmKeys.max_instr, CtrlItmDefs.max_instr)) self.num_cores = my_options.get( CtrlItmKeys.num_cores, my_parent_vals.get(CtrlItmKeys.num_cores, CtrlItmDefs.num_cores)) self.no_asm = my_options.get( CtrlItmKeys.no_asm, my_parent_vals.get(CtrlItmKeys.no_asm, CtrlItmDefs.no_asm)) self.no_sim = my_options.get( CtrlItmKeys.no_sim, my_parent_vals.get(CtrlItmKeys.no_sim, CtrlItmDefs.no_sim)) self.timeout = my_options.get( CtrlItmKeys.timeout, my_parent_vals.get(CtrlItmKeys.timeout, CtrlItmDefs.timeout))
def instruction_counts( self ): my_lines = None my_glog = "%s%s" % ( PathUtils.include_trailing_path_delimiter( self.work_dir ), self.force_log ) Msg.user("Path: %s" % my_glog) with open( my_glog, "r" ) as my_log: my_lines = my_log.readlines() Msg.dbg( "Line %d: %s" % ( len( my_lines ), my_lines[-1])) my_log.close() try: my_results = [ my_tmp for my_tmp in my_lines if re.search( ' Instructions Generated', my_tmp )] Msg.lout( my_results, "dbg" ) if not my_results: raise Exception( "Instruction Count Not Found in \"gen.log\"" ) # ok there are instruction counts located for my_line in my_results: my_line = my_line.strip() # find the instruction type (Total, Default, Secondary) my_lpos = my_line.find(']') my_rpos = my_line.find( "Instr" ) my_type = PerformanceInstructionType.instruction_type(( my_line[my_lpos + 1 : my_rpos - 1 ]).strip()) # get the count for this instruction type my_lpos = my_line.find( ':' ) my_count = int( my_line[my_lpos+2:].strip()) if my_type == PerformanceInstructionType.Total: self.count = my_count elif my_type == PerformanceInstructionType.Secondary: self.secondary = my_count elif my_type == PerformanceInstructionType.Default: self.default = my_count except ValueError: Msg.error_trace() Msg.err( "Unable to extract instruction count from %s" % ( int( my_lines[-1] ))) return 0
def process(self): # Msg.dbg( "FileController::process()" ) # Msg.dbg( "FileController Contents: \n\"" + str( self.fcontrol ) + "\n" ) try: # Msg.lout( my_options["work-dir"], MsgLevel.dbg, "Work Director Stack" ) # a control file may iterate through to completion according to the amount set in num_runs for my_ndx in range( self.ctrl_item.iterations ): # my_usr_lbl = Msg.set_label( "user", "FILE-ITERATION" ) # Msg.user( "Executing %d of %d Iterations, Control File: %s" % ( my_ndx + 1, self.ctrl_item.iterations, self.ctrl_item.file_path() )) # Msg.set_label( "user", my_usr_lbl ) try: my_item_ndx = 0 # each item in the control set exists as a dictionary for my_item_dict in self.fcontrol: try: my_item_ndx += 1 my_usr_lbl = Msg.set_label( "user", "CTRL-FILE" ) Msg.blank( "user" ) Msg.user( "Processing Line: %s" % (str( my_item_dict ))) my_ctrl_item = ControlItem() my_ctrl_item.parent_fctrl = self.parent_fctrl my_ctrl_item.fctrl_item = str( my_item_dict ) my_item_dict[CtrlItmKeys.parent_vals], my_parent_data = self.ctrl_item.values() Msg.lout( my_parent_data, "user", "Result Parent Data" ) Msg.lout( my_item_dict , "user", "Result Item Dictionary" ) Msg.set_label( "user", my_usr_lbl ) # Msg.user( "Processing Updated Line: %s" % (str( my_item_dict )), "CTRL-FILE" ) # Msg.user( str( my_parent_data.data() ), "CTRL-FILE" ) my_ctrl_item.load( my_item_dict, my_parent_data ) my_item_type = my_ctrl_item.item_type() my_controller = None if my_item_type == ControlItemType.TaskItem: # Msg.dbg( "\nControl Item is a Control Task ..." ) my_controller = TaskController() elif my_item_type == ControlItemType.FileItem: # Msg.dbg( "\nControl Item is a Control File ..." ) my_controller = FileController() else: raise Exception( "\"" + my_fctrl_name + "\": Unknown Item Type ...\nUnable to Process ... " ) # Whew! everything is set up and ready to rock and roll, let the dogs out # my_controller.load( my_ctrl_item ) # my_controller.process() if my_controller.load( my_ctrl_item ): my_controller.process() # my_controller.load( my_ctrl_item ) # my_controller.process() # Msg.dbg( "%s: Controller Creation Complete" % ( my_ctrl_item.fctrl_name )) except TypeError as arg_ex: Msg.err( str( arg_ex )) my_err_queue_item = SummaryErrorQueueItem( { "error" : "Item #%s Contains an Invalid Type" % ( str( my_item_ndx )) , "message": arg_ex , "path" : self.ctrl_item.file_path() , "type" : str( type( arg_ex )) } ) self.ctrl_item.summary().queue.enqueue( my_err_queue_item ) Msg.blank() except FileNotFoundError as arg_ex: Msg.err( str( arg_ex )) my_err_queue_item = SummaryErrorQueueItem( { "error" : arg_ex , "message": "Control File Not Found ..." , "path" : self.ctrl_item.file_path() , "type" : str( type( arg_ex )) } ) self.ctrl_item.summary().queue.enqueue( my_err_queue_item ) Msg.blank() except Exception as arg_ex: Msg.error_trace( str(arg_ex) ) Msg.err( str(arg_ex)) Msg.blank() finally: my_controller = None my_item_dict = None except Exception as arg_ex: Msg.error_trace( "[ERROR] - " + str(arg_ex) ) Msg.err( str(arg_ex)) finally: pass finally: pass # Msg.dbg() return True