Hello,
Traduzir do: português
Digite um texto ou
endereço de um site ou traduza um
documento.
Cancelar
Tradução do português
para inglês
I have three processes that communicate with each other. The first process creates the other two processes (using MPI_Comm_spaw (...)).
When one of the processes performs MPI_Finalize (), it continues in execution, stoppedin MPI_Finalize function () (in busy waiting, ie, using CPU) and just executes the next instruction only
when the other two processes run MPI_Finalize (). It seems that MPI_Finalize () behaves like MPI_Barrier (). This behavior only occurs when processes communicate with each other (when, for example, use MPI_Send, MPI_Isend, MPI_Bsend. or MPI_Ssend).
I would like to know if we can avoid this behavior of MPI_Finalize when processes communicate with each other.
Here there are the codes:
Process Master:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mpi.h>
int main(int argc, char** argv) {
int i;
char other[200];
getcwd(other, 199);
strcat(other, "/otherProcess");
MPI_Init(&argc, &argv);
MPI_Comm com;
MPI_Status s;
MPI_Comm_spawn(other, MPI_ARGV_NULL, 2, MPI_INFO_NULL, 0,
MPI_COMM_WORLD, &com, MPI_ERRCODES_IGNORE);
MPI_Recv(&i, 1, MPI_INT, 0, 0, com, &s);
sleep(15); // Make the otherProcess wait the Master process in MPI_Finalize().
MPI_Finalize();
return 0;
}
Other Process (process Master calls otherProcess):
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main(int argc, char * argv[]) {
int dest;
MPI_Comm parent;
MPI_Init(&argc, &argv);
MPI_Comm_get_parent(&parent);
MPI_Send(&dest, 1, MPI_INT, 0, 0, parent); // If this line is removed, the process doesn't stop in MPI_Finalize.
printf("Before MPI_Finalize\n");
MPI_Finalize(); // The process stay here waiting all process execute
MPI_Finalize.
printf("After MPI_Finalize\n");
return 0;
}
I've tried several things but nothing worked. I don't want that otherProcess stay waiting in MPI_Finalize().
Could someone help-me?
Thanks.
|