5

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 shared between all participating tasks or every task has it's own copy?

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.)

4 Comments

Unfortunately, I have to stick to MPI to do this. Thanks for the answer anyway
@kranberg: Just curious, but why is that?
Because I am learning to use MPI, I cannot use OpenMP. And I don't have distributed machines that I could use to practise, so I am using my laptop.
As I suspected :) Well, just keep OpenMP in mind, it might come in handy some day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.