3#include "GlobalSharingStrategy.hpp"
4#include "containers/Bitset.hpp"
5#include "containers/ClauseUtils.hpp"
10 int32_t productionEpoch;
39 unsigned long baseBufferSize,
40 unsigned long maxBufferSize,
43 unsigned int roundsPerSecond,
44 float maxCompensation,
46 unsigned int resharePeriodMicroSec);
93 bool exportClauseToClient(
const ClauseExchangePtr& clause, std::shared_ptr<SharingEntity> client)
override;
110 std::vector<int>& result,
111 size_t& nonFreeLiteralsCount);
141 std::vector<std::reference_wrapper<std::vector<int>>>
buffers;
186 unsigned int sharingsPerSecond,
187 unsigned int maxProducerId = 63);
265 unsigned m_sharingPerSecond;
266 unsigned m_maxProducerId;
268 int m_resharingPeriodInEpochs;
276 std::unordered_map<ClauseExchangePtr,
A class representing a bitset with dynamic size.
Definition Bitset.hpp:14
Base class for global clause sharing strategies across MPI processes.
Definition GlobalSharingStrategy.hpp:27
Implements a global sharing strategy based on the Mallob algorithm.
Definition MallobSharing.hpp:25
unsigned int defaultBufferSize
Default size of the sharing buffer.
Definition MallobSharing.hpp:137
std::vector< int > receivedClausesFather
Buffer for clauses received from parent.
Definition MallobSharing.hpp:146
bool exportClauseToClient(const ClauseExchangePtr &clause, std::shared_ptr< SharingEntity > client) override
Exports a clause to a specific client.
std::vector< ClauseExchangePtr > deserializedClauses
Buffer for deserialized clauses.
Definition MallobSharing.hpp:148
float accumulatedAdmittedLiterals
Accumulated number of literals shared to parent.
Definition MallobSharing.hpp:165
const int lbdLimitAtImport
LBD limit for clause import.
Definition MallobSharing.hpp:161
bool doSharing() override
Performs the clause sharing operation.
bool insertClause(const ClauseExchangePtr &cls)
Inserts a new clause or updates an existing one in the sharing map.
float compensationFactor
Factor for volume compensation.
Definition MallobSharing.hpp:169
MallobSharing(const std::shared_ptr< ClauseDatabase > &clauseDB, unsigned long baseBufferSize, unsigned long maxBufferSize, unsigned int lbdLimitAtImport, unsigned int sizeLimitAtImport, unsigned int roundsPerSecond, float maxCompensation, unsigned int resharePeriodMicroSec)
Constructor for MallobSharing.
bool initMpiVariables() override
Initializes MPI-related variables.
size_t lastEpochAdmittedLits
Number of literals in last epoch final buffer.
Definition MallobSharing.hpp:167
bool addChildClauses
Flag to determine if child clauses should be added.
Definition MallobSharing.hpp:159
const unsigned int maxSize
Maximum size for buffer calculations.
Definition MallobSharing.hpp:139
std::vector< int > receivedClausesRight
Buffer for clauses received from right child.
Definition MallobSharing.hpp:145
float estimatedIncomingLits
Estimated number of incoming literals.
Definition MallobSharing.hpp:171
bool doesClauseExist(const ClauseExchangePtr &cls) const
Checks if a clause exists in the sharing map.
int mergeSerializedBuffersWithMine(std::vector< std::reference_wrapper< std::vector< int > > > &buffers, std::vector< int > &result, size_t &nonFreeLiteralsCount)
Merges serialized buffers with local clauses from the m_clauseDB database.
bool isClauseShared(const ClauseExchangePtr &cls) const
Checks if a clause has been shared recently.
float estimatedSharedLits
Estimated number of shared literals.
Definition MallobSharing.hpp:172
void incrementEpoch()
Increments the current epoch.
const int sizeLimitAtImport
Size limit for clause import.
Definition MallobSharing.hpp:162
float maxCompensationFactor
Maximum Compensation factor.
Definition MallobSharing.hpp:170
Bitset myBitVector
Bitset for tracking shared clauses.
Definition MallobSharing.hpp:150
int left_child
MPI rank of the left child.
Definition MallobSharing.hpp:153
bool importClause(const ClauseExchangePtr &cls) override
Imports a clause into the clause database.
const unsigned int baseSize
Base size for buffer calculations.
Definition MallobSharing.hpp:138
size_t lastEpochReceivedLits
Number of literals received in last epoch.
Definition MallobSharing.hpp:168
int right_child
MPI rank of the right child.
Definition MallobSharing.hpp:154
unsigned m_freeSize
Clause size not counted in the buffer at serialization.
Definition MallobSharing.hpp:163
std::vector< std::reference_wrapper< std::vector< int > > > buffers
Buffers for clause sharing.
Definition MallobSharing.hpp:141
void initializeFilter(unsigned int resharingPeriod, unsigned int sharingsPerSecond, unsigned int maxProducerId=63)
Initializes the sharing filter with given parameters.
std::vector< int > clausesToSendSerialized
Buffer for serialized clauses to send.
Definition MallobSharing.hpp:143
void computeCompensation()
Computes the compensation factor for volume balancing.
std::chrono::microseconds getSleepingTime() override
Gets the sleeping time for the sharing strategy.
int father
MPI rank of the parent node.
Definition MallobSharing.hpp:152
float accumulatedDesiredLiterals
Accumulated number of literals received from children.
Definition MallobSharing.hpp:166
void updateClause(const ClauseExchangePtr &cls)
Updates the metadata for an existing clause.
~MallobSharing()
Destructor for MallobSharing.
void deserializeClauses(const std::vector< int > &serialized_v_cls)
Deserializes received clauses.
bool getOneClauseWrapper(ClauseExchangePtr &cls)
Wrapper for getting one clause from the database. This remove the need to make the filter thread-safe...
Definition MallobSharing.hpp:124
size_t shrinkFilter()
Shrinks the filter to remove entries of clauses that can be reshared. Once a clause was shared m_resh...
void joinProcess(int winnerRank, SatResult res, const std::vector< int > &model) override
Handles the process of joining when a solution is found.
std::vector< int > receivedClausesLeft
Buffer for clauses received from left child.
Definition MallobSharing.hpp:144
int nb_children
Number of children nodes.
Definition MallobSharing.hpp:155
void markClauseAsShared(ClauseExchangePtr &cls)
Marks a clause as shared, updating its metadata.
bool canConsumerImportClause(const ClauseExchangePtr &cls, unsigned consumerId)
Determines if a consumer can import a given clause.
void computeBufferSize(unsigned int aggregationsCount)
Computes the buffer size based on the number of aggregations.
size_t sleepTime
Sleep time between sharing operations.
Definition MallobSharing.hpp:157
std::shared_ptr< ClauseDatabase > m_clauseDB
Clause database where exported clauses are stored.
Definition SharingStrategy.hpp:147
SatResult
Enumeration for SAT solver results.
Definition SolverInterface.hpp:39
Equality functor for ClauseExchangePtr objects.
Definition ClauseUtils.hpp:151
Hash functor for ClauseExchangePtr objects.
Definition ClauseUtils.hpp:143