Hi,

I have followed the tutorial in this link: http://www.cs.ucla.edu/~zhu/tutorial/Using_MS-MPI.pdf to use MPI on my local windows machine with vs. The simple Hello wold work as expected, I have 2 processors and I get the expected result.
The problem is when I try a very simple send receive program I just see nothing printed on the screen, I have no errors in compilation or linking. Here is the code:

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

using namespace std;
int main (int argc, char *argv[])
{
    int numtasks, rank, dest, source, rc, count, tag=1;  
    char inmsg, outmsg='x';
    MPI_Status Stat;

    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    if(rank == 0){
        dest = 1;
        rc = MPI_Send(&outmsg, 1, MPI_CHAR, dest, tag, MPI_COMM_WORLD);
    }
    else
    {
        source = 0;
        rc = MPI_Recv(&inmsg, 1, MPI_CHAR, source, tag, MPI_COMM_WORLD, &Stat);
        std::cout<<"Task "<<rank<<": Received "<< inmsg << "\n";
    }

    MPI_Finalize();
    system("pause");
    return 0;
}   

the command line I use on cmd is: mpiexec -n 2 C:\Debug\out.exe and as I said I see nothing at all, the program just ask me to press any key to proceed. Anybody has an Idea what can be the problem?

Thanks!!

Recommended Answers

All 4 Replies

put a print statement after line 17 and display the value of rc.

It prints 0. and I made the same thing after line 22 and it prints also 0.

I tried it an it (the first example program) won't work on my Windows 7 computer. I have no idea why since I have an 8-core processor.

Aborting: failed to launch 'ûn 8 mpiTest1.exe' on TARDIS
Error (2) The system cannot find the file specified.

OK. When I just change the cout in line 23 to cerr, it prints the variable. I have no idea why it is directed to the std error, do anybody have any idea?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.