event driven MPI
Asked Answered
D

2

6

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?

Ddene answered 5/10, 2011 at 1:1 Comment(3)
Do you want asynchronous communication or are you asking for other ways to avoid deadlocks in distributed systems?Osvaldooswal
I want to effectively be able to perform asynchronous communication. MPI has built in capabilities for asynchronous send/recv, but it is not at all obvious how to build a general asynchronous communication platform using those primitives, since they still require cooperation (every asynchronous send must be have a corresponding anticipated recv).Ddene
Communication always needs cooperation, so I am not 100% sure what you need. If my understanding is correct, you want to have a process acting as a dispatch queue, which is used by the master as well by the slaves. That decouples the communication between the master and the slaves and resolves the need for direct communication between them. Could you elaborate further what you thought of?Osvaldooswal
O
1

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.

Overcritical answered 7/10, 2011 at 15:46 Comment(0)
S
1

You might want to use charm++; it's not explicitly an event driven framework, but does provide an abstraction mechanism for performing tasks and distributing those tasks dynamically.

Serrano answered 20/9, 2013 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.