Newsgroups: comp.parallel.mpi
From: lederman@rap.cs.wisc.edu (Steve Huss-Lederman)
Subject: Re: shift in MPI?
Organization: CS Department, University of Wisconsin
Date: 31 Jan 1997 18:28:53 GMT
Message-ID: <LEDERMAN.97Jan31122853@rap.cs.wisc.edu>

In article <5cn0rm$bc7@si-nic.hrz.uni-siegen.de> kielmann@informatik.uni-siegen.de (Thilo Kielmann) writes:

 > In article <32ef04cb.0@news.rz.uni-passau.de>, gorlatch@fmi.uni-passau.de (Sergei Gorlatch) writes:
 > |> Hi,
 > |> 
 > |> I wonder, whether there is a collective communication primitive
 > |> which does a cyclic shift (rotation) of data between processors 
 > |> of one group? Such kind of data exchange is used, e.g., for
 > |> matrix multiplication. 
 > 
 > Hmmm,
 > 
 > what about MPI_Sendrecv ???
 > 
 > As far as I remember, "the book" contains an example of a cyclic data
 > exchange based on this operation.

Yes, there is an example of doing a shift in the book, "MPI: The
Complete Reference" (I know because I put it there :-).  See section
6.5.5 on p. 261.  It has sample code, output, and a picture to show
what happens in different cases for the 2D case.

If you don't have access, the basic idea is to create a 1D cartesian
topology that is periodic with MPI_CART_CREATE, then use
MPI_CART_SHIFT to determine who to send/recv from, and then use
MPI_SENDRECV to do the communication.

Steve

