Gaurav Gupta
2008-12-30 17:24:41 UTC
I tried to run code :
#include <mpi.h>
void main(int argc, char **argv)
{
int nprocs, myrank, tag, rc;
float sendbuf, recvbuf;
MPI_Request req;
MPI_Status status;
rc = MPI_Init(&argc, &argv);
rc = MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
rc = MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
tag = 1;
if (myrank == 0)
{
sendbuf = 9.0;
rc = MPI_Send(&sendbuf, 1, MPI_FLOAT, 1, tag, MPI_COMM_WORLD);
}
else if (myrank == 1)
{
rc = MPI_Irecv(&recvbuf, 1, MPI_FLOAT, 0, tag, MPI_COMM_WORLD,
&req);
rc = MPI_Wait(&req, &status);
printf("recvbuf = %f\n", recvbuf);
}
rc = MPI_Finalize();
}
and got error message ::
[administrator-desktop:23637] *** An error occurred in MPI_Send
[administrator-desktop:23637] *** on communicator MPI_COMM_WORLD
[administrator-desktop:23637] *** MPI_ERR_RANK: invalid rank
[administrator-desktop:23637] *** MPI_ERRORS_ARE_FATAL (goodbye)
I am new to MPI programming and not able to figure out what is the
actual problem please help me out so i can start.
Thanks in advance.
#include <mpi.h>
void main(int argc, char **argv)
{
int nprocs, myrank, tag, rc;
float sendbuf, recvbuf;
MPI_Request req;
MPI_Status status;
rc = MPI_Init(&argc, &argv);
rc = MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
rc = MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
tag = 1;
if (myrank == 0)
{
sendbuf = 9.0;
rc = MPI_Send(&sendbuf, 1, MPI_FLOAT, 1, tag, MPI_COMM_WORLD);
}
else if (myrank == 1)
{
rc = MPI_Irecv(&recvbuf, 1, MPI_FLOAT, 0, tag, MPI_COMM_WORLD,
&req);
rc = MPI_Wait(&req, &status);
printf("recvbuf = %f\n", recvbuf);
}
rc = MPI_Finalize();
}
and got error message ::
[administrator-desktop:23637] *** An error occurred in MPI_Send
[administrator-desktop:23637] *** on communicator MPI_COMM_WORLD
[administrator-desktop:23637] *** MPI_ERR_RANK: invalid rank
[administrator-desktop:23637] *** MPI_ERRORS_ARE_FATAL (goodbye)
I am new to MPI programming and not able to figure out what is the
actual problem please help me out so i can start.
Thanks in advance.