Ejemplo n.º 1
0
    def commit(self):

        my_gen_cnt = 0
        my_gen_ret = 0
        my_sim_cnt = 0
        my_sim_ret = 0
        my_rtl_cnt = 0
        my_rtl_ret = 0
        my_trace_cmp_ret = 0
        my_trace_cmp_cnt = 0
        my_tgt_name = ""
        self.passed = True

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

        if self.has_simulate():
            #Msg.user( "if self.has_simulate(): True" )
            my_sim_cnt = 1
            my_sim_ret = self.commit_simulate()
            self.passed = self.passed and bool(my_sim_ret)

        if self.has_rtl():
            #Msg.user( "if self.has_rtl(): True" )
            my_rtl_cnt = 1
            my_rtl_ret = self.commit_rtl()
            self.passed = self.passed and bool(my_rtl_ret)

        # Msg.user( "SummaryItem::commit - [20]", "GOT HERE" )
        if self.has_trace_cmp():
            # Msg.user( "SummaryItem::commit - [21]", "GOT HERE"  )
            my_trace_cmp_cnt = 1
            # Msg.user( "SummaryItem::commit - [22]", "GOT HERE"  )
            my_trace_cmp_ret = self.commit_trace_cmp()
            self.passed = self.passed and bool(my_trace_cmp_ret)

        # Msg.user( "SummaryItem::commit - [24]", "GOT HERE"  )
        my_src_name = "%s%s" % (self.task_path, "STARTED")
        my_tgt_name = "%s%s" % (self.task_path,
                                SysUtils.ifthen(
                                    self.passed, "PASS",
                                    SysUtils.ifthen(self.signal_id is None,
                                                    "FAIL", "INCOMPLETE")))

        PathUtils.move(my_src_name, my_tgt_name)

        if not self.passed:
            self.summary.do_on_fail(self)

        return (my_gen_cnt, my_gen_ret, my_sim_cnt, my_sim_ret, my_rtl_cnt,
                my_rtl_ret, my_trace_cmp_cnt, my_trace_cmp_ret)
Ejemplo n.º 2
0
    def commit_trace_cmp( self ):

        # Msg.dbg( "RegressionSummaryItem::commit_generate" )
        self.trace_cmp_result = SysUtils.ifthen( SysUtils.success( self.trace_cmp_retcode ), "PASS", SysUtils.ifthen( self.signal_id is None, "FAIL", "INCOMPLETE" ) )
        self.trace_cmp_level = SummaryLevel.Any

        if SysUtils.failed( self.trace_cmp_retcode ):
            self.trace_cmp_level = SummaryLevel.Fail
            Msg.user( "self.trace_cmp_retcode = %s" % ( str( self.trace_cmp_retcode )) )

        Msg.user( "self.trace_cmp_level = %s" % ( str( SummaryLevel.Fail)) )
        return SysUtils.ifthen( SysUtils.success( self.trace_cmp_retcode ), 1 , 0 )
Ejemplo n.º 3
0
    def load(self, arg_ctrl_item):
        super().load(arg_ctrl_item)

        # Msg.dbg("ForceProcessor::load()")
        my_cmd = self.ctrl_item.generator['path']

        my_cmd += " -t %s" + " --max-instr %d" % self.ctrl_item.max_instr
        my_cmd += " --num-chips %d --num-cores %d --num-threads %d" % (self.ctrl_item.num_chips, self.ctrl_item.num_cores, self.ctrl_item.num_threads)
        my_cmd += SysUtils.ifthen(self.ctrl_item.seed is None , "", (" -s %s" % (self.ctrl_item.seed)))
        # Msg.dbg("my_cmd: %s" %  (str(my_cmd)))

        if isinstance(self.ctrl_item.generator, dict):
            for my_key in self.ctrl_item.generator.keys():
                if my_key not in ['path']:
                    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()
    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()
Ejemplo n.º 5
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):
            Msg.info(
                "Instructions: %d, Default: %d, Secondary: %d, "
                "Elapsed Time: %0.5f Seconds\n\n"
                % (
                    self.total,
                    self.default,
                    self.secondary,
                    self.force_end - self.force_start,
                )
            )
            return 1

        return 0
Ejemplo n.º 6
0
 def HMS(cls, arg_utcdt=None):
     my_utcdt = SysUtils.ifthen(arg_utcdt is None, datetime.utcnow(),
                                arg_utcdt)
     return "%0.2d%0.2d%0.2d" % (
         my_utcdt.hour,
         my_utcdt.minute,
         my_utcdt.second,
     )
Ejemplo n.º 7
0
 def YMD(cls, arg_utcdt=None):
     my_utcdt = SysUtils.ifthen(arg_utcdt is None, datetime.utcnow(),
                                arg_utcdt)
     return "%0.4d%0.2d%0.2d" % (
         my_utcdt.year,
         my_utcdt.month,
         my_utcdt.day,
     )
Ejemplo n.º 8
0
 def YMD_HMS(cls, arg_utcdt=None):
     my_utcdt = SysUtils.ifthen(arg_utcdt is None, datetime.utcnow(),
                                arg_utcdt)
     return "%0.4d%0.2d%0.2d-%0.2d%0.2d%0.2d" % (
         my_utcdt.year,
         my_utcdt.month,
         my_utcdt.day,
         my_utcdt.hour,
         my_utcdt.minute,
         my_utcdt.second,
     )
Ejemplo n.º 9
0
    def commit_simulate( self ):

        try:
            # check the return code for error
            if SysUtils.success( self.iss_retcode ):
                # Check to see for instruction overrun
                if int( self.instr_count ) < self.max_instr:
                    if int( self.instr_count ) >= self.min_instr:
                        self.iss_result = "PASS"
                        self.iss_level  = SummaryLevel.Any
                        return 1

            self.iss_result = SysUtils.ifthen( self.signal_id is None, "FAIL", "INCOMPLETE" )
            self.iss_level  = SummaryLevel.Fail
            return 0
        finally:
            pass
Ejemplo n.º 10
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
Ejemplo n.º 11
0
    def __init__(self, arg_options):

        # the HiThread has two states state 1 has no thread loop thus there is
        # no need for control to be halted to allow other thread processes to
        # continue, State 2 executes a loop until the shutdown sequence is
        # invoked which determines whether or not the thread a) has more work
        # to do, or b) will wait for another process to finished. A Thread will
        # remain in the shutdown sequence until the terminate flag is set. When
        # the terminate flag is set then the thread will execute the terminate
        # sequence.
        my_target = SysUtils.ifthen(arg_options.get("noloop", False),
                                    self.run_once, self.run_loop)
        super().__init__(name=arg_options.get("name", None), target=my_target)
        Msg.dbg("Created Thread[%s] Processing...." % (self.name))

        # useful Thread events
        self.on_start = arg_options.get("on-start", None)
        self.on_execute = arg_options.get("on-execute", None)
        self.on_done = arg_options.get("on-done", None)
        self.on_shutdown = arg_options.get("on-shutdown", None)
        self.on_finished = arg_options.get("on-finished", None)

        # thread flags
        self.shutdown = False  # shutdown request has been received
        self.finished = False  # thread has completed all work and has exited

        # the thread heartbeat is set to write a debug message every 30 seconds
        # if the thread is waiting. I do not like the term blocking because
        # waiting is a more controlled event. The waiting thread asks for
        # permission to procees rather than the thread that is busy having to
        # create a block. Blocks are notorious for causing deadlock requiring
        # less than a graceful shutdown
        self.heartbeat_rate = arg_options.get("heartbeat-rate", 30)
        self.sleep_period = arg_options.get("sleep-period", 1000)
        self.current_tick = 0

        # not a good idea to use daemons as a blanket rule, makes bad designs
        # seem to function but there are always underlying issues with these.
        # The daemon attribute exists in the abstract as does the handler.
        # Setting it here will ensure the thread acts as we expect
        self.daemon = arg_options.get("daemon", False)
        if arg_options.get("active", False):
            self.start_thread()
Ejemplo n.º 12
0
 def TimeAsStr(arg_class, arg_utcdt=None):
     my_utcdt = SysUtils.ifthen(arg_utcdt is None, datetime.utcnow(),
                                arg_utcdt)
     return str(my_utcdt.time())
Ejemplo n.º 13
0
 def DateAsStr(cls, arg_utcdt=None):
     my_utcdt = SysUtils.ifthen(arg_utcdt is None, datetime.utcnow(),
                                arg_utcdt)
     return str(my_utcdt.date())