GSATThreadMPI.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef GSATTHREADMPI_HPP
  2. #define GSATTHREADMPI_HPP
  3. /* --- Include --- */
  4. #include <vector>
  5. #include <thread>
  6. #include "GSAT/GSAT.hpp"
  7. /* --- Constante --- */
  8. #define DEFAULT_NB_THREAD 4
  9. /* --- Structure --- */
  10. typedef struct {
  11. int pid;
  12. int rank;
  13. int threadId;
  14. double calcTime;
  15. unsigned int nbIteration;
  16. unsigned int heuristicFill;
  17. unsigned int heuristicSolve;
  18. unsigned int nbSatisfiedClausesFill;
  19. unsigned int nbSatisfiedClausesSolve;
  20. }GSATResult;
  21. class GSATThreadMPI {
  22. public:
  23. GSATThreadMPI(int, int, char**);
  24. ~GSATThreadMPI();
  25. bool solve();
  26. void end();
  27. void end(bool);
  28. void printResult();
  29. /* --- Getter --- */
  30. inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
  31. inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}
  32. inline GSATResult getResult() {return result;}
  33. void setResult(int, int, int, double, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
  34. private:
  35. bool bEnd;
  36. bool find;
  37. int nbThread;
  38. std::vector<GSAT*> gsat;
  39. std::vector<std::thread> threads;
  40. std::thread mpiSync;
  41. GSATResult result;
  42. void solverThread(int);
  43. void mpiWait(GSATThreadMPI*);
  44. void mpiNotify(int);
  45. };
  46. #endif