¿Por qué mi programa se bloquea cuando utilizo MPI_Send y MPI_Recv?

There is a simple communication program that I used in MPICH2. when I execute the program by using

mpiexec.exe -hosts 2 o00 o01  -noprompt mesajlasma.exe

The program starts but does not end. I can see it is still running on the host computer "o01" by using resource monitor program. When I press Ctrl + C, it is ended. Then I can see that my program ran properly

Why doesn't my program end. Where does it stuck? why does my program hang when I use MPI_Send and MPI_Recv?

Gracias por adelantado

// mesajlasma.cpp

#include "stdafx.h"
#include "string.h"
#include "mpi.h"

int main(int argc, char* argv[])
{

    int  nTasks, rank;
    char mesaj[20];
    MPI_Status status;

    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD,&nTasks);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);

    //printf ("\nNumber of threads = %d, My rank = %d\n", nTasks, rank);

    if(rank == 1)
    {
        strcpy_s(mesaj, "Hello World");
        if (MPI_SUCCESS==MPI_Send(mesaj, strlen(mesaj)+1, MPI_CHAR, 0, 99, MPI_COMM_WORLD)) printf("_OK!_\n");
    }


    if(rank == 0)
    {
        MPI_Recv(mesaj, 20, MPI_CHAR, 1, 99, MPI_COMM_WORLD, &status);
        printf("Received Message:%s\n", mesaj);
    }

    MPI_Finalize();

    return 0;
}

preguntado el 27 de agosto de 11 a las 16:08

What is your MPI library? Is it openmpi or MPICH or MPICH2? What is an exact version? Unix or Windows? -

My library is MPICH2. In both computers, windows 7 is the operating system. Actually there are 41 computers which I installed MPICH2 and they work properly for simple «hello world» applications. But if I use MPI_Send and MPI_Receive functions, then it hangs. Therefore, I simplyfied the problem to two computers (o00 and o01) and wrote on this forum. -

1 Respuestas

You probably also need to pass an argument like -n 2 para usted mpiexec.exe command in order to instruct it to launch 2 processes. I believe that the -hosts argument is just an alternative way to specify the hosts on which your program can run, not how many processes will be created.

Respondido 29 ago 11, 18:08

I tried to run with -n 2 and I got the host names from a host_list.txt mediante el uso -machinefile. But still it works good for a host (even a remote one) but it doesn't work for two hosts till I press ctrl+c - adba

Hmm... sounds like a networking problem to me. I would recommend contacting the full MPICH2 development team at mpich-discuss@mcs.anl.gov. Since you are on Windows you have exceeded my ability to troubleshoot this issue. If/when you get the problem sorted out, make sure to post the solution back here at SO. - Dave Goodell

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.