Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
SimpleSharing Class Reference

This strategy is a simple sharing strategy. More...

#include <SimpleSharing.hpp>

Inheritance diagram for SimpleSharing:
Collaboration diagram for SimpleSharing:

Public Member Functions

 SimpleSharing (const std::shared_ptr< ClauseDatabase > &clauseDB, unsigned int sizeLimitAtImport, unsigned long literalsPerRoundPerProducer, const std::vector< std::shared_ptr< SharingEntity > > &producers={}, const std::vector< std::shared_ptr< SharingEntity > > &consumers={})
 Constructor for SimpleSharing.
 
 ~SimpleSharing ()
 Destructor for SimpleSharing.
 
bool importClause (const ClauseExchangePtr &clause) override
 Imports a single clause. Clauses are tested against sizeLimit before.
 
void importClauses (const std::vector< ClauseExchangePtr > &v_clauses) override
 Imports multiple clauses.
 
bool doSharing () override
 Performs the sharing operation.
 
- Public Member Functions inherited from SharingStrategy
 SharingStrategy (const std::vector< std::shared_ptr< SharingEntity > > &producers, const std::vector< std::shared_ptr< SharingEntity > > &consumers, const std::shared_ptr< ClauseDatabase > &clauseDB)
 Constructor for SharingStrategy. Be sure to call connectConstructorProducers after construction, this is due to the base class shared_from_this.
 
virtual ~SharingStrategy ()
 Virtual destructor.
 
virtual std::chrono::microseconds getSleepingTime ()
 Determines the sleeping time for the sharer.
 
virtual void printStats ()
 Prints the statistics of the strategy.
 
void connectConstructorProducers ()
 Add this to the producers' clients list.
 
virtual void addProducer (std::shared_ptr< SharingEntity > producer)
 Adds a producer to this strategy.
 
virtual void connectProducer (std::shared_ptr< SharingEntity > producer)
 Connect a producer to this strategy. Add (this) to clients of (producer)
 
virtual void removeProducer (std::shared_ptr< SharingEntity > producer)
 Removes a producer from this strategy.
 
- Public Member Functions inherited from SharingEntity
 SharingEntity ()
 Construct a new SharingEntity object.
 
 SharingEntity (const std::vector< std::shared_ptr< SharingEntity > > &clients)
 Construct a new SharingEntity object.
 
virtual ~SharingEntity ()
 Destroy the SharingEntity object.
 
int getSharingId () const
 Get the sharing ID of this entity.
 
void setSharingId (int _id)
 Set the sharing ID of this entity.
 
virtual void addClient (std::shared_ptr< SharingEntity > client)
 Add a client to this entity.
 
virtual void removeClient (std::shared_ptr< SharingEntity > client)
 Remove a specific client from this entity.
 
size_t getClientCount () const
 Get the current number of clients.
 
void clearClients ()
 Remove all clients.
 

Protected Attributes

int literalPerRound
 Number of shared literals per round.
 
std::vector< ClauseExchangePtr > selection
 Used to manipulate clauses (as a member to reduce number of allocations).
 
unsigned int sizeLimit
 Maximum clause size.
 
- Protected Attributes inherited from SharingStrategy
std::shared_ptr< ClauseDatabasem_clauseDB
 Clause database where exported clauses are stored.
 
SharingStatistics stats
 Sharing statistics.
 
std::vector< std::weak_ptr< SharingEntity > > m_producers
 The set holding the references to the producers.
 
std::shared_mutex m_producersMutex
 Shared mutex for producers list (to become RCU ?)
 
- Protected Attributes inherited from SharingEntity
std::vector< std::weak_ptr< SharingEntity > > m_clients
 List of weak pointers to client SharingEntities.
 
std::shared_mutex m_clientsMutex
 Mutex to protect access to m_clients.
 

Additional Inherited Members

- Protected Member Functions inherited from SharingStrategy
bool exportClauseToClient (const ClauseExchangePtr &clause, std::shared_ptr< SharingEntity > client) override
 A SharingStrategy doesn't send a clause to the source client (->from must store the sharingId of its producer)
 
- Protected Member Functions inherited from SharingEntity
bool exportClause (const ClauseExchangePtr &clause)
 Export a clause to all registered clients.
 
void exportClauses (const std::vector< ClauseExchangePtr > &clauses)
 Export multiple clauses to all registered clients.
 

Detailed Description

This strategy is a simple sharing strategy.

Constructor & Destructor Documentation

◆ SimpleSharing()

SimpleSharing::SimpleSharing ( const std::shared_ptr< ClauseDatabase > & clauseDB,
unsigned int sizeLimitAtImport,
unsigned long literalsPerRoundPerProducer,
const std::vector< std::shared_ptr< SharingEntity > > & producers = {},
const std::vector< std::shared_ptr< SharingEntity > > & consumers = {} )

Constructor for SimpleSharing.

Parameters
clauseDBShared pointer to the clause database.
producersVector of shared pointers to producer entities.
consumersVector of shared pointers to consumer entities.
sizeLimitAtImportThe maximum size of allowed clauses at import.
literalsPerRoundPerProducerThe number of literals each producer should export at each round.

Member Function Documentation

◆ doSharing()

bool SimpleSharing::doSharing ( )
overridevirtual

Performs the sharing operation.

Returns
True if sharing is complete or should be terminated, false otherwise.

Implements SharingStrategy.

◆ importClause()

bool SimpleSharing::importClause ( const ClauseExchangePtr & clause)
overridevirtual

Imports a single clause. Clauses are tested against sizeLimit before.

Parameters
clausePointer to the clause to be imported.
Returns
True if the clause was successfully imported, false otherwise.

Implements SharingEntity.

◆ importClauses()

void SimpleSharing::importClauses ( const std::vector< ClauseExchangePtr > & v_clauses)
inlineoverridevirtual

Imports multiple clauses.

Parameters
v_clausesVector of clause pointers to be imported.

Implements SharingEntity.


The documentation for this class was generated from the following file: