示例#1
0
        public Scheduler(List <string> fileNames)
        {
            this.fileNames = fileNames;

            Pipeline pipeline = ((GPUVerifyCruncherCommandLineOptions)CommandLineOptions.Clo).Pipeline;

            if (pipeline.RunHoudini)
            {
                pipeline.AddHoudiniEngine();
            }

            Houdini.HoudiniOutcome outcome;

            // Execute the engine pipeline in sequence or in parallel
            if (pipeline.Sequential)
            {
                outcome = ScheduleEnginesInSequence(pipeline);
            }
            else
            {
                outcome = ScheduleEnginesInParallel(pipeline);
            }

            // If Houdini has been invoked then apply the invariants to the program.
            // Otherwise report success
            if (pipeline.RunHoudini)
            {
                var     counters = default(KernelAnalyser.ResultCounter);
                Program prog     = GetFreshProgram(true, true);
                foreach (var implOutcome in outcome.implementationOutcomes)
                {
                    KernelAnalyser.ProcessOutcome(
                        prog, implOutcome.Key, implOutcome.Value.outcome, implOutcome.Value.errors, string.Empty, ref counters);
                }

                if (counters.AllVerified())
                {
                    GPUVerify.Utilities.IO.EmitProgram(ApplyInvariants(outcome), GetFileNameBase(), "cbpl");
                }

                ErrorCode = KernelAnalyser.GetExitCode(counters);
            }
            else
            {
                ErrorCode = (int)ToolExitCodes.SUCCESS;
            }

            if (((GPUVerifyCruncherCommandLineOptions)CommandLineOptions.Clo).WriteKilledInvariantsToFile)
            {
                DumpKilledInvariants(pipeline.ToString());
            }
        }
        private static ResultCounter VerifyProgram(Program program)
        {
            var counters = new ResultCounter();

            ConditionGeneration vcgen = null;

            try {
                vcgen = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List <Checker>());
            }
            catch (ProverException e) {
                GVUtil.IO.ErrorWriteLine("Fatal Error: ProverException: {0}", e);
                return(ResultCounter.GetNewCounterWithInternalError());
            }

            // operate on a stable copy, in case it gets updated while we're running
            var decls = program.TopLevelDeclarations.ToArray();

            foreach (Declaration decl in decls)
            {
                Contract.Assert(decl != null);

                int prevAssertionCount = vcgen.CumulativeAssertionCount;

                Implementation impl = decl as Implementation;
                if (impl != null && CommandLineOptions.Clo.UserWantsToCheckRoutine(cce.NonNull(impl.Name)) && !impl.SkipVerification)
                {
                    List <Counterexample /*!*/> /*?*/ errors;

                    DateTime start = new DateTime(); // to please compiler's definite assignment rules
                    if (CommandLineOptions.Clo.Trace)
                    {
                        start = DateTime.UtcNow;
                        if (CommandLineOptions.Clo.Trace)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Verifying {0} ...", impl.Name);
                        }
                    }

                    VCGen.Outcome outcome;
                    try {
                        outcome = vcgen.VerifyImplementation(impl, out errors);
                    }
                    catch (VCGenException e) {
                        GVUtil.IO.ReportBplError(impl, string.Format("Error BP5010: {0}  Encountered in implementation {1}.", e.Message, impl.Name), true, true);
                        errors  = null;
                        outcome = VCGen.Outcome.Inconclusive;
                    }
                    catch (UnexpectedProverOutputException upo) {
                        GVUtil.IO.AdvisoryWriteLine("Advisory: {0} SKIPPED because of internal error: unexpected prover output: {1}", impl.Name, upo.Message);
                        errors  = null;
                        outcome = VCGen.Outcome.Inconclusive;
                    }

                    string   timeIndication = "";
                    DateTime end            = DateTime.UtcNow;
                    TimeSpan elapsed        = end - start;
                    if (CommandLineOptions.Clo.Trace)
                    {
                        int poCount = vcgen.CumulativeAssertionCount - prevAssertionCount;
                        timeIndication = string.Format("  [{0:F3} s, {1} proof obligation{2}]  ", elapsed.TotalSeconds, poCount, poCount == 1 ? "" : "s");
                    }
                    KernelAnalyser.ProcessOutcome(program, impl.Name, outcome, errors, timeIndication, ref counters);

                    if (outcome == VCGen.Outcome.Errors || CommandLineOptions.Clo.Trace)
                    {
                        Console.Out.Flush();
                    }
                }
            }

            vcgen.Close();
            cce.NonNull(CommandLineOptions.Clo.TheProverFactory).Close();

            GVUtil.IO.WriteTrailer(counters);
            return(counters);
        }