Reputation: 386
I'm writing a small test problem in F77 (Yes, I know it's outdated, no I can't move to F90 for reasons I'm not going to go into), and I'm trying to parallelize it with MPI. I'm relatively familiar with SMP (specifically OpenMP), but I've run into a lack of understanding as to how MPI allocated memory. My current code structure grabs a large chunk of memory at the beginning of the program, and then carves out pieces of a statically dimensioned array (a way to get around the dynamic memory allocation problem without dynamically allocating memory). My problem is this: I allocate a lot of memory at the beginning of the program (usually the bulk of available RAM). If I try to do this will MPI, will it try to allocate the same large array for each process?
For example
Program MPI_SUM
Implicit Real*8(A-H,O-Z)
Include '/usr/include/mpi/mpif.h'
Parameter (MDV = MAX_MEM) ! Let's say I have MAX_MEM defined here
Dimension V(MDV)
Call MPI_Init(IErr)
Call MPI_WORLD_RANK(MPI_COMM_WORLD,myID,IErr)
Call MPI_WORLD_SIZE(MPI_COMM_WORLD,nProc,IErr)
Ect... Ect... Let's say MAX_Mem is a value such that allocating allocating two of them would exceed available RAM. Will each process try to allocate a new V array of dimension MDV?
Upvotes: 0
Views: 923
Reputation: 78306
In an MPI program each process executes the same program. If you are constrained to static allocation by your affection for FORTRAN77 you are constrained to each process grabbing the same amount of memory upon program start-up. Sometimes this is not a problem -- when, for example, an MPI program is running on a distributed-memory machine on which each process has access to separate local memory. Sometimes this is a problem -- when, for example, eight MPI processes running on the same computer (perhaps a multicore desktop) each try to grab all available memory.
So, in terms of your question -- yes, each MPI process will try to grab the entire available memory, bad things will ensue.
Upvotes: 3