1 /**************************************************************************************[ParallelSolver.h]
2 Glucose -- Copyright (c) 2009-2014, Gilles Audemard, Laurent Simon
3 CRIL - Univ. Artois, France
4 LRI - Univ. Paris Sud, France (2009-2013)
5 Labri - Univ. Bordeaux, France
7 Syrup (Glucose Parallel) -- Copyright (c) 2013-2014, Gilles Audemard, Laurent Simon
8 CRIL - Univ. Artois, France
9 Labri - Univ. Bordeaux, France
11 Glucose sources are based on MiniSat (see below MiniSat copyrights). Permissions and copyrights of
12 Glucose (sources until 2013, Glucose 3.0, single core) are exactly the same as Minisat on which it
13 is based on. (see below).
15 Glucose-Syrup sources are based on another copyright. Permissions and copyrights for the parallel
16 version of Glucose-Syrup (the "Software") are granted, free of charge, to deal with the Software
17 without restriction, including the rights to use, copy, modify, merge, publish, distribute,
18 sublicence, and/or sell copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
21 - The above and below copyrights notices and this permission notice shall be included in all
22 copies or substantial portions of the Software;
23 - The parallel version of Glucose (all files modified since Glucose 3.0 releases, 2013) cannot
24 be used in any competitive event (sat competitions/evaluations) without the express permission of
25 the authors (Gilles Audemard / Laurent Simon). This is also the case for any competitive event
26 using Glucose Parallel as an embedded SAT engine (single core or not).
29 --------------- Original Minisat Copyrights
31 Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
32 Copyright (c) 2007-2010, Niklas Sorensson
34 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
35 associated documentation files (the "Software"), to deal in the Software without restriction,
36 including without limitation the rights to use, copy, modify, merge, publish, distribute,
37 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
38 furnished to do so, subject to the following conditions:
40 The above copyright notice and this permission notice shall be included in all copies or
41 substantial portions of the Software.
43 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
44 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
45 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
46 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
47 OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48 **************************************************************************************************/
50 #ifndef PARALLELSOLVER_H
51 #define PARALLELSOLVER_H
53 #include "core/SolverTypes.h"
54 #include "core/Solver.h"
55 #include "simp/SimpSolver.h"
56 #include "parallel/SharedCompanion.h"
58 //=================================================================================================
60 //class SolverCompanion;
61 // class MultiSolvers;
63 class ParallelSolver : public SimpSolver {
64 friend class MultiSolvers;
65 friend class SolverCompanion;
66 friend class SharedCompanion;
67 // friend class ReasoningCompanion;
68 // friend class SolverConfiguration;
72 int thn; // internal thread number
73 //MultiSolvers* belongsto; // Not working (due to incomplete types)
74 SharedCompanion *sharedcomp;
75 bool coreFUIP; // true if one core is specialized for branching on all FUIP
77 pthread_mutex_t *pmfinished; // mutex on which main process may wait for... As soon as one process finishes it release the mutex
78 pthread_cond_t *pcfinished; // condition variable that says that a thread as finished
81 // Constructor/Destructor:
83 ParallelSolver(int threadId);
84 ParallelSolver(const ParallelSolver &s);
90 virtual Clone* clone() const {
91 return new ParallelSolver(*this);
94 int threadNumber () const;
95 void setThreadNumber (int i);
96 void reportProgress();
97 void reportProgressArrayImports(vec<unsigned int> &totalColumns);
98 virtual void reduceDB();
99 virtual lbool solve_ (bool do_simp = true, bool turn_off_simp = false);
101 vec<Lit> importedClause; // Temporary clause used to copy each imported clause
104 uint64_t nbexportedunit, nbimportedunit , nbimportedInPurgatory, nbImportedGoodClauses;
105 unsigned int goodlimitlbd; // LBD score of the "good" clauses, locally
107 bool purgatory; // mode of operation
108 bool shareAfterProbation; // Share any none glue clause only after probation (seen 2 times in conflict analysis)
109 bool plingeling; // plingeling strategy for sharing clauses (experimental)
112 uint64_t getNbExported() { return nbexported;}
113 uint64_t getNbImported() { return nbimported;}
114 uint64_t getNbExportedUnit() {return nbexportedunit;}
116 uint32_t firstSharing, limitSharingByGoodLBD, limitSharingByFixedLimitLBD, limitSharingByFixedLimitSize;
117 uint32_t probationByFollowingRoads, probationByFriend;
118 uint32_t survivorLayers; // Number of layers for a common clause to survive
119 bool dontExportDirectReusedClauses ; // When true, directly reused clauses are not exported
120 uint64_t nbNotExportedBecauseDirectlyReused;
123 vec<uint32_t> goodImportsFromThreads; // Stats of good importations from other threads
125 virtual void parallelImportClauseDuringConflictAnalysis(Clause &c,CRef confl);
126 virtual bool parallelImportClauses(); // true if the empty clause was received
127 virtual void parallelImportUnaryClauses();
128 virtual void parallelExportUnaryClause(Lit p);
129 virtual void parallelExportClauseDuringSearch(Clause &c);
130 virtual bool parallelJobIsFinished();
131 virtual bool panicModeIsEnabled();
133 bool shareClause(Clause & c); // true if the clause was succesfully sent
140 inline int ParallelSolver::threadNumber () const {return thn;}
141 inline void ParallelSolver::setThreadNumber (int i) {thn = i;}
143 #endif /* PARALLELSOLVER_H */