Hi,
If i am using MPI_Send, I am not getting any problem but when I am using both MPI_Send and MPI_Recv my program blocks.
#include <iostream>
#include <fstream>
#include <cmath>
#include <mpi.h>
#include <ctime>
#include <vector>
int rank, size;
int tag = 99;
int main(int argc, char * argv[])
{
double sTime, eTime, rTime;
std::ifstream inFile;
int num_rows = 3200;
int num_cols = 3200;
int cur_control = 0;
double * send_buffer = NULL;
double * recv_buffer = NULL;
double ** data = NULL;
double determinant;
MPI_Status stat;
std::vector<double> file_buffer;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if(argc < 2)
{
std::cout << "No input file given." << std::endl;
MPI_Finalize();
return 0;
}
if(!rank)
{
inFile.open(argv[1]);
inFile >> num_rows;
file_buffer.resize(num_rows);
}
send_buffer = new double[num_rows];
if(!rank) {
for(int i=1; i<size; ++i) {
MPI_Send(&num_rows, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
}
}
for(int i=1; i<size; ++i) {
MPI_Recv(&num_rows, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &stat);
}
num_cols = num_rows / size;
delete [] send_buffer;
MPI_Finalize();
return 0;
Some body please guide me how to correct this error?
Zulfi.
What I have tried:
I have checked the syntax of MPI_recv(...). i can't understand any reason for blocking.
MPI_Recv(...) is a blocking call but it must get the data.