Skip to content
Snippets Groups Projects
CNDFS.h 1.8 KiB
Newer Older
//
// Created by ghofrane on 5/4/22.
//
#ifndef PMC_SOG_CNDFS_H
#define PMC_SOG_CNDFS_H
chihebabid's avatar
chihebabid committed
#include "../ModelCheckBaseMT.h"
#include <spot/tl/apcollect.hh>
chihebabid's avatar
chihebabid committed
#include <cstdint>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <spot/twa/twagraph.hh>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <atomic>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <thread>
#include <mutex>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <condition_variable>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include "misc/SafeDequeue.h"

Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
using namespace std ;
chihebabid's avatar
chihebabid committed
typedef pair<struct myState_t*, int> coupleSuccessor;
static constexpr uint8_t MAX_THREADS=64;
chihebabid's avatar
chihebabid committed
struct myState_t {
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    LDDState *left;
    const spot::twa_graph_state* right;
chihebabid's avatar
chihebabid committed
    vector<pair<struct myState_t*, int>> new_successors;
    bool isAcceptance {false};
    bool isConstructed {false};
    array<bool,MAX_THREADS> cyan {false};
chihebabid's avatar
chihebabid committed
    atomic<bool> blue {false};
    atomic<bool> red {false};
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
};
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed

class CNDFS {
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
private:
chihebabid's avatar
chihebabid committed
    ModelCheckBaseMT * mMcl;
    spot::twa_graph_ptr mAa;
chihebabid's avatar
chihebabid committed
    uint16_t mNbTh;
chihebabid's avatar
chihebabid committed
    atomic<uint8_t> mIdThread;
    std::thread* mlThread[MAX_THREADS];
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    mutex mMutex;
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    condition_variable cv;
chihebabid's avatar
chihebabid committed
    void spawnThreads();
chihebabid's avatar
chihebabid committed
    myState_t * mInitStatePtr;
    SafeDequeue<struct myState_t*> mSharedPoolTemp;
    static spot::bdd_dict_ptr* m_dict_ptr;
chihebabid's avatar
chihebabid committed
    void getInitialState();
    static void threadHandler(void *context);
    void threadRun();
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
//    SafeDequeue<myCouple> sharedPool;
     SafeDequeue<spot::formula> transitionNames;
     SafeDequeue<coupleSuccessor> new_successor;
chihebabid's avatar
chihebabid committed
    CNDFS(ModelCheckBaseMT *mcl,const spot::twa_graph_ptr &af,const uint16_t& nbTh);
    virtual ~CNDFS();
chihebabid's avatar
chihebabid committed
    void computeSuccessors(myState_t *state);
    void dfsBlue(myState_t *state, vector<myState_t*>& Rp,uint8_t idThread);
    void dfsRed(myState_t* state, vector<myState_t*>& Rp,uint8_t idThread);
chihebabid's avatar
chihebabid committed
    void WaitForTestCompleted(myState_t* state);
chihebabid's avatar
chihebabid committed
    myState_t* buildState(LDDState* left, spot::state* right, bool acc, bool constructed,bool cyan);

};

#endif //PMC_SOG_CNDFS_H