c++ - Errors while compiling MPI -
i trying compile code in c++ using code : https://stackoverflow.com/questions/5953979/sending-and-receiving-array-using-mpi-part-2.
i use following command compile: mpiicpc -o <filename> xxxx.cc -lmpi
after compile, errors seem refer 2 functions have defined in source code print output values , mpi isend , mpi irecv. specifically, 2 types of errors
- error: identifier "variable" undefined
- error: few arguments in function call:
mpi_isend/mpi_irecv
,mpi waitall();
finally, exists message: compilation aborted xxxx.cc (code 2).
could please point must doing wrong while defining variables?
here excerpt of source code (the code in entirety available @ 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 (ibeat=0;ibeat<beats;ibeat++) { (i=0; i<cols/2; i++) { (y=0; y<rows/2; y++) { if (my_rank == 0) if (i < 48) if (y<48) v[i][y] = 0; if (my_rank == ..... .... .... } } //load array edge values (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 () { (i = 0; i<cols/2; i++) { (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 (); }
mpi_isend()
requires lot more arguments you've supplied. here's line:
mpi_isend(c, rows, mpi_double, my_rank+1, mpi_comm_world);
where's tag? where's request?
similarly, mpi_waitall()
doesn't have arguments @ all! need array of requests, number of requests, , array of statuses.
i suggest read example of non-blocking communication in mpi.
Comments
Post a Comment