|  | @@ -36,7 +36,13 @@ int main(int argc, char* argv[]) {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      double startTime = gsat->realTime();
 | 
	
		
			
				|  |  |      srand(getpid());
 | 
	
		
			
				|  |  | -      
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //Attente d'un message de fin
 | 
	
		
			
				|  |  | +    int syncBuff;
 | 
	
		
			
				|  |  | +    MPI_Request sync, send;
 | 
	
		
			
				|  |  | +    MPI_Irecv(&syncBuff, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &sync);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //Calcul  
 | 
	
		
			
				|  |  |      bool end = false;
 | 
	
		
			
				|  |  |      bool stop = false;
 | 
	
		
			
				|  |  |      while(!end && !stop){
 | 
	
	
		
			
				|  | @@ -59,19 +65,27 @@ int main(int argc, char* argv[]) {
 | 
	
		
			
				|  |  |              printf(RESET);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //Regarde si quelqu'un a trouver
 | 
	
		
			
				|  |  | -        for(int i = 0; i < world_size; i++){
 | 
	
		
			
				|  |  | -            int buff;
 | 
	
		
			
				|  |  | -            if(i == world_rank) {
 | 
	
		
			
				|  |  | -                buff = end ? 1 : 0;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            MPI_Bcast(&buff, 1, MPI_INT, i, MPI_COMM_WORLD);
 | 
	
		
			
				|  |  | -            if(i != world_rank && buff && !stop) {
 | 
	
		
			
				|  |  | -                stop = true;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +        int flag;
 | 
	
		
			
				|  |  | +        MPI_Test(&sync, &flag, MPI_STATUS_IGNORE);
 | 
	
		
			
				|  |  | +        if(flag) {
 | 
	
		
			
				|  |  | +            stop = true;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    //Si on est le processus qui à trouvé
 | 
	
		
			
				|  |  |      if(end) {
 | 
	
		
			
				|  |  | +        //Avertit les autres
 | 
	
		
			
				|  |  | +        for(int i = 0; i < world_size; i++) {
 | 
	
		
			
				|  |  | +            MPI_Isend(&world_rank, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &send);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //Attend la fin des autres processus
 | 
	
		
			
				|  |  | +        for(int i = 0; i < world_size; i++) {
 | 
	
		
			
				|  |  | +            if(i != world_rank) {
 | 
	
		
			
				|  |  | +                int buff;
 | 
	
		
			
				|  |  | +                MPI_Recv(&buff, 1, MPI_INT, i, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //Affiche le resultat
 | 
	
		
			
				|  |  |          printf("--------------------------------------------------------------------------------------------\n");
 | 
	
		
			
				|  |  |          printf(GREEN);
 | 
	
		
			
				|  |  |          printf("s %s\n",end?"SATISFIABLE":"NOT FOUND");
 | 
	
	
		
			
				|  | @@ -85,6 +99,10 @@ int main(int argc, char* argv[]) {
 | 
	
		
			
				|  |  |              gsat->getNbSatisfiedClausesFill(),
 | 
	
		
			
				|  |  |              gsat->getNbSatisfiedClausesSolve());
 | 
	
		
			
				|  |  |          printf(RESET);
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +        //Indique au processus qui a trouvé que ce processus a finit de travailler
 | 
	
		
			
				|  |  | +        int buff = 1;
 | 
	
		
			
				|  |  | +        MPI_Send(&buff, 1, MPI_INT, syncBuff, 0, MPI_COMM_WORLD);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      MPI_Finalize();    
 |