示例#1
0
        private List <PredictorInfo> getPredictorRequests(PredictorTypeInfo predictorInfoType)
        {
            List <PredictorInfo> predictorInfo = new List <PredictorInfo>();

            // cartesian product for all valid and unique property values
            int propertyCount = predictorInfoType.PredictorProperties.Count;

            List <object>[] propertyValues = new List <object> [propertyCount];

            int index = 0;

            foreach (var property in predictorInfoType.PredictorProperties)
            {
                propertyValues[index] = property.loadValuesFromUI();
                index++;
            }

            int[] valueIndex = new int[propertyCount];
            for (index = 0; index < propertyCount; index++)
            {
                valueIndex[index] = -1;
            }

            index = 0;
            while (index >= 0)
            {
                valueIndex[index]++;

                if (valueIndex[index] == propertyValues[index].Count)
                {
                    index--;  // backtrack
                }
                else
                {
                    if (index == propertyCount - 1) // found a solution
                    {
                        object[] predictorArguments = new object[propertyCount];
                        for (int k = 0; k < propertyCount; k++)
                        {
                            predictorArguments[k] = propertyValues[k][valueIndex[k]];
                        }
                        string description = predictorInfoType.DisplayName + " (" + predictorInfoType.PredictorProperties[0].DisplayName + " = " + propertyValues[0][valueIndex[0]].ToString();
                        for (int k = 1; k < propertyCount; k++)
                        {
                            description += ", " + predictorInfoType.PredictorProperties[k].DisplayName + " = " + propertyValues[k][valueIndex[k]].ToString();
                        }
                        description += ")";

                        predictorInfo.Add(new PredictorInfo(predictorInfoType.PredictorType, description, this.AppOptions, predictorArguments));
                    }
                    else
                    {
                        index++; // forward track
                        valueIndex[index] = -1;
                    }
                }
            }

            return(predictorInfo);
        }
示例#2
0
        private void simulate_Click(object sender, RoutedEventArgs e)
        {
            List <PredictorInfo> predictorRequests;

            if (!this.AppOptions.IsPredictorCompareMode)
            {
                PredictorTypeInfo predictorType = (PredictorTypeInfo)PredictorTypesListBox.SelectedItem;
                predictorRequests = getPredictorRequests(predictorType);
            }
            else
            {
                predictorRequests = new List <PredictorInfo>();
                foreach (PredictorTypeInfo predictorTypeInfo in predictorTypeList)
                {
                    if (predictorTypeInfo.IsChecked)
                    {
                        predictorRequests.AddRange(getPredictorRequests(predictorTypeInfo));
                    }
                }
            }

            // Stanford
            var stanfordTraceQuery = from trace in stanfordTraces
                                     where trace.Selected
                                     select trace.Filename;

            // SPEC2000
            var spec2000TraceQuery = from trace in spec2000Traces
                                     where trace.Selected
                                     select trace.Filename;

            // CBP 2
            var CBP2TraceQuery = from trace in cbp2Traces
                                 where trace.Selected
                                 select trace.Filename;

            int numberOfSelectedTraces = stanfordTraceQuery.Count() + spec2000TraceQuery.Count() + CBP2TraceQuery.Count();

            if (numberOfSelectedTraces == 0)
            {
                displayedResults.Add(new ResultListMessage("(no traces selected)"));
                return;
            }
            if (predictorRequests.Count == 0)
            {
                displayedResults.Add(new ResultListMessage("(no predictors selected)"));
                return;
            }

            // start the simulation

            simulationResultsDictionary.Clear();
            simulationQueue.Clear();

            foreach (string traceFilename in stanfordTraceQuery)
            {
                simulationResultsDictionary.addBenchmark(new BenchmarkInfo(traceFilename, BenchmarkType.Stanford));
            }
            foreach (string traceFilename in spec2000TraceQuery)
            {
                simulationResultsDictionary.addBenchmark(new BenchmarkInfo(traceFilename, BenchmarkType.SPEC2000));
            }
            foreach (string traceFilename in CBP2TraceQuery)
            {
                simulationResultsDictionary.addBenchmark(new BenchmarkInfo(traceFilename, BenchmarkType.CBP2));
            }

            foreach (PredictorInfo predictorRequest in predictorRequests)
            {
                foreach (BenchmarkInfo benchmarkInfo in simulationResultsDictionary.Benchmarks)
                {
                    simulationQueue.Enqueue(new SimulationInfo(predictorRequest, benchmarkInfo));
                }
            }

            displayedResults.Add(new ResultListMessage("Starting " + simulationQueue.Count + " simulations on " + predictorRequests.Count + " predictor versions"));

            foreach (PredictorInfo predictorInfo in predictorRequests)
            {
                BenchmarkStatisticsCollection benchmarkStatisticsCollection = simulationResultsDictionary.addPredictor(predictorInfo);

                displayedResults.Add(new ResultListMessage("Simulation using " + predictorInfo.description));
                displayedResults.Add(benchmarkStatisticsCollection);
            }

            simulationResultsDictionary.initialize();

            // start worker threads
            this.startWork();
        }