3 #include <boost/interprocess/managed_shared_memory.hpp>
4 #include <boost/interprocess/containers/vector.hpp>
5 #include <boost/interprocess/allocators/allocator.hpp>
8 #include "../utils/Bookkeeping.h"
15 using namespace boost::interprocess;
16 typedef allocator<std::optional<Explanation> , managed_shared_memory::segment_manager>
ShmemAllocator;
24 template<
typename... Backends>
27 using B = std::tuple<Backends...>;
30 template<std::size_t N = 0, carl::EnableIfBool<N == std::tuple_size<B>::value> = carl::dummy>
35 template<std::size_t N = 0, carl::EnableIfBool<N < std::tuple_size<B>::value> = carl::dummy>
38 if( (pids[N] = fork()) == 0){
39 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.explanation",
"Concurrent strategy " << N+1 <<
" started");
40 std::optional<Explanation> explanation = std::get<N>(mBackends)(data,
var, reason);
41 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.explanation",
"Concurrent strategy " << N+1 <<
" done");
43 managed_shared_memory segment(open_only,
"SharedVector");
45 *(explanations->begin()+N) = explanation;
51 SMTRAT_LOG_ERROR(
"smtrat.mcsat.explanation",
"This should not be reachable");
52 }
else if(pids[N] == -1){
56 explain<N+1>(data,
var, reason, pids);
60 std::optional<Explanation> operator()(
const mcsat::Bookkeeping& data, carl::Variable
var,
const FormulasT& reason)
const {
61 const std::size_t NUM_PROCESSES = std::tuple_size<B>::value;
62 if(NUM_PROCESSES <= 0){
72 std::vector<pid_t> pids;
74 managed_shared_memory segment(create_only,
"SharedVector", 65536);
78 for(
size_t i = 0; i < NUM_PROCESSES; i++) {
79 explanations->push_back(std::nullopt);
83 explain<0>(data,
var, reason, pids);
86 for (
auto it = explanations->begin(); it != explanations->end(); it++) {
87 if((*it) != std::nullopt){
88 for (
size_t i = 0; i < NUM_PROCESSES; i++) {
89 if(!kill(pids[i], SIGKILL)){
Represent the trail, i.e.
static void remove(V &ts, const T &t)
allocator< std::optional< Explanation >, managed_shared_memory::segment_manager > ShmemAllocator
vector< std::optional< Explanation >, ShmemAllocator > SharedVector
Class to create the formulas for axioms.
carl::Formulas< Poly > FormulasT
#define SMTRAT_LOG_ERROR(channel, msg)
#define SMTRAT_LOG_DEBUG(channel, msg)
This explanation executes all given explanation in parallel processes and waits for the fastest expla...
SMTRAT_LOG_DEBUG("smtrat.mcsat.explanation", "Start looking for explanation")
std::tuple< Backends... > B
void explain(const mcsat::Bookkeeping &, carl::Variable, const FormulasT &, std::vector< pid_t > &pids) const