コード例 #1
0
    def RunAdditionalPhases(self, wp_pb_dir, sim_replay_cmd, options):
        """
        Run the additional phases for the simulator which are not run as
        part of the usual PinPlay phases.
        """

        phases_obj = phases.Phases()
        self.sim_kit = self.GetSimKit()

        msg.PrintMsg('sinuca_tracer_output:         ' +
                     config.sinuca_tracer_output)
        msg.PrintMsg('sinuca_tracer_threads:        ' +
                     str(config.sinuca_tracer_threads))
        msg.PrintMsg('sinuca_tracer_parallel_start: ' +
                     str(config.sinuca_tracer_parallel_start))
        msg.PrintMsg('sinuca_tracer_parallel_end:   ' +
                     str(config.sinuca_tracer_parallel_end))

        if not options.sinuca_tracer_output:
            msg.PrintMsgPlus('ERROR: Please set sinuca_tracer_output.')
            util.CheckResult(
                -1, options,
                'Could not find the sinuca_tracer_output parameter.'
            )  # Force error with -1
# ~ # ~
        if not options.sinuca_tracer_threads:
            msg.PrintMsgPlus('ERROR: Please set sinuca_tracer_threads.')
            util.CheckResult(
                -1, options,
                'Could not find the sinuca_tracer_threads parameter.'
            )  # Force error with -1
# ~ # ~
        if not options.sinuca_tracer_parallel_start:
            msg.PrintMsgPlus('ERROR: Please set sinuca_tracer_parallel_start.')
            util.CheckResult(
                -1, options,
                'Could not find the sinuca_tracer_parallel_start parameter.'
            )  # Force error with -1


# ~ # ~
        if not options.sinuca_tracer_parallel_end:
            msg.PrintMsgPlus('ERROR: Please set sinuca_tracer_parallel_end.')
            util.CheckResult(
                -1, options,
                'Could not find the sinuca_tracer_parallel_end parameter.'
            )  # Force error with -1

        # Run branch predictor simulator on region pinballs.
        #
        if options.region_sim or options.default_phases:
            # Print out simulator results every warmup_length instructions.
            #
            for pp_dir in util.GetRegionPinballDir():
                phase_length = options.warmup_length
                if phase_length == 0:
                    phase_length = options.slice_size
                if not options.list:
                    msg.PrintMsgDate('Running simulator on region pinballs: %s' % \
                        config.PhaseStr(config.sim_regions))
                util.PhaseBegin(options)
                result = self.sim_kit.RunSimulator(pp_dir, sim_replay_cmd,
                                                   options)
                if not options.list:
                    msg.PrintMsgDate('Finished running simulator on region pinballs: %s' % \
                        config.PhaseStr(config.sim_regions))
                util.CheckResult(result, options, 'simulator on region pinballs: %s' % \
                    config.PhaseStr(config.sim_regions))

        # Run branch predictor simulator on whole program pinballs.
        #
        if options.whole_sim or options.default_phases:
            # Set phase_length to print out simulator results every slice_size instructions.
            #
            phase_length = options.slice_size

            if not options.list:
                msg.PrintMsgDate('Running simulator on whole program pinballs: %s' % \
                    config.PhaseStr(config.sim_whole))
            util.PhaseBegin(options)
            result = self.sim_kit.RunSimulator(wp_pb_dir, sim_replay_cmd,
                                               options)
            if not options.list:
                msg.PrintMsgDate('Finished running simulator on whole program pinballs: %s' % \
                    config.PhaseStr(config.sim_whole))
            util.CheckResult(result, options, 'simulator on whole program pinballs: %s' % \
                config.PhaseStr(config.sim_whole))

        return 0
コード例 #2
0
ファイル: pinpoints.py プロジェクト: GabrielCambe/OrCS
    def Run(self):
        """
        Get the user's options, read config file and execute the phases desired by the user.

        @return Exit code from last phase executed
        """

        # Catch signals in order to do an orderly shutdown of the script.
        #
        self.InstallSigHandler()

        # import pdb;  pdb.set_trace()
        options = self.ParseCommandLine()

        # Print out the version numbers for all python modules in this directory.
        #
        if config.debug:
            util.PrintModuleVersions()

        # If logging, ensure the user has entered a mode.
        #
        if options.log and config.mode == '':
            msg.PrintHelpAndExit(
                'Must enter mode of application using: --mode "st|mt|mpi|mpi_mt"')

        # Set the defaults for a set of variables which are needed, but not in the list
        # of required options in the tracing configuration file.
        #
        self.SetDefaults(options)

        # Create an new status file and zero out the file if it already exists.
        # If user sets parameter 'append_status', the old file is not deleted.
        #
        util.NewStatusFile(options)

        # Add 1500 to the warmup length in order to deal with problems that
        # occur when the start of a warmup region and the end of the previous
        # region are in the same basic block.
        #
        if not config.global_regions:
          config.warmup_length += 1500

        # Get variables used in many phases.
        #
        # import pdb;  pdb.set_trace()
        wp_pb_dir = util.GetWPDir()
        log_file_name = util.GetLogFile()

        # Print out the tracing configuration parameters.
        #
        if not options.list:
            self.phases.PrintTracingInfo(options, wp_pb_dir, log_file_name,
                                         self.PrintHome)

        #########################################################################
        #
        # Several phases which clean up tracing instances.
        #
        #########################################################################

        result = 0
        if options.delete or options.delete_wp:
            self.phases.DeleteTracingFileDir(options)
            util.CheckResult(result, options, 'Deleting tracing instance files')

            # Since just deleted all files/dirs for the tracing instance, need
            # to set the whole program directory to the default value.  Do NOT
            # use util.GetWPDir() here because this may return the name of a
            # relogged WP directory (which we, of course, just deleted.)
            #
            wp_pb_dir = util.GetBaseWPDir()

        if options.delete_all:
            self.phases.DeleteAllTracingFileDir(options)
            util.CheckResult(result, options, 'Deleting all tracing files')

            # Again, since just deleted all files/dirs, need to set the whole
            # program directory to the default value.  
            #
            wp_pb_dir = util.GetBaseWPDir()

        # If the user has given the name of the whole program pinball
        # directory, then save it. This must be done after the two delete
        # phases because these phases delete this configuration file.
        # Also, need to get default WP directory name in 'wp_pb_dir'.
        #
        # import pdb ; pdb.set_trace()
        if hasattr(options, 'whole_pgm_dir') and options.whole_pgm_dir:
            config.whole_pgm_dir = options.whole_pgm_dir
            self.Config.SaveCfgParameter('whole_pgm_dir', options.whole_pgm_dir)
            wp_pb_dir = util.GetWPDir()

        #########################################################################
        #
        # Run the phases of the script. They are in a specific order to ensure
        # all prerequisite phases are completed before a given phase is run.
        #
        #########################################################################

        # Run the application without pin/pintools.
        #
        if options.native_pure:
            util.PhaseBegin(options)
            result = self.phases.NativePure(options)
            util.CheckResult(
                result, options,
                'Pure native run %s' % config.PhaseStr(config.native_pure))

        # Run the application using pin, but no pintools.
        #
        if options.native_pin:
            util.PhaseBegin(options)
            result = self.phases.NativePin(self.logger_cmd, wp_pb_dir, log_file_name, \
                options)
            util.CheckResult(result, options, 'Native run with pin only %s' % \
                config.PhaseStr(config.native_pin))

        # Logging phase to generate initial whole program pinballs.
        #
        # import pdb;  pdb.set_trace()
        if options.log or options.default_phases:
            util.PhaseBegin(options)
            result = self.phases.Logger(self.logger_cmd, wp_pb_dir, log_file_name, \
                options)
            util.CheckResult(result, options, 'Whole program pinball generation %s' % \
                config.PhaseStr(config.log_whole))

        # All phases after this require the whole program pinball directory.  Exit with an
        # error if it does not exist.
        #
        # import pdb;  pdb.set_trace()
        if not os.path.isdir(wp_pb_dir) and not options.list and not options.debug and\
                not options.delete and not options.delete_all and not options.delete_wp and \
                not options.native_pure and not options.native_pin:
            string = '\nERROR: Can\'t proceed because the whole program pinball directory does not exist:\n' + \
                '      ' + wp_pb_dir + \
                '\nMust select at least one phase to run.  Try using option \'--default_phases\'.' + \
                '\nUse \'-h\' for help on selecting phases to run.'
            msg.PrintMsg(string)
            # Use -1 to force check to fail
            util.CheckResult(-1, options,
                             'Initial check to see if WP pinballs exist')

        # Print out the number of instructions in the whole program pinballs.
        #
        if not options.list and os.path.isdir(wp_pb_dir):
            msg.PrintMsg('')
            msg.PrintMsg('Initial whole program pinball(s)')
            util.PrintInstrCount(wp_pb_dir, options)

        #########################################################################
        #
        # Phases which relog whole program pinballs using a filter to remove
        # certain type of instructions (such as initialization or MPI spin).
        #
        # The relogging phases must be executed before the basic block vector
        # generation phase. This must be done in case one, or more, relogging
        # phases are executed.  If so then, the BB vector phase needs to use
        # the final relogged WP pinballs generated here.
        #
        #########################################################################

        # If the user gives one, or more, of the use_relog_* options, they want
        # to explictly define which filtered WP pinballs to use.  As a result,
        # unset the parameter 'relog_dir' just read from the per instance
        # tracing configuration file and from the config object.  This removes
        # the previous "sticky" value for the filtered WP pinballs.  Then use
        # the WP pinball directory before any filters have been applied.
        #
        # import pdb;  pdb.set_trace()
        if cmd_options.UseRelogOptionsSet(options):
            Config = config.ConfigClass()
            Config.ClearCfgParameter('relog_dir')
            config.relog_dir = ''
            wp_pb_dir = util.GetBaseWPDir()

        def FinalizeWPDir(wp_dir, string):
            """
            Set the filtered WP pinball directory to be the new default WP dir
            and print out the number of instructions in the newly filtered
            pinballs.
            """

            config.relog_dir = wp_dir
            if not options.debug and not options.list:
                # Only save this parameter if not just debugging or
                # listing the commands to be run.
                #
                self.Config.SaveCfgParameter('relog_dir', wp_dir)
            if not options.list and os.path.isdir(wp_dir):
                msg.PrintMsg('')
                msg.PrintMsg(string)
                util.PrintInstrCount(wp_dir, options)

            return

        # The format of the code for each relogging (filtering) phase contains
        # 3 components:
        #
        #   1) If going to use relogged WP pinballs for the phase (indicated by
        #      either 'relog_*' or 'use_relog_*' options), then get the
        #      appropriate WP directory name for this phase.  Need to always do
        #      this, even when not relogging, because a previous run generated
        #      relogged WP pinballs.
        #
        #   2) If going to filter with relogging (indicated by a 'relog_*'
        #      option), then run the relogging phase.
        #
        #   3) Set the name of the default whole program pinball directory to
        #      the directory with the relogged WP pinballs.

        # Relog with a user defined name for the relogged directory, and hopefully a set of
        # knobs to define what action to take when relogging.
        #
        # import pdb;  pdb.set_trace()
        if options.use_relog_name != '' or options.relog_name:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir, config.RELOG_NAME,
                                                 options)
            if options.relog_name:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs with user defined name: %s %s' % \
                        (options.relog_name, config.PhaseStr(config.filter_user_defn)))
                util.PhaseBegin(options)
                result = self.phases.RelogWholeName(self.replay_cmd, wp_pb_dir,
                                                    relog_wp_dir, options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs with user defined name: %s %s' % \
                        (options.relog_name, config.PhaseStr(config.filter_user_defn)))
                util.CheckResult(result, options, 'Filtering WP pinballs with user defined name: %s %s' % \
                    (options.relog_name, config.PhaseStr(config.filter_user_defn)))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered with user defined name: ' +
                options.relog_name)

        # Relog with a focus thread.
        #
        if options.use_relog_focus or options.relog_focus:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir, config.RELOG_FOCUS,
                                                 options)
            if options.relog_focus:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs with a focus thread %s' % \
                        config.PhaseStr(config.filter_focus_thread))
                # import pdb;  pdb.set_trace()
                util.PhaseBegin(options)
                result = self.phases.RelogWholeFocus(self.replay_cmd,
                                                     wp_pb_dir, relog_wp_dir,
                                                     options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs with a focus thread %s' % \
                        config.PhaseStr(config.filter_focus_thread))
                util.CheckResult(result, options, 'Filtering WP pinballs with focus thread %s' % \
                    config.PhaseStr(config.filter_focus_thread))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered with a focus thread')

            # If pinballs were relogged with a focus thread, then in the
            # remaining phases the focus thread must be 0.  Relogging generates
            # per thread whole program pinballs (which only have thread 0).  To
            # enforce this, we change the focus_thread in the config object to
            # be 0.
            #
            config.focus_thread = 0

            # Also need to set options.use_relog_focus = True because we are will be using
            # WP pinballs which have been relogged with a focus thread.
            #
            options.use_relog_focus = True

        # Relog to remove initialization instructions.  Do this before removing cleanup or
        # MPI spin instructions.
        #
        # import pdb;  pdb.set_trace()
        if options.use_relog_no_init or options.relog_no_init:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir,
                                                 config.RELOG_NO_INIT, options)
            if options.relog_no_init:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs to remove initialization instructions %s' % \
                        config.PhaseStr(config.filter_init))
                util.PhaseBegin(options)
                result = self.phases.RelogWholeRemoveInit(self.replay_cmd,
                                                          wp_pb_dir,
                                                          relog_wp_dir, options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs to remove initialization instructions %s' % \
                        config.PhaseStr(config.filter_init))
                util.CheckResult(result, options, 'Filtering WP pinballs to remove init instructions %s' % \
                    config.PhaseStr(config.filter_init))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered to remove initialization instructions')

        # Relog to remove cleanup instructions.  Do this before removing MPI spin
        # instructions.
        #
        # import pdb;  pdb.set_trace()
        if options.use_relog_no_cleanup or options.relog_no_cleanup:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir,
                                                 config.RELOG_NO_CLEANUP,
                                                 options)
            if options.relog_no_cleanup:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs to remove cleanup instructions %s' % \
                        config.PhaseStr(config.filter_cleanup))
                util.PhaseBegin(options)
                result = self.phases.RelogWholeRemoveCleanup(
                    self.replay_cmd, wp_pb_dir, relog_wp_dir, options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs to remove cleanup instructions %s' % \
                        config.PhaseStr(config.filter_cleanup))
                util.CheckResult(result, options, 'Filtering WP pinballs to remove cleanup instructions %s' % \
                    config.PhaseStr(config.filter_cleanup))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered to remove cleanup instructions')

        # Relog to exclude code (instructions) between two addresses. Do this
        # before removing MPI spin instructions.
        #
        # import pdb;  pdb.set_trace()
        if options.use_relog_code_exclude != '' or options.relog_code_exclude:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir,
                                                 config.RELOG_CODE_EXCLUDE,
                                                 options)
            if options.relog_code_exclude:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs with code exclusion %s' % \
                        config.PhaseStr(config.filter_code_exclude))
                util.PhaseBegin(options)
                result = self.phases.RelogWholeCodeExclude(
                    self.replay_cmd, wp_pb_dir, relog_wp_dir, options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs with code exclusion %s' % \
                        config.PhaseStr(config.filter_code_exclude))
                util.CheckResult(result, options, 'Filtering WP pinballs with code exclusion %s' % \
                    config.PhaseStr(config.filter_code_exclude))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered with code exclusion')

        # Relog to remove OpenMP spin instructions.
        #
        # import pdb;  pdb.set_trace()
        if options.use_relog_no_omp_spin or options.relog_no_omp_spin:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir,
                                                 config.RELOG_NO_OMP_SPIN,
                                                 options)
            if options.relog_no_omp_spin:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs to remove OpenMP spin instructions %s' % \
                        config.PhaseStr(config.filter_OMP_spin))
                util.PhaseBegin(options)
                result = self.phases.RelogWholeRemoveOMPSpin(
                    self.replay_cmd, wp_pb_dir, relog_wp_dir, options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs to remove OpenMP spin instructions %s' % \
                        config.PhaseStr(config.filter_OMP_spin))
                util.CheckResult(result, options, 'Filtering WP pinballs to remove OpenMP spin instructions %s' % \
                    config.PhaseStr(config.filter_OMP_spin))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered to remove OpenMP spin instructions')

        # Relog to remove MPI spin instructions.
        #
        # import pdb;  pdb.set_trace()
        if options.use_relog_no_mpi_spin or options.relog_no_mpi_spin:
            relog_wp_dir = util.GetRelogPhaseDir(wp_pb_dir,
                                                 config.RELOG_NO_MPI_SPIN,
                                                 options)
            if options.relog_no_mpi_spin:
                if not options.list:
                    msg.PrintMsgDate('Filtering whole program pinballs to remove MPI spin instructions %s' % \
                        config.PhaseStr(config.filter_MPI_spin))
                util.PhaseBegin(options)
                result = self.phases.RelogWholeRemoveMPISpin(
                    self.replay_cmd, wp_pb_dir, relog_wp_dir, options)
                if not options.list:
                    msg.PrintMsgDate('Finished filtering whole program pinballs to remove MPI spin instructions %s' % \
                        config.PhaseStr(config.filter_MPI_spin))
                util.CheckResult(result, options, 'Filtering WP pinballs to remove MPI spin instructions %s' % \
                    config.PhaseStr(config.filter_MPI_spin))

            # No errors, commit to using the new pinballs.
            #
            wp_pb_dir = relog_wp_dir
            FinalizeWPDir(
                relog_wp_dir,
                'Whole program pinball(s) filtered to remove MPI spin instructions')

        if not options.list:
            msg.PrintMsgPlus(
                'Using whole program pinballs in dir: ' + wp_pb_dir)
            if (cmd_options.UseRelogOptionsSet(options) or \
               cmd_options.RelogOptionsSet(options)) and \
               os.path.isdir(wp_pb_dir):
                msg.PrintMsg('')
                util.PrintInstrCount(wp_pb_dir, options)

        #########################################################################
        #
        # These phases are run with the whole progam pinballs defined/generated
        # in the previous phases.
        #
        #########################################################################

        # Make sure any relogged whole program pinball directory exist.  Exit with an
        # error if it does not exist.
        #
        # import pdb;  pdb.set_trace()
        if not os.path.isdir(wp_pb_dir) and not options.list and not options.debug and\
                not options.delete and not options.delete_all and not options.delete_wp and \
                not options.native_pure and not options.native_pin:
            string = 'ERROR: Can\'t proceed because the whole program pinball directory does not exist:\n' + \
                '      ' + wp_pb_dir
            msg.PrintMsg(string)
            # Use -1 to force check to fail
            util.CheckResult(-1, options,
                             'Second check to see if WP pinballs exist')

        # Do not run replay whole program pinballs as one of the default
        # phases.  The user must explicitly include this option.  This is to
        # save time during the tracing process.
        #
        if options.replay:
            if not options.list:
                msg.PrintMsgDate('Replaying all whole program pinballs %s' % \
                    config.PhaseStr(config.replay_whole))
            util.PhaseBegin(options)
            result = self.phases.Replay(self.replay_cmd, wp_pb_dir, options)
            if not options.list:
                msg.PrintMsgDate('Finished replaying all whole program pinballs %s' % \
                    config.PhaseStr(config.replay_whole))
            util.CheckResult(result, options, 'Replay of whole program pinballs %s' % \
                config.PhaseStr(config.replay_whole))

        # Generate basic block vectors.
        #
        if options.basic_block_vector or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Generating basic block vectors %s' % \
                    config.PhaseStr(config.gen_BBV))
            util.PhaseBegin(options)
            result = self.phases.BasicBlockVector(self.replay_cmd, wp_pb_dir,
                                                  options)
            if result == 0:
                result = util.WaitJobs(options)
            if not options.list:
                msg.PrintMsgDate('Finished basic block vector generation %s' % \
                    config.PhaseStr(config.gen_BBV))
            util.CheckResult(result, options, 'Basic block vector generation %s' % \
                config.PhaseStr(config.gen_BBV))

        # Run Simpoints to genenerate representative regions.
        #
        if options.simpoint or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Running Simpoint on all processes %s' % \
                    config.PhaseStr(config.Simpoint))
            # Setup dictionary of parameters for method RunAllDir()
            #
            msg.PrintMsg('fbm was in pinpoints')
            param = {'options': options}
            util.PhaseBegin(options)
            result = util.RunAllDir(wp_pb_dir, self.phases.RunSimPoint, True,
                                    param)
            if not options.list:
                msg.PrintMsgDate('Finished running Simpoint for all processes %s' % \
                    config.PhaseStr(config.Simpoint))
            util.CheckResult(result, options, 'Simpoints generation %s' % \
                config.PhaseStr(config.Simpoint))

        # Relog to generate representative region pinballs.
        #
        if options.region_pinball or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Generating region pinballs %s' % \
                    config.PhaseStr(config.relog_regions))
            util.PhaseBegin(options)
            result = self.phases.MultiIterGenRegionPinballs(wp_pb_dir,
                                                            self.replayer_cmd,
                                                            options)
            if result == 0:
                if not options.list:
                    msg.PrintMsgPlus(
                        'Waiting on final concurrent region pinball generation')
                result = util.WaitJobs(options)
            if not options.list:
                msg.PrintMsgDate('Finished generating region pinballs %s' % \
                    config.PhaseStr(config.relog_regions))
            util.CheckResult(result, options, 'Region pinball generation %s' %\
                config.PhaseStr(config.relog_regions))

        # Do not run replay region pinballs as one of the default phases.  The
        # user must explicitly include this option.  This is to save time
        # during the tracing process.
        #
        if options.replay_region:
            result = 0
            if not options.list:
                msg.PrintMsgDate('Replaying all region pinballs %s' % \
                    config.PhaseStr(config.replay_regions))
            # import pdb;  pdb.set_trace()
            util.PhaseBegin(options)
            for pp_dir in util.GetRegionPinballDir():
                # Accumulate any errors which occur, but don't check for errors
                # until all the pinballs have been replayed.
                #
                r = self.phases.Replay(self.replay_cmd, pp_dir, options)
                result = result or r
            if not options.list:
                msg.PrintMsgDate('Finished replaying all region pinballs %s' % \
                    config.PhaseStr(config.replay_regions))
            util.CheckResult(result, options, 'Replay of region pinballs %s' % \
                config.PhaseStr(config.replay_regions))
            result = 0  # Remove the return values from replaying region pinballs

        # If there are any additional phases, then run them.
        #
        self.RunAdditionalPhases(wp_pb_dir, self.sim_replay_cmd, options)

        # Cleanup and print out a string to indicate the tracing has completed.
        #
        # import pdb;  pdb.set_trace()
        util.CleanupTraceEnd(options)
        util.PrintTraceEnd(options)

        return result
コード例 #3
0
    def RunAdditionalPhases(self, sim_replay_cmd, options, bin_options):
        """
        Run the CBSP additional phases for SDE which are not run for PinPlay.

        @param sim_replay_cmd Script which run the simulator on pinballs
        @param options Options given on cmd line
        @param options Options for each CBSP binary

        @return Exit code from last phase executed
        """

        # The SDE phases object needs an SDE kit object.
        #
        s_phases = sde_phases.SDEPhases()
        kit_obj = self.GetKit()
        s_phases.SetKit(kit_obj)

        # Need the appropriate simulator kit too.
        #
        sim_kit = self.GetSimKit()

        # Generate LMAT/LIT files
        #
        result = 0
        if options.lit_gen or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Generating traces for region pinballs %s' % \
                    config.PhaseStr(config.LIT))
            util.PhaseBegin(options)
            for bopts in bin_options:
                wp_dir = util.GetDefaultWPDir(bopts)
                log_file_name = util.GetLogFile(bopts)
                self.Config.SetPerBinParams(bopts)
                result = s_phases.GenAllLitFiles(self.replayer_cmd, bopts)
                if result == 0:
                    if not options.list:
                        msg.PrintMsgPlus('Waiting on final trace generation')
                    result = util.WaitJobs(options)
                util.CheckResult(result, options, 'Traces for: %s %s' % \
                    (log_file_name, config.PhaseStr(config.LIT)), intermediate_phase=True)
            if not options.list:
                msg.PrintMsgDate('Finished generating traces for region pinballs %s' % \
                    config.PhaseStr(config.LIT))
            util.CheckResult(result, options, 'Trace file generation %s' %\
                config.PhaseStr(config.LIT))

        # Run CMPSim simulator on region pinballs.
        #
        result = 0
        if options.region_sim or options.default_phases:
            # Print out CMPSim results every warmup_length instructions.
            #
            phase_length = options.warmup_length // config.instr_cmpsim_phase
            if phase_length == 0:
                phase_length = 1
            for bopts in bin_options:
                self.Config.SetPerBinParams(bopts)
                for pp_dir in util.GetRegionPinballDir(bopts):
                    if not options.list:
                        msg.PrintMsgDate('Running CMPSim on region pinballs in dir: %s %s' % \
                            (pp_dir, config.PhaseStr(config.CMPsim_regions)))
                    util.PhaseBegin(options)
                    result = sim_kit.RunSimulator(pp_dir, sim_replay_cmd,
                                                  phase_length, bopts)
                    util.CheckResult(result, options, 'CMPSim for: %s %s' % \
                        (pp_dir, config.PhaseStr(config.CMPsim_regions)), intermediate_phase=True)
            if not options.list:
                msg.PrintMsgDate('Finished running CMPSim on region pinballs in dir %s %s' % \
                    (pp_dir, config.PhaseStr(config.CMPsim_regions)))
            util.CheckResult(result, options, 'CMPSim on region pinballs: %s' % \
                        config.PhaseStr(config.CMPsim_regions))

        # Run CMPSim simulator on whole program pinballs.
        #
        if options.whole_sim or options.default_phases:
            # Set phase_length to print out CMPSim results every slice_size instructions.
            #
            phase_length = options.slice_size // config.instr_cmpsim_phase
            if phase_length == 0:
                phase_length = 1
            for bopts in bin_options:
                if not options.list:
                    msg.PrintMsgDate('Running CMPSim on whole program pinballs %s' % \
                        config.PhaseStr(config.CMPsim_whole))
                util.PhaseBegin(options)
                wp_dir = util.GetDefaultWPDir(bopts)
                self.Config.SetPerBinParams(bopts)
                result = sim_kit.RunSimulator(wp_dir, sim_replay_cmd,
                                              phase_length, bopts)
                util.CheckResult(result, options, 'CMPSim for: %s %s' % \
                    (wp_dir, config.PhaseStr(config.CMPsim_whole)), intermediate_phase=True)
            if not options.list:
                msg.PrintMsgDate('Finished running CMPSim on whole program pinballs %s' % \
                    config.PhaseStr(config.CMPsim_whole))
            util.CheckResult(result, options, 'CMPSim on whole program pinballs %s' % \
                config.PhaseStr(config.CMPsim_whole))

        # Calculate prediction error from simulator data files.
        #
        if options.pred_error or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Calculating prediction error %s' % \
                    config.PhaseStr(config.pred_error))
            util.PhaseBegin(options)
            for bopts in bin_options:
                wp_dir = util.GetDefaultWPDir(bopts)
                result = s_phases.CalcPredError(wp_dir, sim_kit, bopts)
                util.CheckResult(result, options, 'Prediction error for: %s %s' % \
                    (wp_dir, config.PhaseStr(config.pred_error)), intermediate_phase=True)
            if not options.list:
                msg.PrintMsgDate('Finished calculating prediction error %s' % \
                    config.PhaseStr(config.pred_error))
            util.CheckResult(result, options, 'Prediction error calculation %s' % \
                config.PhaseStr(config.pred_error))

        # Assume nothing has gone wrong at this point.
        #
        return result
コード例 #4
0
    def DeleteTracingFileDir(self, options):
        """
        Delete files & directories generated for only the current tracing instance.

        TODO: Implement this for CBSP.

        @param options Options given on cmd line

        @return no return
        """

        # The "base" WP pinball directory is the directory before any filters have
        # been applied.
        #
        # import pdb;  pdb.set_trace()
        wp_pb_dir = util.GetBaseWPDir()

        # Variables used to define different file types for this tracing instance.
        #
        relog_wp_dir = wp_pb_dir + config.relog_dir_str
        log_file = util.GetLogFile()
        pb_list = [p.replace('.Data', '') for p in util.GetDataDir()]
        csv_list = [p + '*.csv' for p in pb_list]
        sim_list = [p + '_simpoint_out.txt' for p in pb_list]

        # Only delete these files/dirs which are specific to the current
        # tracing instance defined by tracing parameters.
        #
        util.Delete(options, ' '.join(util.GetDataDir()))
        util.Delete(options, ' '.join(util.GetRegionPinballDir()))
        util.Delete(options, ' '.join(util.GetLitDir()))
        util.Delete(options, relog_wp_dir + '.*')
        util.Delete(options, ' '.join(csv_list))
        util.Delete(options, ' '.join(sim_list))
        util.Delete(options, log_file + '*.NATIVE.TIME')
        util.Delete(options, 'verify_' + log_file + '_out.txt')
        util.Delete(options, util.GetStatusFileName())
        util.Delete(options, 'PARALLEL.PARAM')

        # Delete sniper result directories for this tracing instance
        #
        sniper_dirs = glob.glob(
            os.path.join(config.sniper_result_dir, wp_pb_dir,
                         util.GetLogFile() + '*'))
        sniper_dirs += [
            os.path.join(config.sniper_result_dir,
                         os.path.basename(w) + '.pp') for w in sniper_dirs
        ]
        for dir in sniper_dirs:
            util.Delete(options, dir)
        util.Delete(options, os.path.join(config.sniper_result_dir, wp_pb_dir))

        # Only delete the whole program pinball directory if it was not
        # specified by the user in a previous run of the scripts or the user
        # gave the option '--delete_wp'.
        #
        # import pdb;  pdb.set_trace()
        if (hasattr(config, 'whole_pgm_dir') and config.whole_pgm_dir == '') or \
           options.delete_wp:
            util.Delete(options,
                        self.Config.GetInstanceFileName(config.config_ext))
            util.Delete(options, wp_pb_dir)
        else:
            msg.PrintMsg(
                '\nNOTE: User defined whole program directory was used.  Will NOT\n'
                'delete this directory.')
            msg.PrintMsg('    ' + config.whole_pgm_dir)

        # No error checking for deleting
        #
        return 0
コード例 #5
0
    def GenTraceinfoFiles(self, options):
        """
        Generate traceinfo files from sysinfo files. Also do some simple error
        checking.

        One traceinfo file is generated for each directory which contains
        region pinballs.  Currently, the script 'create_traceinfo.sh' is used
        to generate the traceinfo file.  This will be replaced with a Python
        script at sometime in the future.

        The following info is printed to allow the user to determine if the
        required number of region pinballs and traces were generated:
        1) The script 'count_traces.sh' gets a count of the number of
           expected traces and the region numbers from the region CSV file.
        2) The number of actual traces generated and the trace names.
        3) The number of region pinballs generated and the pinball names.
        """

        # Check to make sure there is at least one region pinball directory for
        # this tracing instance.
        #
        all_pp_dirs = util.GetRegionPinballDir(options)
        if all_pp_dirs == [] and not options.debug:
            msg.PrintMsg(
                '\nERROR: Could not find any PinPoint \'*.pp\' directories.\n'
                'Make sure you have run the phase \'-p\'.')
            return -1

        # Get the region pinball directories for this tracing instance.
        #
        # import pdb;  pdb.set_trace()
        all_lit_dirs = util.GetLitDir()
        if all_lit_dirs == [] and not options.debug:
            msg.PrintMsg(
                '\nERROR: Could not find any LIT \'*.lit\' directories.\n'
                'Make sure you have run the phase \'-L\'.')
            return -1

        result = 0
        # import pdb;  pdb.set_trace()
        for lit_dir in all_lit_dirs:

            # Get the name of the corresponding region pinball directory
            # and make sure it exists.
            #
            pp_dir = util.ChangeExtension(lit_dir, '.lit', '.pp')
            if not os.path.isdir(pp_dir):
                if not options.list:
                    msg.PrintMsgPlus('WARNING: Generating traceinfo files, but the required \'pp\' ' \
                        'directory does not exist:\n   ' + pp_dir)

                    # If running in MPI_MT_MODE, then it's possible for one process to
                    # not have a thread corresponding to the the current focus thread.
                    # However, another process might have this thread.
                    # Thus, only return an error if not tracing a MPI_MT application.
                    #
                    if options.mode == config.MPI_MT_MODE:
                        msg.PrintMsg(
                            'Since tracing mode is \'mpi_mt\', this may be OK.')
                        continue
                    else:
                        return -1
                else:
                    # Not printing any msgs, just skip to the next directory
                    #
                    continue

            # Make sure the LIT directory exists, then go there.
            #
            old_dir = os.getcwd()
            if os.path.isdir(lit_dir):
                os.chdir(lit_dir)
            else:
                if not options.list:
                    msg.PrintMsgPlus('WARNING: Generating traceinfo files, but the LIT ' \
                        'directory does not exist:\n   ' + lit_dir)

                    # If running in MPI_MT_MODE, then it's possible for one process to
                    # not have a thread corresponding to the the current focus thread.
                    # However, another process might have this thread.
                    # Thus, only return an error if not tracing a MPI_MT application.
                    #
                    if options.mode == config.MPI_MT_MODE:
                        msg.PrintMsg(
                            'Since tracing mode is \'mpi_mt\', this may be OK.')
                        continue
                    else:
                        return -1
                else:
                    # Not printing any msgs, just skip to the next directory
                    #
                    continue

            # Copy the traceinfo 'blank' XML files from the SDE kit.
            #
            blank_path = self.kit_obj.GetTraceinfoBlank()
            for blank in config.traceinfo_blank_files:
                blank_file = os.path.join(blank_path, blank)
                try:
                    shutil.copy(blank_file, os.getcwd())
                except IOError:
                    msg.PrintMsg(
                        '\nERROR: Unable to copy traceinfo \'blank\' file:\n    '
                        + blank_file)
                    return -1

            # Run the script to generate traceinfo XML file.  Stdout from the
            # script is the XML file.  Function util.RunCMD() needs the output XML
            # file object in order to write this file.
            #
            msg.PrintMsg('')
            base_name = util.ChangeExtension(lit_dir, '.lit', '')
            tr_file = base_name + '.traceinfo.xml'
            try:
                fp_out = open(tr_file, 'w')
            except IOError:
                msg.PrintMsg('ERROR: Failed to open traceinfo output file:\n'
                             '   ' + tr_file)
                return -1
            cmd = self.traceinfo_bin + ' ' + base_name
            result = util.RunCmd(cmd, options, '',
                                 concurrent=False,
                                 f_stdout=fp_out)
            if result != 0:
                msg.PrintMsg('Error found while running script \'%s\'' %
                             self.traceinfo_bin)
                return -1

            # Print info from the CSV regions file (located in the *.Data
            # directory) about the number of expected traces.
            #
            msg.PrintMsg('')
            param = {'in_lit_dir': True}
            cluster_info, not_used, total_instr = util.GetClusterInfo(base_name, param)
            if cluster_info == {}:
                msg.PrintMsg(
                    'ERROR: Problems getting cluster info from file: %s.pinpoints.csv'
                    % (base_name))
                return -1
            cluster_list = util.ParseClusterInfo(cluster_info)
            if len(cluster_info) != len(cluster_list):
                msg.PrintMsg('ERROR: Did not parse enough clusters from CSV file: %s.pinpoints.csv\n' '   Num clusters:         %d\n' \
                    '   Num parsed clusters:  %d' % (base_name, len(cluster_info), len(cluster_list)))
                return -1

            # Print the number of expected traces from the regions CSV file.
            #
            base_tid = -1
            for cl in cluster_list:
                if (cl.has_key('tid')):
                    tid = cl['tid']
                else:
                    msg.PrintMsg(
                        'ERROR: Parsing cluster info for cluster:\n     %s' %
                        (cl))
                    return -1
                if base_tid == -1:
                    base_tid = tid
                else:
                    if tid != base_tid:
                        msg.PrintAndExit(
                            'ERROR: Expected TID %d, but found TID %d' %
                            (base_tid, tid))
                        return -1
            msg.PrintMsg('Expected trace count: %d\n' % (len(cluster_info)))

            # Print the number of actual traces in the LIT directory and the names. 
            #
            # import pdb;  pdb.set_trace()
            if not options.list:
                msg.PrintMsg(
                    'Actual trace count: ' + str(util.CountFiles('ami')))
                lit_files = glob.glob('*.ami*')
                lit_files.sort()
                for f in lit_files:
                    msg.PrintMsg('   ' + f)

            # Clean up tmp files in the LIT directory.
            #
            tmp_files = glob.glob('*blank*.xml')
            for f in tmp_files:
                os.remove(f)

            # Return to the working directory.
            #
            os.chdir(old_dir)

            # Go to the *.pp directory. Print the number of actual pinballs and the names.
            #
            os.chdir(pp_dir)
            if not options.list:
                msg.PrintMsg(
                    '\nPinball count: ' + str(util.CountFiles('address')))
                pp_files = glob.glob('*.address')
                pp_files.sort()
                for f in pp_files:
                    msg.PrintMsg('   ' + f)

                # Print a warning if the expected number of traces are not found.
                #
                if len(lit_files) != len(pp_files):
                    msg.PrintMsgPlus(
                        'WARNING: Number of traces does not match the number of region pinballs.')

            msg.PrintMsg('\nGenerated traceinfo file: ' + tr_file)

            # Return to the working directory.
            #
            os.chdir(old_dir)

        return result
コード例 #6
0
    def GenAllLitFiles(self, replay_cmd, options):
        """
        Generate LIT files and warmup LMAT files for all region pinballs in the tracing instance.
        """

        result = 0

        # Get the region pinball directories for this tracing instance.
        #
        # import pdb;  pdb.set_trace()
        pp_dirs = util.GetRegionPinballDir(options)

        # Put the replay_cmd, options and flavor of files to generate into a
        # directory because only one argument can be passed thru to the method
        # GenLitFiles(), but three arguments need to be given to this method.
        #
        # Set the flavor to LMAT file generation.
        #
        param = {
            'replay_cmd': replay_cmd,
            'options': options,
            'flavor': self.LMAT
        }

        # First generate LMAT files for each directory.
        #
        # import pdb;  pdb.set_trace()
        if hasattr(options, 'list') and not options.list:
            msg.PrintMsgDate('Generating LMAT files')
        for pdir in pp_dirs:
            if not options.list:
                msg.PrintMsgPlus(
                    'Generating LMAT files for pinballs in: ' + pdir)
            result = util.RunAllDir(pdir, self.GenLitFiles, True, param)
            if result != 0:
                msg.PrintMsg('Error found during LIT file generation (1)')
                return result

        # Need to wait until all the LMAT jobs are complete before the
        # LIT files are generated.
        #
        if hasattr(options, 'list') and not options.list:
            msg.PrintMsgPlus('Waiting on concurrent LMAT file generation')
        result = util.WaitJobs(options)
        if hasattr(options, 'list') and not options.list:
            msg.PrintMsgDate('Finished generating LMAT files')

        # Now set the flavor for LIT file generation.
        #
        param['flavor'] = self.LIT

        # Then generate LCAT files for each directory.
        #
        # import pdb;  pdb.set_trace()
        if hasattr(options, 'list') and not options.list:
            msg.PrintMsgDate('Generating LIT files')
        for pdir in pp_dirs:
            if hasattr(options, 'list') and not options.list:
                msg.PrintMsgPlus('Generating LIT files for pinballs in: ' + pdir)
            result = util.RunAllDir(pdir, self.GenLitFiles, True, param)
            if result != 0:
                msg.PrintMsg('Error found during LIT file generation (2)')
                return result

        # Need to wait until all the LIT jobs are complete before continuing.
        #
        if hasattr(options, 'list') and not options.list:
            msg.PrintMsgPlus('Waiting on concurrent LIT file generation')
        result = util.WaitJobs(options)
        if hasattr(options, 'list') and not options.list:
            msg.PrintMsgDate('Finished generating LIT files')

        return result
コード例 #7
0
ファイル: sde_pinpoints.py プロジェクト: mazalves/OrCS
    def RunAdditionalPhases(self, wp_pb_dir, sim_replay_cmd, options):
        """
        Run the additional phases for SDE which are not run for PinPlay.

        @param wp_pb_dir     Directory containing whole program log files (pinballs)
        @param sim_replay_cmd Python script used to replay a pinball with a simulator
        @param options Options given on cmd line

        @return Exit code from last phase executed
        """

        # The SDE phases object needs an SDE kit object.
        #
        s_phases = sde_phases.SDEPhases()
        kit_obj = self.GetKit()
        s_phases.SetKit(kit_obj)

        # Need the appropriate simulator kit too.
        #
        sim_kit = self.GetSimKit()

        # Generate LMAT/LIT files.
        #
        result = 0
        if options.lit_gen or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Generating traces for region pinballs %s' % \
                    config.PhaseStr(config.LIT))
            util.PhaseBegin(options)
            result = s_phases.GenAllLitFiles(self.replayer_cmd, options)
            #if result == 0:
            # if not options.list:
            #    msg.PrintMsgPlus('Waiting on final concurrent region pinball generation')
            # result = util.WaitJobs(options)
            if not options.list:
                msg.PrintMsgDate('Finished generating traces for region pinballs %s' % \
                    config.PhaseStr(config.LIT))
            util.CheckResult(result, options, 'Trace file generation %s' % \
                config.PhaseStr(config.LIT))

        # Generate traceinfo files.
        #
        if options.traceinfo or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Generating traceinfo files %s' % \
                    config.PhaseStr(config.traceinfo))
            util.PhaseBegin(options)
            result = s_phases.GenTraceinfoFiles(options)
            if not options.list:
                msg.PrintMsgDate('Finished generating traceinfo files %s' % \
                    config.PhaseStr(config.traceinfo))
            util.CheckResult(result, options, 'Traceinfo file generation %s' % \
                config.PhaseStr(config.traceinfo))

        # Run CMPSim simulator on region pinballs.
        #
        if options.region_sim or options.default_phases:
            # Print out CMPSim results every warmup_length instructions.
            #
            phase_length = options.warmup_length // config.instr_cmpsim_phase
            if phase_length == 0:
                phase_length = 1
            for pp_dir in util.GetRegionPinballDir():
                if not options.list:
                    msg.PrintMsgDate('Running CMPSim on region pinballs in dir: %s %s' % \
                        (pp_dir, config.PhaseStr(config.CMPsim_regions)))
                util.PhaseBegin(options)
                result = sim_kit.RunSimulator(pp_dir, sim_replay_cmd,
                                              phase_length, options)
                if not options.list:
                    msg.PrintMsgDate('Finished running CMPSim on region pinballs in dir %s %s' % \
                        (pp_dir, config.PhaseStr(config.CMPsim_regions)))
                util.CheckResult(result, options, 'CMPSim on pinballs, dir: %s %s' % \
                        (pp_dir, config.PhaseStr(config.CMPsim_regions)))

        # Run CMPSim simulator on whole program pinballs.
        #
        if options.whole_sim or options.default_phases:
            # Set phase_length to print out CMPSim results every slice_size instructions.
            #
            phase_length = options.slice_size // config.instr_cmpsim_phase
            if phase_length == 0:
                phase_length = 1
            if not options.list:
                msg.PrintMsgDate('Running CMPSim on whole program pinballs %s' % \
                    config.PhaseStr(config.CMPsim_whole))
            util.PhaseBegin(options)
            result = sim_kit.RunSimulator(wp_pb_dir, sim_replay_cmd,
                                          phase_length, options)
            if not options.list:
                msg.PrintMsgDate('Finished running CMPSim on whole program pinballs %s' % \
                    config.PhaseStr(config.CMPsim_whole))
            util.CheckResult(result, options, 'CMPSim on whole program pinballs %s' % \
                config.PhaseStr(config.CMPsim_whole))

        # Calculate prediction error from simulator data files.
        #
        if options.pred_error or options.default_phases:
            if not options.list:
                msg.PrintMsgDate('Calculating prediction error %s' % \
                    config.PhaseStr(config.pred_error))
            util.PhaseBegin(options)
            result = s_phases.CalcPredError(wp_pb_dir, sim_kit, options)
            if not options.list:
                msg.PrintMsgDate('Finished calculating prediction error %s' % \
                    config.PhaseStr(config.pred_error))
            util.CheckResult(result, options, 'Prediction error calculation %s' % \
                config.PhaseStr(config.pred_error))

        # Verify the LIT files with the simulator.
        #
        if options.verify:
            if not options.list:
                msg.PrintMsgDate('Verifying LIT files %s' % \
                    config.PhaseStr(config.verify_LIT))
            util.PhaseBegin(options)
            result = s_phases.VerifyLITFiles(self.sim_run_cmd, options)
            if not options.list:
                msg.PrintMsgDate('Finished verifying LIT files %s' % \
                    config.PhaseStr(config.verify_LIT))
            util.CheckResult(result, options, 'LIT file verification %s' % \
                config.PhaseStr(config.verify_LIT))

        # Generate instruction mix for the whole program pinballs.
        #
        if options.imix_whole:
            if not options.list:
                msg.PrintMsgDate('Generating imix on whole program pinballs  %s' % \
                    config.PhaseStr(config.imix_whole))
            # Setup dictionary of parameters for method RunAllDir()
            #
            param = {'options': options, 'replayer_cmd': self.replayer_cmd}
            util.PhaseBegin(options)
            result = util.RunAllDir(wp_pb_dir, s_phases.GenImix, True, param)
            if result == 0:
                if not options.list:
                    msg.PrintMsgPlus(
                        'Waiting on final whole program pinball imix generation'
                    )
                result = util.WaitJobs(options)
            if not options.list:
                msg.PrintMsgDate('Finished generating imix on whole program pinballs %s' % \
                    config.PhaseStr(config.imix_whole))
            util.CheckResult(result, options, 'Imix on whole program pinballs %s' % \
                config.PhaseStr(config.imix_whole))

        # Generate instruction mix for the LIT files.
        #
        if options.imix_lit:
            if not options.list:
                msg.PrintMsgDate('Generating imix on LIT files  %s' % \
                    config.PhaseStr(config.imix_lit))
            # Setup dictionary of parameters for method RunAllDir()
            #
            param = {'options': options, 'replayer_cmd': self.replayer_cmd}
            util.PhaseBegin(options)
            for lit_dir in util.GetLitDir():
                result = util.RunAllDir(lit_dir, s_phases.GenImix, True, param)
            if result == 0:
                if not options.list:
                    msg.PrintMsgPlus('Waiting on final LIT files generation')
                result = util.WaitJobs(options)
            if not options.list:
                msg.PrintMsgDate('Finished generating imix on LIT files %s' % \
                    config.PhaseStr(config.imix_lit))
            util.CheckResult(result, options, 'Imix on LIT files %s' % \
                config.PhaseStr(config.imix_lit))

        # Generate instruction mix for the region pinballs.
        #
        if options.imix_region:
            if not options.list:
                msg.PrintMsgDate('Generating imix on region pinballs  %s' % \
                    config.PhaseStr(config.imix_regions))
            # Setup dictionary of parameters for method RunAllDir()
            #
            param = {'options': options, 'replayer_cmd': self.replayer_cmd}
            util.PhaseBegin(options)
            for pp_dir in util.GetRegionPinballDir():
                result = util.RunAllDir(pp_dir, s_phases.GenImix, True, param)
            if result == 0:
                if not options.list:
                    msg.PrintMsgPlus(
                        'Waiting on final region pinballs generation')
                result = util.WaitJobs(options)
            if not options.list:
                msg.PrintMsgDate('Finished generating imix on region pinballs %s' % \
                    config.PhaseStr(config.imix_regions))
            util.CheckResult(result, options, 'Imix on region pinballs %s' % \
                config.PhaseStr(config.imix_regions))

        # Assume nothing has gone wrong at this point.
        #
        return result
コード例 #8
0
    def RunAdditionalPhases(self, wp_pb_dir, sim_replay_cmd, options):
        """Run the additional phases for SDE which are not run for PinPlay."""

        if not options.sniper_root or not os.path.exists(
                os.path.join(options.sniper_root, 'run-sniper')):
            msg.PrintMsgPlus(
                'ERROR: Please set SNIPER_ROOT or --sniper_root to a valid Sniper install.'
            )
            util.CheckResult(
                -1, options,
                'Checking for Sniper install location.')  # Force error with -1

        if options.region_sim or options.default_phases:
            # Print out Sniper results every warmup_length instructions.
            #
            for pp_dir in util.GetRegionPinballDir():
                phase_length = options.warmup_length // config.instr_cmpsim_phase
                if phase_length == 0:
                    phase_length = 1

                if not options.list:
                    msg.PrintMsgDate('Running Sniper on region pinballs %s' % \
                        config.PhaseStr(config.sniper_regions))
                util.PhaseBegin(options)
                result = RunSniper(pp_dir, sim_replay_cmd, phase_length,
                                   options)
                if not options.list:
                    msg.PrintMsgDate('Finished running Sniper on region pinballs %s' % \
                        config.PhaseStr(config.sniper_regions))
                util.CheckResult(result, options, 'Sniper on region pinballs %s' % \
                    config.PhaseStr(config.sniper_regions))

        if options.whole_sim or options.default_phases:
            # Set phase_length to print out Sniper results every slice_size instructions.
            #
            phase_length = options.slice_size // config.instr_cmpsim_phase
            if phase_length == 0:
                phase_length = 1

            if not options.list:
                msg.PrintMsgDate('Running Sniper on whole program pinballs %s' % \
                    config.PhaseStr(config.sniper_whole))
            util.PhaseBegin(options)
            result = RunSniper(wp_pb_dir, sim_replay_cmd, phase_length,
                               options)
            if not options.list:
                msg.PrintMsgDate('Finished running Sniper on whole program pinballs %s' % \
                    config.PhaseStr(config.sniper_whole))
            util.CheckResult(result, options, 'Sniper on whole program pinballs %s' % \
                    config.PhaseStr(config.sniper_whole))

        if options.pred_error or options.default_phases:
            if options.pccount_regions:
                msg.PrintMsg('\n Prediction with PCregions is NIY')
                return 0
            if not options.list:
                msg.PrintMsgDate('Calculating prediction error %s' % \
                    config.PhaseStr(config.pred_error))
            util.PhaseBegin(options)
            result = CalcPredError(wp_pb_dir, self.sim_replay_cmd, options)
            if not options.list:
                msg.PrintMsgDate('Finished calculating prediction error %s' % \
                    config.PhaseStr(config.pred_error))
            util.CheckResult(result, options, 'Prediction error calculation %s' % \
                    config.PhaseStr(config.pred_error))

        # Assume nothing has gone wrong at this point.
        #
        return 0
コード例 #9
0
ファイル: brpred_pinpoints.py プロジェクト: mazalves/OrCS
    def RunAdditionalPhases(self, wp_pb_dir, sim_replay_cmd, options):
        """
        Run the additional phases for the simulator which are not run as
        part of the usual PinPlay phases.
        """

        phases_obj = phases.Phases()
        self.sim_kit = self.GetSimKit()

        # Run branch predictor simulator on region pinballs.
        #
        if options.region_sim or options.default_phases:
            # Print out simulator results every warmup_length instructions.
            #
            for pp_dir in util.GetRegionPinballDir():
                phase_length = options.warmup_length
                if phase_length == 0:
                    phase_length = options.slice_size

                if not options.list:
                    msg.PrintMsgDate('Running simulator on region pinballs: %s' % \
                        config.PhaseStr(config.sim_regions))
                util.PhaseBegin(options)
                result = self.sim_kit.RunSimulator(pp_dir, sim_replay_cmd,
                                                   phase_length, options)
                if not options.list:
                    msg.PrintMsgDate('Finished running simulator on region pinballs: %s' % \
                        config.PhaseStr(config.sim_regions))
                util.CheckResult(result, options, 'simulator on region pinballs: %s' % \
                    config.PhaseStr(config.sim_regions))

        # Run branch predictor simulator on whole program pinballs.
        #
        if options.whole_sim or options.default_phases:
            # Set phase_length to print out simulator results every slice_size instructions.
            #
            phase_length = options.slice_size

            if not options.list:
                msg.PrintMsgDate('Running simulator on whole program pinballs: %s' % \
                    config.PhaseStr(config.sim_whole))
            util.PhaseBegin(options)
            result = self.sim_kit.RunSimulator(wp_pb_dir, sim_replay_cmd,
                                               phase_length, options)
            if not options.list:
                msg.PrintMsgDate('Finished running simulator on whole program pinballs: %s' % \
                    config.PhaseStr(config.sim_whole))
            util.CheckResult(result, options, 'simulator on whole program pinballs: %s' % \
                config.PhaseStr(config.sim_whole))

        # Calculate prediction error.
        #
        if options.pred_error or options.default_phases:
            if hasattr(options, 'pccount_regions') and options.pccount_regions:
                msg.PrintMsg('\n Prediction with PCregions is NIY')
                return 0
            if not options.list:
                msg.PrintMsgDate('Calculating prediction error: %s' % \
                    config.PhaseStr(config.pred_error))
            util.PhaseBegin(options)
            result = phases_obj.CalcPredError(wp_pb_dir, self.sim_kit, options)
            if not options.list:
                msg.PrintMsgDate('Finished calculating prediction error: %s' % \
                    config.PhaseStr(config.pred_error))
            util.CheckResult(result, options, 'Prediction error calculation: %s' % \
                config.PhaseStr(config.pred_error))
        # Assume nothing has gone wrong at this point.
        #
        return 0