Esempio n. 1
0
    def commit(self):

        my_gen_cnt = 0
        my_gen_ret = 0
        my_sim_cnt = 0
        my_sim_ret = 0
        my_tgt_name = ""

        if self.has_generate():
            #Msg.user( "if self.has_generate(): True" )
            my_gen_cnt = 1
            my_gen_ret = self.commit_generate()

        if self.has_simulate():

            #Msg.user( "if self.has_simulate(): True" )
            my_sim_cnt = 1
            my_sim_ret = self.commit_simulate()
            my_tgt_name = "%s%s" % (self.task_path,
                                    SysUtils.ifthen(bool(my_sim_ret), "PASS",
                                                    "FAIL"))
        else:
            my_tgt_name = "%s%s" % (self.task_path,
                                    SysUtils.ifthen(bool(my_gen_ret), "PASS",
                                                    "FAIL"))

        my_src_name = "%s%s" % (self.task_path, "STARTED")
        PathUtils.move(my_src_name, my_tgt_name)

        return (my_gen_cnt, my_gen_ret, my_sim_cnt, my_sim_ret)
Esempio n. 2
0
    def process_groups( self, arg_ofile ):

        my_total_count = 0
        my_total_elapsed = 0

        my_groups = self.groups.task_groups();


        # Msg.trace("PerformanceSummaryItem::process_groups")
        for my_group, my_items in my_groups.items():
            try:
                my_str = "\nBegin Group: %s\n" % ( my_group )
                arg_ofile.write( my_str )
                Msg.blank( "info" )
                Msg.info( my_str )

                my_grp_count, my_grp_elapsed = self.process_group_items( arg_ofile, my_items )

                my_total_count   += my_grp_count
                my_total_elapsed += my_grp_elapsed

                my_line =  "\nGroup Instructions: %3d\n" % ( my_grp_count )
                my_line += "Group Elapsed Time: %0.3f\n" % ( my_grp_elapsed )
                my_line += "Group Instructions per Second:  %0.3f\n"  % ( SysUtils.ifthen( bool( my_grp_elapsed ), my_grp_count / my_grp_elapsed, 0 ))
                my_line += "End Group: %s\n" % ( my_group )

                Msg.info( my_line )
                arg_ofile.write( my_line )

            except Exception as arg_ex:

                Msg.error_trace()
                Msg.err( "Unable to process, Group: %s, Reason: %s" % (  my_group, type( arg_ex )))

        return my_total_count, my_total_elapsed
Esempio n. 3
0
    def process_summary( self, sum_level = SummaryLevel.Fail ):

        my_file_name = "%sperformance_summary.log" % ( PathUtils().include_trailing_path_delimiter( self.summary_dir ))
        Msg.dbg( "Master Log File: %s" % ( my_file_name ))
        my_utcdt = DateTime.UTCNow()
        my_ofile = None
        try:
        # First try to open file
            with open( my_file_name, "w" ) as my_ofile:

                my_ofile.write( "Date: %s\n" % ( DateTime.DateAsStr( my_utcdt )))
                my_ofile.write( "Time: %s\n" % ( DateTime.TimeAsStr( my_utcdt )))

                self.process_errors( my_ofile )
                my_total_count, my_total_elapsed = self.process_groups( my_ofile )

                Msg.blank( "info" )
                my_line = "Total Instructions Generated: %3d\n" % ( my_total_count )
                my_line += "Total Elapsed Time:  %0.3f\n" % ( my_total_elapsed )
                my_line += "Overall Instructions per Second:  %0.3f\n" % ( SysUtils.ifthen( bool( my_total_elapsed ), my_total_count / my_total_elapsed, 0 ))

                Msg.info( my_line )
                my_ofile.write( my_line )

        except Exception as arg_ex:
            Msg.error_trace()
            Msg.err( "Error Processing Summary, " + str( arg_ex ) )

        finally:
            my_ofile.close()
Esempio n. 4
0
    def initialize_sim(self):

        # Msg.dbg( "ExecuteController::initialize_sim()")
        if not self.ctrl_item.no_sim:
            my_tmlog = "iss.railhouse"  #arg_testname.replace( ".py", ".log" )
            self.sim_log = "iss_sim.log"

            self.sim_cmd = "%s -T %s -C %s -i %d --exit_loop=%d" % (
                self.ctrl_item.parent_data.iss_path, my_tmlog,
                self.ctrl_item.num_cores, self.ctrl_item.max_instr,
                self.ctrl_item.exit_loop)

            if not self.ctrl_item.iss is None and type(
                    self.ctrl_item.iss) is dict:
                for my_key in self.ctrl_item.iss.keys():
                    if not my_key == CtrlItmKeys.iss_path:
                        Msg.user("sim_cmd: %s, key: %s " %
                                 (str(self.sim_cmd), str(my_key)))
                        self.sim_cmd += " %s %s" % (
                            str(my_key),
                            SysUtils.ifthen(
                                self.ctrl_item.iss[my_key] is None, "",
                                str(self.ctrl_item.iss[my_key])))

            self.sim_cmd += "%s%s"  #
Esempio n. 5
0
    def report( self ):

        if self.default    is None: self.default    = 0
        if self.secondary is None: self.secondary = 0
        if self.total     is None: self.total     = 0

        Msg.info( "Task Id: %s, Task Index: %d" % ( self.task_id, self.task_index ))
        my_msg = "Process Log Contains "
        if self.detail_flags & SummaryDetail.AnyDetail   == SummaryDetail.Nothing    : my_msg = "Process No Found or is Empty"
        else:
            if self.detail_flags & SummaryDetail.ForceCmd    == SummaryDetail.ForceCmd   : my_msg += "ForceCommand, "
            if self.detail_flags & SummaryDetail.ForceResult == SummaryDetail.ForceResult: my_msg += "ForceResult, "
            if self.detail_flags & SummaryDetail.IssCmd      == SummaryDetail.IssCmd     : my_msg += "IssCommand, "
            if self.detail_flags & SummaryDetail.IssResult   == SummaryDetail.IssResult  : my_msg += "IssResult, "
            my_msg = my_msg[:-2]

        # Msg.user( my_msg )

        # Msg.info( "Originating Control File: %s"  % ( self.parent_fctrl ))
        # Msg.info( "Control File Item: %s"  % ( str(  self.fctrl_item )))
        # Msg.info( "F-Run Control File: %s" % ( self.frun_path ))
        Msg.dbg( "Force Ret Code: %s" % ( str( self.force_retcode )))
        Msg.info( "[%s], Generate Command: %s" % ( SysUtils.ifthen( SysUtils.success( self.force_retcode ), "SUCCESS", "FAILED" ), str( self.force_cmd )))
        Msg.info( "Instructions Generated - Default: %d, Secondary: %d, Total: %d" % ( self.default, self.secondary, self.total ))

        if self.iss_cmd is not None:
            if self.iss_success():
                Msg.info( "[SUCCESS], ISS Command: %s" % ( str( self.iss_cmd   )))
            else:
                Msg.info( "[FAILED], ISS Command: %s" % ( str( self.iss_cmd   )))
            #Msg.fout( self.iss_log, "user" )
        Msg.blank()
Esempio n. 6
0
    def exec_iss(self, arg_task_name):

        # Msg.dbg( "ExecuteController::exec_iss( %s )" % ( arg_task_name ) )
        # build rest of command for iss
        my_elf = "%s.Default.ELF" % (arg_task_name)
        # Msg.dbg( "Looking For: %s" % ( my_elf ))
        my_elf = SysUtils.ifthen(PathUtils.check_file(my_elf), " %s" % my_elf,
                                 "")
        # Msg.dbg( "Using ELF: %s" % ( my_elf ))

        my_elfns = "%s.Secondary.ELF" % (arg_task_name)
        # Msg.dbg( "Looking For: %s" % ( my_elfns ))
        my_elfns = SysUtils.ifthen(PathUtils.check_file(my_elfns),
                                   " %s" % my_elfns, "")
        my_cmd = self.sim_cmd % (my_elf, my_elfns)

        try:
            # execute the simulation
            Msg.info("ISSCommand = " + str({"iss-command": my_cmd}))
            my_log = self.sim_log
            my_elog = self.sim_log

            #my_ret_code = int( SysUtils.exec_cmd( my_cmd ) )
            my_result = SysUtils.exec_process(my_cmd, my_log, my_elog,
                                              self.ctrl_item.timeout, True)

            my_ret_code = int(my_result[0])
            my_std_out = str(my_result[1])
            my_std_err = str(my_result[2])
            my_start = str(my_result[3])
            my_end = str(my_result[4])

            Msg.info("ISSResult = " + str({
                "iss-retcode": my_ret_code,
                "iss-log": self.sim_log,
                "iss-stdout": my_std_out,
                "iss-stderr": my_std_err,
                "iss-start": my_start,
                "iss-end": my_end
            }))

        except Exception as arg_ex:
            Msg.error_trace("ISS Execute Failure")
            Msg.err("ISS did not properly execute, Reason: %s" % (str(arg_ex)))
            return False

        return True
Esempio n. 7
0
    def exec_gen(self, arg_task_file):

        # Msg.dbg( "ExecuteController::exec_gen( %s )" % ( arg_task_file ) )

        # NOTE: Do not change force_cmd may need to reuse!!
        # my_task_file = self.ctrl_item.file_path()

        # my_cmd = self.force_cmd % ( my_testfile, arg_testname.replace( ".py", ".gen.log" ))
        my_log = "gen.log"  # arg_testname.replace( ".py", ".gen.log" )
        my_elog = "gen.err"  # arg_testname.replace( ".py", ".gen.log" )

        my_cmd = self.force_cmd % (arg_task_file)  # , my_log )
        # Msg.dbg( "Generate Command Line: %s" % ( my_cmd ))

        # if self.ctrl_item.mode == "mock":
        #     Msg.info( "Mock Generate: " +  my_cmd )
        # else:
        Msg.info(
            "ForceCommand = " + str({
                "force-command": my_cmd,
                "force-log": my_log,
                "force-elog": my_elog,
                "max-instr": self.ctrl_item.max_instr,
                "min-instr": self.ctrl_item.min_instr
            }), True)
        Msg.flush()
        #     if self.ctrl_item.summary is not None:
        #         # update the current test with the generate cmd and the generate log file.
        #         self.ctrl_item.summary.set_gen_info( arg_task_name, arg_ndx, my_cmd, my_log )
        my_result = SysUtils.exec_process(my_cmd, my_log, my_elog,
                                          self.ctrl_item.timeout, True)

        # Msg.user( str( my_result[0] ) + ", type: " + str( type( my_result[0] )))
        my_ret_code = int(my_result[0])
        my_std_out = str(my_result[1])
        my_std_err = str(my_result[2])
        my_start = str(my_result[3])
        my_end = str(my_result[4])

        my_time_elapsed = SysUtils.ifthen(my_result[3] is not None,
                                          float(my_result[3]), 0.0)

        Msg.info("ForceResult = " + str({
            "force-retcode": my_ret_code,
            "force-stdout": my_std_out,
            "force-stderr": my_std_err,
            "force-start": my_start,
            "force-end": my_end
        }))

        return SysUtils.success(my_result[0])
Esempio n. 8
0
    def initialize_gen(self):

        # Msg.dbg( "ExecuteController::initialize_gen()")

        my_cmd = self.ctrl_item.parent_data.force_cmd

        # Msg.user( "ControlItem.no-asm: %s" %  ( str( self.ctrl_item.no_asm )) )
        # Msg.dbg( "ControlItem.max_instr: %s" %  ( str( self.ctrl_item.max_instr )) )

        my_cmd += " -t %s" + SysUtils.ifthen(
            self.ctrl_item.no_asm == False, "",
            " --noasm") + " --max-instr %d" % self.ctrl_item.max_instr

        # Msg.dbg( "my_cmd: %s" %  ( str( my_cmd )) )

        if isinstance(self.ctrl_item.generator, dict):
            for my_key in self.ctrl_item.generator.keys():
                my_cmd += " %s %s " % (
                    str(my_key),
                    SysUtils.ifthen(self.ctrl_item.generator[my_key] is None,
                                    "", str(self.ctrl_item.generator[my_key])))

        self.force_cmd = my_cmd.strip()
Esempio n. 9
0
    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
Esempio n. 10
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))