I am using C and MPI. How is memory allocated for arrays if the program runs on multiple processors on the same machine? Is that array being sha开发者_如何转开发red between all participating tasks or every task has it's own copy?
Every rank has its own copy of the data. They are generally run in separate processes, and so do not share a virtual address space.
Implementations like Adaptive MPI and Phoenix put multiple ranks on threads in a common process, but they take steps to isolate each rank so that thinks it's running as a separate process.
MPI is a distributed memory framework. It has only a limited notion of shared-memory processing. If shared memory is of importance to your program's performance, then I suggest you look into OpenMP; both can be combined in the same application. (I.e., each node would run, ideally, a single OpenMP-based process that would communicate with other instances through MPI.)
精彩评论