Reputation: 491
I am trying to compile a code in C++ using code from : https://stackoverflow.com/questions/5953979/sending-and-receiving-array-using-mpi-part-2.
I use the following command to compile: mpiicpc -o <filename> xxxx.cc -lmpi
After I compile, all my errors seem to refer to the two functions i have defined in my source code to print output values and do the MPI Isend and MPI Irecv. Specifically, I get two types of errors
MPI_Isend/MPI_Irecv
and MPI Waitall();
Finally, it exists with this message: compilation aborted for xxxx.cc (code 2). Could you please point to what I must be doing wrong while defining the variables?
Here is an excerpt of my source code (The code in its entirety is available at https://stackoverflow.com/questions/5953979/sending-and-receiving-array-using-mpi-part-2):
int main (int argc, char *argv[])
{
int my_rank;
int p;
int source;
int dest;
int tag = 0;
//Allocating Memory
double *A = new double[Rows*sizeof(double)];
double *B = new double[Rows*sizeof(double)];
....
....
....
//MPI Commands
MPI_Status status;
MPI_Init (&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &p);
//For number of beats
for (ibeat=0;ibeat<beats;ibeat++)
{
for (i=0; i<Cols/2; i++)
{
for (y=0; y<Rows/2; y++)
{
if (my_rank == 0)
if (i < 48)
if (y<48)
V[i][y] = 0;
if (my_rank ==
.....
....
....
}
}
//Load the Array with the edge values
for (r=0; r<Rows/2; y++)
{
if ((my_rank == 0) || (my_rank == 1))
{
A[r] = V[r][48];
BB[r] = V[r][48];
}
if ((my_rank
...
...
}
prttofile ();
outputpass ();
ibeat = ibeat+1;
}
MPI_Finalize ();
}
void prttofile ()
{
for (i = 0; i<Cols/2; i++)
{
for (y = 0; y<Rows/2; y++)
{
if (my_rank == 0)
fout << V[i][y] << " " ;
....
....
}
}
if (my_rank == 0)
fout << endl;
....
}
void outputpass ()
{
int test = 2;
if ((my_rank%test) == 0)
{
MPI_Isend(C, Rows, MPI_DOUBLE, my_rank+1, MPI_COMM_WORLD); //Non blocking Send
MPI_Irecv(CC, Rows, MPI_DOUBLE, my_rank+1, MPI_COMM_WORLD, &status); //Non Blocking Recv
}
else if ((my_rank%test) == 1)
....
....
MPI_Waitall ();
}
Upvotes: 0
Views: 4049
Reputation: 224844
You're not declaring a lot of variables - in particular the loop counters. Declare them all at the top of your functions and you'll be fine.
According to the documentation, the signature of MPI_Isend()
is:
int MPI_Isend( void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm, MPI_Request *request )
It has seven parameters - you are passing only five arguments. You'll need to correct that. The same goes for MPI_Irecv()
.
Upvotes: 2
Reputation: 37930
MPI_Isend()
requires a lot more arguments than what you've supplied. Here's your line:
MPI_Isend(C, Rows, MPI_DOUBLE, my_rank+1, MPI_COMM_WORLD);
Where's the tag? Where's the request?
Similarly, your MPI_Waitall()
doesn't have any arguments at all! You need the array of requests, the number of requests, and an array of statuses.
I suggest you read an example of non-blocking communication in MPI.
Upvotes: 1