#include "mpi.h" #include #include //Use the following for the MPI_Waitany version //#define MPI_WAIT_ANY_VERSION int main(int pArgc, char *pArgv[]) { int lRank = -1; int lNp = -1; int lTag = 1; int lRet = 0; if (pArgc != 2) { std::cerr << "Please specify the number of int to send!" << std::endl; return 1; } int lNbInt = std::atoi(pArgv[1]); MPI_Request lSendRequest; MPI_Status lStatus; lStatus.MPI_ERROR = MPI_SUCCESS; MPI_Init(&pArgc,&pArgv); MPI_Comm lComm = MPI_COMM_WORLD; MPI_Comm_size(lComm, &lNp); MPI_Comm_rank(lComm, &lRank); int * lPtrToArrayOfInt = 0; int * lVecInt = 0; if (lRank != 0 ) { lPtrToArrayOfInt = new int[lNbInt]; for (int i = 0; i< lNbInt; ++i) { lPtrToArrayOfInt[i] = rand(); } MPI_Isend(lPtrToArrayOfInt, lNbInt, MPI_INT, 0, lTag, lComm, &lSendRequest); } else { MPI_Request* lVecRequest = new MPI_Request[lNp-1]; lVecInt = new int[lNbInt*lNp-1]; if (0 == lVecInt) { std::cerr<< "Unable to allocate array!" <