Nevermind... I figured this one out on my own. I was calling foo() from
inside an if (rank == 0) block. Since MPI_Comm_dup is a collective
operation, it was waiting for all the other nodes to also call
MPI_Comm_dup. Oops.
--
Prentice
Prentice Bisbal wrote:
> I have a problem with MPI_Comm_dup. When I call it in a function, it
> causes my application to hang. Are they any common causes for a problem
> like this? I'm using OpenMPI 1.2.8. Are there any known bugs that could
> be causing this?
>
> My program seems to hang when it gets to MPI_Comm_dup. Here's an example
> of how I'm using it.
>
> #include "foo.h"
>
> /* MPI variables */
> int my_rank;
> int num_proc;
> MPI_Comm euclid_comm;
>
> void foo(long *arg1, long *arg2, MPI_Comm old_comm);
>
> int main (int argc, char** argv) {
>
> /* get options */
>
> MPI_Init(&argc, &argv);
> MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
> MPI_Comm_size(MPI_COMM_WORLD, &num_proc);
>
> /* read in some data, yadda, yadda yadda */
>
> foo(&arg1, &arg2, MPI_COMM_WORLD);
>
> / *print results from foo */
>
> MPI_Finalize();
>
> }
>
> void foo(long *arg1, long *arg2, MPI_Comm old_comm)
> {
> MPI_Comm foo_comm;
> int foo_my_rank;
> int foo_num_proc;
>
> MPI_Comm_dup(old_comm, &foo_comm);
> MPI_Comm_rank(foo_comm, &foo_my_rank);
> MPI_Comm_size(foo_comm, &foo_num_proc);
>
> /* do stuff */
>
> }
>
>
|