When writing code in C/C++ using MPI, if memory is allocated before MPI_Init is called, how do each of the processes view that memory? From a test program, I can see that sometimes it’s OK and others it isn’t. Does the standard define this? I can’t tell if the memory allocation is copied over to the other processes during MPI_Init, of if I just got lucky because all the processes are ‘currently’ on a single (multi-core) CPU.
Share
Yes. Each process is spawned at executable load-time. If any memory is allocated before a call to MPI_Init, each process knows that data. However, before MPI_Init is called, processes are not aware of themselves or each other. Calling MPI_Init and MPI_Comm_world initializes MPI environment and returns you MPI_Comm, which allows you to establish connection between processes.