Пример #1
0
        public void setResult(PredictorInfo predictor, BenchmarkInfo benchmark, BenchmarkStatisticsResult value)
        {
            int predictorIndex;
            int benchmarkIndex;

            if (!predictorIndexMap.TryGetValue(predictor, out predictorIndex))
            {
                throw new Exception("Invalid predictor provided.");
            }
            if (!benchmarkIndexMap.TryGetValue(benchmark, out benchmarkIndex))
            {
                throw new Exception("Invalid simulator provided.");
            }
            if ((value != null) && (resultMatrix[predictorIndex, benchmarkIndex] == null))
            {
                valuesEntered++;
                observableCollections[predictor].addSorted(value);
                if (newValueReceived != null)
                {
                    newValueReceived(this, new SimulationResultsDictionaryNewValueReceivedEventArgs(predictorIndex, benchmarkIndex, value, observableCollections[predictor]));
                }
            }
            else
            {
                throw new NotSupportedException();
            }

            resultMatrix[predictorIndex, benchmarkIndex] = value;

            if ((valuesEntered == numberOfPredictors * numberOfBenchmarks) && (filled != null))
            {
                filled(this, EventArgs.Empty);
            }
        }
Пример #2
0
 public BenchmarkStatisticsCollection addPredictor(PredictorInfo predictor)
 {
     try
     {
         predictorIndexMap.Add(predictor, numberOfPredictors++);
         BenchmarkStatisticsCollection benchmarkStatisticsCollection = new BenchmarkStatisticsCollection();
         observableCollections.Add(predictor, benchmarkStatisticsCollection);
         return(benchmarkStatisticsCollection);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Пример #3
0
        public BenchmarkStatisticsResult getResult(PredictorInfo predictor, BenchmarkInfo benchmark)
        {
            int predictorIndex;
            int benchmarkIndex;

            if (!predictorIndexMap.TryGetValue(predictor, out predictorIndex))
            {
                throw new Exception("Invalid predictor provided.");
            }
            if (!benchmarkIndexMap.TryGetValue(benchmark, out benchmarkIndex))
            {
                throw new Exception("Invalid simulator provided.");
            }
            return(resultMatrix[predictorIndex, benchmarkIndex]);
        }
Пример #4
0
 public SimulationInfo(PredictorInfo predictorInfo, string benchmarkName, BenchmarkType benchmarkType)
 {
     this.predictorInfo = predictorInfo;
     this.benchmarkInfo = new BenchmarkInfo(benchmarkName, benchmarkType);
 }
Пример #5
0
 public SimulationInfo(PredictorInfo predictorInfo, BenchmarkInfo benchmarkInfo)
 {
     this.predictorInfo = predictorInfo;
     this.benchmarkInfo = benchmarkInfo;
 }
Пример #6
0
        public static BenchmarkStatisticsResult simulate(PredictorInfo predictorInfo, BenchmarkInfo benchmarkInfo, SimulationOptions simulationParameters, ApplicationOptions applicationOptions)
        {
            if (simulationParameters == null)
            {
                simulationParameters = SimulationOptions.defaultOptions;
            }

            string       folder      = "";
            ITraceReader traceReader = null;
            BenchmarkStatisticsResult currentResult = null;

            switch (benchmarkInfo.benchmarkType)
            {
            case BenchmarkType.Stanford:
                folder      = applicationOptions.TracePathStanford;
                traceReader = new StanfordReader();
                break;

            case BenchmarkType.SPEC2000:
                folder      = applicationOptions.TracePathSpec2000;
                traceReader = new Spec2000Reader();
                break;

            case BenchmarkType.CBP2:
                folder      = applicationOptions.TracePathCBP2;
                traceReader = new CBP2Reader();
                break;
            }

            // obtain predictor
            IPredictor predictor = predictorInfo.getPredictor();

            if (predictor == null)
            {
                return(new BenchmarkStatisticsResult(benchmarkInfo.benchmarkName + " - Could not be performed: The predictor could not be instantiated on the client."));
            }

            // open the trace file
            if (!traceReader.openTrace(folder, benchmarkInfo.benchmarkName))
            {
                return(new BenchmarkStatisticsResult(benchmarkInfo.benchmarkName + " - Could not be performed: The trace file could not be opened on the client."));
            }

            // create new entry
            currentResult = new BenchmarkStatisticsResult(benchmarkInfo.benchmarkName);
            currentResult.NumberOfCorrectPredictions   = 0;
            currentResult.NumberOfIncorrectPredictions = 0;


            // check if we should skip N branches when counting the performance (to avoid accounting for the predictor warmup)
            int branchIndex            = 0;
            int numberOfBranchesToSkip = simulationParameters.NumberOfBranchesToSkip;

            while (true)
            {
                // get the next branch
                IBranch branch = traceReader.getNextBranch();

                // null means trace end
                if (branch == null)
                {
                    break;
                }

                BranchInfo currentJumpInfo = branch.getBranchInfo();
                if (!simulationParameters.ConditionalOnly || ((branch.getBranchInfo().branchFlags & BranchInfo.BR_CONDITIONAL) > 0))
                {
                    // predict
                    bool prediction = predictor.predictBranch(branch.getBranchInfo());

                    if (branchIndex >= numberOfBranchesToSkip)
                    {
                        if (branch.taken() == prediction)
                        {
                            currentResult.NumberOfCorrectPredictions++;
                        }
                        else
                        {
                            currentResult.NumberOfIncorrectPredictions++;
                        }
                    }

                    // update the predictor
                    predictor.update(branch);

                    branchIndex++;
                }
            }

            traceReader.closeTrace();

            currentResult.NumberOfBranches = currentResult.NumberOfCorrectPredictions + currentResult.NumberOfIncorrectPredictions;
            currentResult.Accuracy         = (double)currentResult.NumberOfCorrectPredictions / currentResult.NumberOfBranches;

            // free the predictor instance for future reusability
            predictorInfo.freePredictor(predictor);

            return(currentResult);
        }
Пример #7
0
 public BenchmarkStatisticsCollection getResultCollectionForPredictor(PredictorInfo predictor)
 {
     return(observableCollections[predictor]);
 }