Newsgroups: comp.parallel.mpi
From: zxu@aloha.usc.edu (Zhiwei Xu)
Subject: How to do circular shift in MPI?
Organization: University of Southern California, Los Angeles, CA
Date: 29 Aug 1995 19:11:52 -0700
Message-ID: <420hd8$dck@aloha.usc.edu>

A circular shift is as follows: 

task i sends a msg to task i+1, and task (n-1) sends a msg to task 0.

This operation can be realized in IBM MPL by calling mpc_shift.

What is the best way to do it in MPI? We want to avoid deadlock and serialization
due to buffering.

Actually, what we need to do in our applications is two circular shifts:
(1) for i=0,..., n-2, task i sends a msg to task i+1, and task (n-1) sends a msg to task 0;
(2) for i=1,..., n-1, task i sends a msg to task i-1, and task 0 sends a msg to task n-1;

Is the following solution the best?

(1) Let tasks pairs (0,1), (2,3), ..., (n-2,n-1) each do a MPI_Sendrecv;
(1) Let tasks pairs (n-1,0), (1,2), ..., (n-3,n-2) each do a MPI_Sendrecv


Many thanks.

Zhiwei Xu	zxu@aloha.usc.edu

