GSATHybride.hpp 1.3 KB

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