|
@@ -32,7 +32,7 @@ GSATThreadMPI::~GSATThreadMPI() {
|
|
|
|
|
|
bool GSATThreadMPI::solve() {
|
|
|
threads.clear();
|
|
|
- end = false;
|
|
|
+ this->end(false);
|
|
|
find = false;
|
|
|
//Lance thread
|
|
|
for(int i = 0; i < nbThread; i++) {
|
|
@@ -55,8 +55,12 @@ bool GSATThreadMPI::solve() {
|
|
|
return find;
|
|
|
}
|
|
|
|
|
|
-void GSATThreadMPI::isEnd() {
|
|
|
- end = true;
|
|
|
+void GSATThreadMPI::end() {
|
|
|
+ this->end(true);
|
|
|
+}
|
|
|
+
|
|
|
+void GSATThreadMPI::end(bool endOrNot) {
|
|
|
+ bEnd = endOrNot;
|
|
|
}
|
|
|
|
|
|
void GSATThreadMPI::printResult() {
|
|
@@ -84,7 +88,7 @@ void GSATThreadMPI::solverThread(int id) {
|
|
|
double startTime = gsat[id]->realTime();
|
|
|
bool solve = false;
|
|
|
int cpt = 0;
|
|
|
- while(!end && !solve){
|
|
|
+ while(!bEnd && !solve){
|
|
|
//Pour eviter que les processeurs effectue tous les meme calculs
|
|
|
int fill = rand() % 4 + 2;
|
|
|
int h = rand() % 7;
|
|
@@ -107,9 +111,9 @@ void GSATThreadMPI::solverThread(int id) {
|
|
|
cpt++;
|
|
|
}
|
|
|
//Si 1er arreter
|
|
|
- if(!end && solve) {
|
|
|
+ if(!bEnd && solve) {
|
|
|
this->mpiNotify(world_rank);
|
|
|
- end = true;
|
|
|
+ this->end(true);
|
|
|
find = true;
|
|
|
result.threadId = id;
|
|
|
result.calcTime = gsat[id]->realTime() - startTime;
|
|
@@ -125,7 +129,7 @@ void GSATThreadMPI::mpiWait(GSATThreadMPI* gsat) {
|
|
|
int buff;
|
|
|
MPI_Recv(&buff, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|
|
if(buff != world_rank) {
|
|
|
- gsat->isEnd();
|
|
|
+ gsat->end();
|
|
|
}
|
|
|
}
|
|
|
|