示例#1
0
 public ConcurrentHoudini(int taskId, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.txt")
 {
     Contract.Assert(taskId >= 0);
     this.program      = program;
     this.cexTraceFile = cexTraceFile;
     this.taskID       = taskId;
     Initialize(program, stats);
 }
示例#2
0
        public void Start(Program program, ref Houdini.HoudiniOutcome outcome)
        {
            if (this.Solver.Equals(CVC4))
            {
                if (CommandLineOptions.Clo.Cho[this.ID].ProverOptions.Contains("LOGIC=QF_ALL_SUPPORTED") &&
                    CheckForQuantifiers.Found(program))
                {
                    CommandLineOptions.Clo.Cho[this.ID].ProverOptions.Remove("LOGIC=QF_ALL_SUPPORTED");
                    CommandLineOptions.Clo.Cho[this.ID].ProverOptions.Add("LOGIC=ALL_SUPPORTED");
                }
            }

            Print.VerboseMessage("[CRUNCHER] Engine " + this.GetType().Name + " started");

            ModifyProgramBeforeCrunch(program);

            Houdini.HoudiniSession.HoudiniStatistics houdiniStats = new Houdini.HoudiniSession.HoudiniStatistics();

            if (CommandLineOptions.Clo.StagedHoudini != null)
            {
                // This is an initial attempt at hooking GPUVerify up with Staged Houdini.
                // More work is required to make this compatible with other cruncher options,
                // and we start with a couple of crude hacks to work around the fact that
                // Staged Houdini is not integrated with ConcurrentHoudini.

                CommandLineOptions.Clo.ConcurrentHoudini = false;           // HACK - requires proper integration
                CommandLineOptions.Clo.ProverCCLimit     = this.ErrorLimit; // HACK - requires proper integration
                Debug.Assert(outcome == null);
                Debug.Assert(this is VanillaHoudini);

                Houdini.StagedHoudini houdini = new Houdini.StagedHoudini(program, houdiniStats, ExecutionEngine.ProgramFromFile);

                outcome = houdini.PerformStagedHoudiniInference();
            }
            else
            {
                string filename = "houdiniCexTrace_" + this.ID + ".bpl";
                houdini = new Houdini.ConcurrentHoudini(this.ID, program, houdiniStats, filename);

                if (outcome != null)
                {
                    outcome = houdini.PerformHoudiniInference(initialAssignment: outcome.assignment);
                }
                else
                {
                    outcome = houdini.PerformHoudiniInference();
                }
            }

            Print.VerboseMessage("[CRUNCHER] Engine " + this.GetType().Name + " finished");

            if (((GPUVerifyCruncherCommandLineOptions)CommandLineOptions.Clo).DebugConcurrentHoudini)
            {
                OutputResults(outcome, houdiniStats);
            }
        }
示例#3
0
        private void OutputResults(Houdini.HoudiniOutcome outcome, Houdini.HoudiniSession.HoudiniStatistics houdiniStats)
        {
            int numTrueAssigns = outcome.assignment.Where(x => x.Value).Count();

            Console.WriteLine("Number of true assignments          = " + numTrueAssigns);
            Console.WriteLine("Number of false assignments         = " + (outcome.assignment.Count - numTrueAssigns));
            Console.WriteLine("Prover time                         = " + houdiniStats.proverTime.ToString("F2"));
            Console.WriteLine("Unsat core prover time              = " + houdiniStats.unsatCoreProverTime.ToString("F2"));
            Console.WriteLine("Number of prover queries            = " + houdiniStats.numProverQueries);
            Console.WriteLine("Number of unsat core prover queries = " + houdiniStats.numUnsatCoreProverQueries);
            Console.WriteLine("Number of unsat core prunings       = " + houdiniStats.numUnsatCorePrunings);
        }
示例#4
0
        public StagedHoudini(Program program, HoudiniSession.HoudiniStatistics houdiniStats,
                             Func <string, Program> ProgramFromFile)
        {
            this.program          = program;
            this.houdiniStats     = houdiniStats;
            this.ProgramFromFile  = ProgramFromFile;
            this.houdiniInstances = new List <Houdini> [CommandLineOptions.Clo.StagedHoudiniThreads];
            for (int i = 0; i < CommandLineOptions.Clo.StagedHoudiniThreads; i++)
            {
                houdiniInstances[i] = new List <Houdini>();
            }

            BreakApartConjunctionsInAnnotations();

            var annotationDependenceAnalyser = new AnnotationDependenceAnalyser(program);

            annotationDependenceAnalyser.Analyse();
            this.plan = annotationDependenceAnalyser.ApplyStages();
            if (CommandLineOptions.Clo.Trace)
            {
                annotationDependenceAnalyser.dump();

                if (CommandLineOptions.Clo.DebugStagedHoudini)
                {
                    Console.WriteLine("Plan\n====\n");
                    if (plan == null)
                    {
                        Console.WriteLine("No plan, as there were no stages");
                    }
                    else
                    {
                        Console.WriteLine(this.plan);
                    }
                }

                EmitProgram("staged.bpl");
            }
        }
示例#5
0
        private static PipelineOutcome RunStagedHoudini(Program program, PipelineStatistics stats, ErrorReporterDelegate er)
        {
            Houdini.HoudiniSession.HoudiniStatistics houdiniStats = new Houdini.HoudiniSession.HoudiniStatistics();
              Houdini.StagedHoudini stagedHoudini = new Houdini.StagedHoudini(program, houdiniStats, ProgramFromFile);
              Houdini.HoudiniOutcome outcome = stagedHoudini.PerformStagedHoudiniInference();

              if (CommandLineOptions.Clo.PrintAssignment)
              {
            Console.WriteLine("Assignment computed by Houdini:");
            foreach (var x in outcome.assignment)
            {
              Console.WriteLine(x.Key + " = " + x.Value);
            }
              }

              if (CommandLineOptions.Clo.Trace)
              {
            int numTrueAssigns = 0;
            foreach (var x in outcome.assignment)
            {
              if (x.Value)
            numTrueAssigns++;
            }
            Console.WriteLine("Number of true assignments = " + numTrueAssigns);
            Console.WriteLine("Number of false assignments = " + (outcome.assignment.Count - numTrueAssigns));
            Console.WriteLine("Prover time = " + houdiniStats.proverTime.ToString("F2"));
            Console.WriteLine("Unsat core prover time = " + houdiniStats.unsatCoreProverTime.ToString("F2"));
            Console.WriteLine("Number of prover queries = " + houdiniStats.numProverQueries);
            Console.WriteLine("Number of unsat core prover queries = " + houdiniStats.numUnsatCoreProverQueries);
            Console.WriteLine("Number of unsat core prunings = " + houdiniStats.numUnsatCorePrunings);
              }

              foreach (Houdini.VCGenOutcome x in outcome.implementationOutcomes.Values)
              {
            ProcessOutcome(x.outcome, x.errors, "", stats, Console.Out, CommandLineOptions.Clo.ProverKillTime, er);
            ProcessErrors(x.errors, x.outcome, Console.Out, er);
              }

              return PipelineOutcome.Done;
        }
示例#6
0
        public ConcurrentHoudini(int id, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.bpl")
        {
            Contract.Assert(id >= 0);

            this.id           = id;
            this.program      = program;
            this.cexTraceFile = cexTraceFile;

            if (CommandLineOptions.Clo.Trace)
            {
                Console.WriteLine("Collecting existential constants...");
            }
            this.houdiniConstants = CollectExistentialConstants();

            if (CommandLineOptions.Clo.Trace)
            {
                Console.WriteLine("Building call graph...");
            }
            this.callGraph = Program.BuildCallGraph(program);
            if (CommandLineOptions.Clo.Trace)
            {
                Console.WriteLine("Number of implementations = {0}", callGraph.Nodes.Count);
            }

            if (CommandLineOptions.Clo.HoudiniUseCrossDependencies)
            {
                if (CommandLineOptions.Clo.Trace)
                {
                    Console.WriteLine("Computing procedure cross dependencies ...");
                }
                this.crossDependencies = new CrossDependencies(this.houdiniConstants);
                this.crossDependencies.Visit(program);
            }

            Inline();

            this.vcgen           = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List <Checker>());
            this.proverInterface = ProverInterface.CreateProver(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, CommandLineOptions.Clo.ProverKillTime, id);

            vcgenFailures = new HashSet <Implementation>();
            Dictionary <Implementation, HoudiniSession> houdiniSessions = new Dictionary <Implementation, HoudiniSession>();

            if (CommandLineOptions.Clo.Trace)
            {
                Console.WriteLine("Beginning VC generation for Houdini...");
            }
            foreach (Implementation impl in callGraph.Nodes)
            {
                try {
                    if (CommandLineOptions.Clo.Trace)
                    {
                        Console.WriteLine("Generating VC for {0}", impl.Name);
                    }
                    HoudiniSession session = new HoudiniSession(this, vcgen, proverInterface, program, impl, stats, taskID: id);
                    houdiniSessions.Add(impl, session);
                }
                catch (VCGenException) {
                    if (CommandLineOptions.Clo.Trace)
                    {
                        Console.WriteLine("VC generation failed");
                    }
                    vcgenFailures.Add(impl);
                }
            }
            this.houdiniSessions = new ReadOnlyDictionary <Implementation, HoudiniSession>(houdiniSessions);

            if (CommandLineOptions.Clo.ExplainHoudini)
            {
                // Print results of ExplainHoudini to a dotty file
                explainHoudiniDottyFile = new StreamWriter("explainHoudini.dot");
                explainHoudiniDottyFile.WriteLine("digraph explainHoudini {");
                foreach (var constant in houdiniConstants)
                {
                    explainHoudiniDottyFile.WriteLine("{0} [ label = \"{0}\" color=black ];", constant.Name);
                }
                explainHoudiniDottyFile.WriteLine("TimeOut [label = \"TimeOut\" color=red ];");
            }
        }