LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory - ee_manager_distributed.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 42 43 97.7 %
Date: 2025-01-14 12:45:38 Functions: 5 5 100.0 %
Branches: 20 34 58.8 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Andrew Reynolds
       4                 :            :  *
       5                 :            :  * This file is part of the cvc5 project.
       6                 :            :  *
       7                 :            :  * Copyright (c) 2009-2024 by the authors listed in the file AUTHORS
       8                 :            :  * in the top-level source directory and their institutional affiliations.
       9                 :            :  * All rights reserved.  See the file COPYING in the top-level source
      10                 :            :  * directory for licensing information.
      11                 :            :  * ****************************************************************************
      12                 :            :  *
      13                 :            :  * Management of a distributed approach for equality sharing.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "theory/ee_manager_distributed.h"
      17                 :            : 
      18                 :            : #include "theory/quantifiers_engine.h"
      19                 :            : #include "theory/shared_solver.h"
      20                 :            : #include "theory/theory_engine.h"
      21                 :            : #include "theory/uf/equality_engine.h"
      22                 :            : 
      23                 :            : namespace cvc5::internal {
      24                 :            : namespace theory {
      25                 :            : 
      26                 :      50345 : EqEngineManagerDistributed::EqEngineManagerDistributed(Env& env,
      27                 :            :                                                        TheoryEngine& te,
      28                 :      50345 :                                                        SharedSolver& shs)
      29                 :      50345 :     : EqEngineManager(env, te, shs), d_masterEENotify(nullptr)
      30                 :            : {
      31                 :      50345 : }
      32                 :            : 
      33                 :     100178 : EqEngineManagerDistributed::~EqEngineManagerDistributed()
      34                 :            : {
      35                 :     100178 : }
      36                 :            : 
      37                 :      50345 : void EqEngineManagerDistributed::initializeTheories()
      38                 :            : {
      39                 :      50345 :   context::Context* c = context();
      40                 :            :   // initialize the shared solver
      41                 :     100690 :   EeSetupInfo esis;
      42         [ +  - ]:      50345 :   if (d_sharedSolver.needsEqualityEngine(esis))
      43                 :            :   {
      44                 :            :     // allocate an equality engine for the shared terms database
      45                 :      50345 :     d_stbEqualityEngine.reset(allocateEqualityEngine(esis, c));
      46                 :      50345 :     d_sharedSolver.setEqualityEngine(d_stbEqualityEngine.get());
      47                 :            :   }
      48                 :            :   else
      49                 :            :   {
      50                 :          0 :     Unhandled() << "Expected shared solver to use equality engine";
      51                 :            :   }
      52                 :            : 
      53                 :      50345 :   const LogicInfo& logicInfo = d_env.getLogicInfo();
      54         [ +  + ]:      50345 :   if (logicInfo.isQuantified())
      55                 :            :   {
      56                 :            :     // construct the master equality engine
      57 [ -  + ][ -  + ]:      43169 :     Assert(d_masterEqualityEngine == nullptr);
                 [ -  - ]
      58                 :      43169 :     QuantifiersEngine* qe = d_te.getQuantifiersEngine();
      59 [ -  + ][ -  + ]:      43169 :     Assert(qe != nullptr);
                 [ -  - ]
      60                 :      43169 :     d_masterEENotify.reset(new quantifiers::MasterNotifyClass(qe));
      61                 :      86338 :     d_masterEqualityEngine = std::make_unique<eq::EqualityEngine>(
      62                 :     129507 :         d_env, c, *d_masterEENotify.get(), "theory::master", false);
      63                 :            :   }
      64                 :            :   // allocate equality engines per theory
      65                 :     755175 :   for (TheoryId theoryId = theory::THEORY_FIRST;
      66         [ +  + ]:     755175 :        theoryId != theory::THEORY_LAST;
      67                 :     704830 :        ++theoryId)
      68                 :            :   {
      69                 :     704830 :     Theory* t = d_te.theoryOf(theoryId);
      70         [ -  + ]:     704830 :     if (t == nullptr)
      71                 :            :     {
      72                 :            :       // theory not active, skip
      73                 :     151066 :       continue;
      74                 :            :     }
      75                 :            :     // always allocate an object in d_einfo here
      76                 :     704830 :     EeTheoryInfo& eet = d_einfo[theoryId];
      77                 :     704830 :     EeSetupInfo esi;
      78         [ +  + ]:     704830 :     if (!t->needsEqualityEngine(esi))
      79                 :            :     {
      80                 :            :       // the theory said it doesn't need an equality engine, skip
      81                 :     100721 :       continue;
      82                 :            :     }
      83         [ +  + ]:     604109 :     if (esi.d_useMaster)
      84                 :            :     {
      85                 :            :       // the theory said it wants to use the master equality engine
      86                 :      50345 :       eet.d_usedEe = d_masterEqualityEngine.get();
      87                 :      50345 :       continue;
      88                 :            :     }
      89                 :            :     // allocate the equality engine
      90                 :     553764 :     eet.d_allocEe.reset(allocateEqualityEngine(esi, c));
      91                 :            :     // the theory uses the equality engine
      92                 :     553764 :     eet.d_usedEe = eet.d_allocEe.get();
      93                 :            :     // if there is a master equality engine
      94         [ +  + ]:     553764 :     if (d_masterEqualityEngine != nullptr)
      95                 :            :     {
      96                 :            :       // set the master equality engine of the theory's equality engine
      97                 :     474859 :       eet.d_allocEe->setMasterEqualityEngine(d_masterEqualityEngine.get());
      98                 :            :     }
      99                 :            :   }
     100                 :      50345 : }
     101                 :            : 
     102                 :      24295 : void EqEngineManagerDistributed::notifyModel(bool incomplete)
     103                 :            : {
     104                 :            :   // should have a consistent master equality engine
     105         [ +  + ]:      24295 :   if (d_masterEqualityEngine.get() != nullptr)
     106                 :            :   {
     107 [ -  + ][ -  + ]:      18876 :     AlwaysAssert(d_masterEqualityEngine->consistent());
                 [ -  - ]
     108                 :            :   }
     109                 :      24295 : }
     110                 :            : 
     111                 :            : }  // namespace theory
     112                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14