Search in sources :

Example 6 with VerificationTask

use of com.dat3m.dartagnan.verification.VerificationTask in project Dat3M by hernanponcedeleon.

the class ReachabilityResult method run.

private void run() {
    if (validate()) {
        ShutdownManager sdm = ShutdownManager.create();
        Thread t = new Thread(() -> {
            try {
                if (options.getTimeout() > 0) {
                    // Converts timeout from secs to millisecs
                    Thread.sleep(1000L * options.getTimeout());
                    sdm.requestShutdown("Shutdown Request");
                }
            } catch (InterruptedException e) {
            // Verification ended, nothing to be done.
            }
        });
        try {
            Result result = Result.UNKNOWN;
            Arch arch = program.getArch() != null ? program.getArch() : options.getTarget();
            VerificationTask task = VerificationTask.builder().withBound(options.getBound()).withSolverTimeout(options.getTimeout()).withTarget(arch).build(program, wmm, EnumSet.of(Property.getDefault()));
            t.start();
            Configuration config = Configuration.builder().setOption(PHANTOM_REFERENCES, "true").build();
            try (SolverContext ctx = SolverContextFactory.createSolverContext(config, BasicLogManager.create(config), sdm.getNotifier(), options.getSolver());
                ProverEnvironment prover = ctx.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
                switch(options.getMethod()) {
                    case INCREMENTAL:
                        result = IncrementalSolver.run(ctx, prover, task);
                        break;
                    case ASSUME:
                        result = AssumeSolver.run(ctx, prover, task);
                        break;
                    case TWO:
                        try (ProverEnvironment prover2 = ctx.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
                            result = TwoSolvers.run(ctx, prover, prover2, task);
                        }
                        break;
                    case CAAT:
                        result = RefinementSolver.run(ctx, prover, RefinementTask.fromVerificationTaskWithDefaultBaselineWMM(task));
                        break;
                }
                // Verification ended, we can interrupt the timeout Thread
                t.interrupt();
                buildVerdict(result);
            }
        } catch (InterruptedException e) {
            verdict = "TIMEOUT";
        } catch (Exception e) {
            verdict = "ERROR: " + e.getMessage();
        }
    }
}
Also used : SolverContext(org.sosy_lab.java_smt.api.SolverContext) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) Configuration(org.sosy_lab.common.configuration.Configuration) ShutdownManager(org.sosy_lab.common.ShutdownManager) Arch(com.dat3m.dartagnan.configuration.Arch) ProverEnvironment(org.sosy_lab.java_smt.api.ProverEnvironment) Result(com.dat3m.dartagnan.utils.Result)

Aggregations

VerificationTask (com.dat3m.dartagnan.verification.VerificationTask)6 Program (com.dat3m.dartagnan.program.Program)5 File (java.io.File)5 ProverEnvironment (org.sosy_lab.java_smt.api.ProverEnvironment)5 SolverContext (org.sosy_lab.java_smt.api.SolverContext)5 ProgramParser (com.dat3m.dartagnan.parsers.program.ProgramParser)4 Test (org.junit.Test)4 Configuration (org.sosy_lab.common.configuration.Configuration)4 ParserCat (com.dat3m.dartagnan.parsers.cat.ParserCat)3 Result (com.dat3m.dartagnan.utils.Result)3 Wmm (com.dat3m.dartagnan.wmm.Wmm)3 IOException (java.io.IOException)2 ShutdownManager (org.sosy_lab.common.ShutdownManager)2 Arch (com.dat3m.dartagnan.configuration.Arch)1 OptionInfo.collectOptions (com.dat3m.dartagnan.configuration.OptionInfo.collectOptions)1 PHANTOM_REFERENCES (com.dat3m.dartagnan.configuration.OptionNames.PHANTOM_REFERENCES)1 Property (com.dat3m.dartagnan.configuration.Property)1 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)1 ParserWitness (com.dat3m.dartagnan.parsers.witness.ParserWitness)1 SourceLanguage (com.dat3m.dartagnan.program.Program.SourceLanguage)1