Search code examples
cparallel-processingmpimessage-passing

How to select a master processor randomly in MPI programming?


I need to select one processor from my Comm to do some works ( I don`t want other processors do the work ). Since I split my Comm to the groups, I cannot always pick one specific rank ( for example 0) as my master. I need to choose it from my current comm. Any suggestion?

Thank you.


Solution

  • The rank of a process is always relative to a communicator. After you split your processes, you can just take process 0 in the new communicator to perform the work you want.