As I understand from this answer, there is a size limit of 2^31-1
elements for the messages that you can send/receive in Open MPI. Nevertheless, when I try to send an int
array that has more than exactly 4786470 elements my code simply stops working. It does not give me any error messages or segfaults, it only gets stuck in the communication and never finishes execution.
Here is a minimal example:
#include "mpi.h"
int main(int argc, char **argv){
MPI_Init(&argc,&argv);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
const int n = 4786470 + 1; // it works when n = 4786470
int* send_array = new int[n];
int* recv_array = new int[n];
for(int i=0; i<n; i++) send_array[i] = 0;
for(int i=0; i<n; i++) recv_array[i] = 0;
if(rank==0) MPI_Send(send_array, n, MPI_INT, 1, 0, MPI_COMM_WORLD);
if(rank==1) MPI_Recv(recv_array, n, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
delete[] send_array;
delete[] recv_array;
MPI_Finalize();
}
I did some tests with Isend
and Irecv
and it does not seem to change anything. I'm not sure if I am doing something wrong in the code or it's some problem from my MPI.
By the way, to compile and run I am using Open MPI 4.0.1 and Apple clang 11.0.3 in macOS 10.15.4.