When you MPI_COMM_SPAWN, the parent and children processes are said to be 
"connected".  And MPI_FINALIZE is collective across all connected processes 
(see the definition of MPI_FINALIZE in MPI-2.2).

If you want to disconnect the spawned children from the parents, use 
MPI_COMM_DISCONNECT.  Then the two sets of processes will be able to 
MPI_FINALIZE separately.

http://www.open-mpi.org/doc/v1.5/man3/MPI_Comm_spawn.3.php
http://www.open-mpi.org/doc/v1.5/man3/MPI_Finalize.3.php
http://www.open-mpi.org/doc/v1.5/man3/MPI_Comm_disconnect.3.php


On Aug 31, 2011, at 8:35 PM, Mateus Augusto wrote:

> Hello,
> 
> 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, stopped in 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.
> 
> 
> 
> 
> 
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users


-- 
Jeff Squyres
jsquy...@cisco.com
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/


Reply via email to