GSATThreadMPI.hpp 1.2 KB

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