Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
Sharer.hpp
1#pragma once
2
3#include "sharing/SharingEntity.hpp"
4#include "sharing/SharingStrategy.hpp"
5#include "utils/Logger.hpp"
6#include "utils/Threading.hpp"
7
13static void* mainThrSharing(void* arg);
14
19class Sharer
20{
21 public:
27 Sharer(int id_, std::vector<std::shared_ptr<SharingStrategy>>& sharingStrategies);
28
34 Sharer(int id_, std::shared_ptr<SharingStrategy> sharingStrategy);
35
39 virtual ~Sharer();
40
44 virtual void printStats();
45
49 inline void join()
50 {
51 if (sharer == nullptr)
52 return;
53 sharer->join();
54 delete sharer;
55 sharer = nullptr;
56 LOGDEBUG1("Sharer %d joined", this->getId());
57 }
58
63 inline void setThreadAffinity(int coreId) { this->sharer->setThreadAffinity(coreId); }
64
69 inline int getId() { return this->m_sharerId; }
70
75 inline void setId(int id) { this->m_sharerId = id; }
76
77 protected:
80
82 double totalSharingTime = 0;
83
85 unsigned int round;
86
88 std::vector<std::shared_ptr<SharingStrategy>> sharingStrategies;
89
95 friend void* mainThrSharing(void*);
96
99};
Defines logging functions and macros for the SAT solver.
#define LOGDEBUG1(...)
Log a debug message with verbosity level 1 and blue color.
Definition Logger.hpp:213
A sharer is a thread responsible for executing a list of SharingStrategies.
Definition Sharer.hpp:20
void join()
Join the thread of this sharer object.
Definition Sharer.hpp:49
virtual void printStats()
Print sharing statistics.
friend void * mainThrSharing(void *)
Working function that will call sharingStrategy doSharing()
double totalSharingTime
Heuristic for strategy implementation comparison (TODO: ifndef NSTAT for such probes)
Definition Sharer.hpp:82
int getId()
Get the ID of this sharer.
Definition Sharer.hpp:69
virtual ~Sharer()
Destructor.
void setId(int id)
Set the ID of this sharer.
Definition Sharer.hpp:75
Sharer(int id_, std::vector< std::shared_ptr< SharingStrategy > > &sharingStrategies)
Constructor with multiple sharing strategies.
Thread * sharer
Pointer to the thread in charge of sharing.
Definition Sharer.hpp:79
std::vector< std::shared_ptr< SharingStrategy > > sharingStrategies
Strategy/Strategies used to share clauses.
Definition Sharer.hpp:88
unsigned int round
Number of sharing rounds completed.
Definition Sharer.hpp:85
int m_sharerId
The ID of this sharer.
Definition Sharer.hpp:98
Sharer(int id_, std::shared_ptr< SharingStrategy > sharingStrategy)
Constructor with a single sharing strategy.
void setThreadAffinity(int coreId)
Set the thread affinity for this sharer.
Definition Sharer.hpp:63
Thread class.
Definition Threading.hpp:46
void join()
Join the thread.
Definition Threading.hpp:52