Arthur Brandao 6 år sedan
förälder
incheckning
83fa4a01a9
2 ändrade filer med 21 tillägg och 16 borttagningar
  1. 20 16
      Partie_1/Hybride/GSATThreadMPI.cpp
  2. 1 0
      Partie_1/Hybride/GSATThreadMPI.hpp

+ 20 - 16
Partie_1/Hybride/GSATThreadMPI.cpp

@@ -45,24 +45,10 @@ bool GSATThreadMPI::solve() {
 	mpiSync.join();
 	//Si c'est le proc qui à trouvé
 	if(find) {
-		sleep(1); //Laisse le temps aux autres de se couper
 		//Affiche resultat
+		sleep(1); //Attend la fin des autres processus
 		printf("-----------------------------------------------------------------------------------------------------------------\n");
-		printf(GREEN);
-		printf("s %s\n",find?"SATISFIABLE":"NOT FOUND");
-		printf(YELLOW);
-        printf("c real time : %.4f seconds\n", result.calcTime);
-        printf("c [pid:%6d][process:%2d][thread:%2d][iteration:%4d][fill:%d][heuristic:%d]Satisfied clauses (begin: %d)(end:%d)\n",
-			getpid(),
-			world_rank,
-			result.threadId,
-			result.nbIteration,
-			result.heuristicFill,
-			result.heuristicSolve,
-			result.nbSatisfiedClausesFill,
-			result.nbSatisfiedClausesSolve);
-        printf(RESET);
-        fflush(stdout);
+		this->printResult();
 	}
   	return find;
 }
@@ -71,6 +57,24 @@ void GSATThreadMPI::isEnd() {
 	end = true;
 }
 
+void GSATThreadMPI::printResult() {
+	printf(GREEN);
+	printf("s %s\n",find?"SATISFIABLE":"NOT FOUND");
+	printf(YELLOW);
+    printf("c real time : %.4f seconds\n", result.calcTime);
+    printf("c [pid:%6d][process:%2d][thread:%2d][iteration:%4d][fill:%d][heuristic:%d]Satisfied clauses (begin: %d)(end:%d)\n",
+		getpid(),
+		world_rank,
+		result.threadId,
+		result.nbIteration,
+		result.heuristicFill,
+		result.heuristicSolve,
+		result.nbSatisfiedClausesFill,
+		result.nbSatisfiedClausesSolve);
+    printf(RESET);
+    fflush(stdout);
+}
+
 /* --- Private --- */
 
 void GSATThreadMPI::solverThread(int id) {

+ 1 - 0
Partie_1/Hybride/GSATThreadMPI.hpp

@@ -26,6 +26,7 @@ class GSATThreadMPI {
 		~GSATThreadMPI();
 		bool solve();
 		void isEnd();
+		void printResult();
 		/* --- Getter --- */
 		inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
 		inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}