Hello all

I don't mean to be competing for the 'silliest question of the year award',
but I can't figure this out on my own:

My 'cluster' has 2 machines, bigMPI and smallMPI. They are connected via
several (types of) networks and the connectivity is OK.

In this setup, the following program hangs after printing

Hello world from processor smallMPI, rank 0 out of 2 processors
Hello world from processor bigMPI, rank 1 out of 2 processors
smallMPI sent haha!


Obviously it is hanging at MPI_Recv(). But why? My command line is as
follows, but this happens if I try openib BTL (instead of TCP) as well.

mpirun -np 2 -hostfile ~/hostfile -mca btl self,tcp ./mpitest

It must be something *really* trivial, but I am drawing a blank right now.

Please help!

#include <mpi.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char** argv)
{
    int world_size, world_rank, name_len;
    char hostname[MPI_MAX_PROCESSOR_NAME], buf[8];

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
    MPI_Get_processor_name(hostname, &name_len);
    printf("Hello world from processor %s, rank %d out of %d processors\n",
hostname, world_rank, world_size);
    if (world_rank == 1)
    {
    MPI_Recv(buf, 6, MPI_CHAR, 0, 99, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
    printf("%s received %s\n", hostname, buf);
    }
    else
    {
    strcpy(buf, "haha!");
    MPI_Send(buf, 6, MPI_CHAR, 1, 99, MPI_COMM_WORLD);
    printf("%s sent %s\n", hostname, buf);
    }
    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();
    return 0;
}



We learn from history that we never learn from history.

Reply via email to