Philip Moloney
Philip Moloney

Reputation: 51

How to write MPI routines to send/ receive for an MPI Graph?

I have an mpi graph structure that is roughly cartesian, but has some extra structure for the top/bottom processes. The top/bottom processes need to receive from all processes just below/above it, but only pass to one of them, for example:

enter image description here

Assuming that I know the neighbours for each process (e.g. for the example I know that rank8 has [up,down,left,right]=[9,7,5,11]; or that rank0 has [up,down,left,right]=[1,-1,-1,-1], where -1 means no neighbour) then how would I go about writing a generic send/receive routine to pass (for example) integers around on this graph? Every processor should be able to pass different values to all of its neighbours and the routine should be general and work for arbitrary domains that follow this structure (i.e. one process on the top and bottom, but with any regular, cartesian grid 'between' them).

I know that the question is quite broad and I don't have much of a starting point, but any help would be really appreciated!

Upvotes: 2

Views: 179

Answers (1)

Victor Eijkhout
Victor Eijkhout

Reputation: 5810

For send/recv operations you don't have to do anything special. Every process knows who to send to / receive from.

You could use the new MPI graph topology operations: MPI_Dist_graph_create and MPI_Neighbor_allgather for gathering from the neighbors. In that case maybe your MPI implementation can actually move processes to get them physically closer to each other.

Upvotes: 1

Related Questions