Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

event driven MPI

Tags:

mpi

I am interested in implementing a sort of event driven dispatch queue using MPI (message passing interface). The basic problem I want to solve is this: I have a master process which inserts jobs into a global queue, and each available slave process retrieves the next job in the queue if there is one.

From what I've read about MPI, it seems like sending and receiving processes must be in agreement about when they send and receive. As in, suppose one process sends a message but the other process does not know it needs to receive, or vice versa, then everything deadlocks. Is there any way to make every process a bit more independent?

like image 454
Victor Liu Avatar asked Oct 05 '11 01:10

Victor Liu


1 Answers

You can do that as follows:

Declare one master-node (0), that is going to distribute the tasks. In this node the pseudocode is:

int sendTo
for task in tasks:
  MPI_Recv(...sendTo, MPI_INT, MPI_ANY_SOURCE,...)
  MPI_Send(job,... receiver: sendTo)

for node in nodes:
  MPI_Recv(...sendTo, MPI_INT, MPI_ANY_SOURCE,...)
  MPI_SEND(job_null,...,receiver: sendTo)

In the slave nodes the code would be:

while (true)
  MPI_Send(myNodenum to 0, MPI_INT)
  MPI_Recv(job from 0)
  if (job == job_null)
    break
  else
    execute job

I think this should work.

like image 181
sta Avatar answered Sep 22 '22 15:09

sta