Exemple #1
0
void mpi_manager_2D::do_MPISendRecv(NumMatrix<double,2> &buff,
                                    int Source, int Destination) {
	//! Do a send-receive operation, where the send-buffer is overwritten
	/*! Get data from somewhere and send own data somewhere else. The original
	  data will be overwritten
	 */
	// Get size of buffer:
	int size = ((buff.getHigh(1) - buff.getLow(1) + 1)*
	            (buff.getHigh(0) - buff.getLow(0) + 1));

	// MPI_Request request[1] = {MPI_REQUEST_NULL};
	// MPI_Request request;
	MPI_Status status;

	//	int tag = rank;
	int SendTag = rank;
	int RecvTag = Source;
	// int SendTag = rank + Destination;
	// int RecvTag = Destination + rank;


	// Now do the communication:
	MPI_Sendrecv_replace((double *) buff, size, MPI_DOUBLE, Destination,
	                     SendTag, Source, RecvTag,
	                     comm2d, &status);


	// MPI_Waitall(1, request);
	

}
Exemple #2
0
void mpi_manager_2D::do_MPISendRecv(NumMatrix<double,2> &buff,
                                    int Destination) {
	//! Do a send-receive operation, where the send-buffer is overwritten
	/*! Origin and destination is the same in this case
	 */
	// Get size of buffer:
	int size = ((buff.getHigh(1) - buff.getLow(1) + 1)*
	            (buff.getHigh(0) - buff.getLow(0) + 1));

	// MPI_Request request[1] = {MPI_REQUEST_NULL};
	// MPI_Request request;
	MPI_Status status;

	//	int tag = rank;
	int SendTag = rank;
	int RecvTag = Destination;
	// int SendTag = rank + Destination;
	// int RecvTag = Destination + rank;


	// Now do the communication:
	MPI_Sendrecv_replace((double *) buff, size, MPI_DOUBLE, Destination,
	                     SendTag, Destination, RecvTag,
	                     comm2d, &status);


	// MPI_Waitall(1, request);
	

}