GSATThreadMPI.hpp 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 threadId;
  12. double calcTime;
  13. unsigned int nbIteration;
  14. unsigned int heuristicFill;
  15. unsigned int heuristicSolve;
  16. unsigned int nbSatisfiedClausesFill;
  17. unsigned int nbSatisfiedClausesSolve;
  18. }GSATResult;
  19. class GSATThreadMPI {
  20. public:
  21. GSATThreadMPI(int, int, char**);
  22. ~GSATThreadMPI();
  23. bool solve();
  24. void end();
  25. void end(bool);
  26. void printResult();
  27. /* --- Getter --- */
  28. inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
  29. inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}
  30. private:
  31. bool bEnd;
  32. bool find;
  33. int nbThread;
  34. std::vector<GSAT*> gsat;
  35. std::vector<std::thread> threads;
  36. std::thread mpiSync;
  37. GSATResult result;
  38. void solverThread(int);
  39. void mpiWait(GSATThreadMPI*);
  40. void mpiNotify(int);
  41. };
  42. #endif