Cartesian Topology


Virtual and Physical Topologies



#include<mpi.h>
#include<stdio.h>
/* A 12 process- 2 Dimensional Cylinder*/
#define TRUE 1
#define FALSE 0
int main(int argc, char *argv[]) {
    MPI_Status status;
    int rank;
    MPI_Comm A_New_MPI_World;
    int dim[2],reorder,period[2];
    int up,down,right,left;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    dim[0]=4; dim[1]=3;
    period[0]=TRUE; period[1]=FALSE;
    reorder=TRUE;   /* Can the processes be reordered, may result in improved performance.*/
    MPI_Cart_create(MPI_COMM_WORLD,2,dim,period,reorder,&A_New_MPI_World);
            MPI_Cart_shift(A_New_MPI_World,0,1,&left,&right);
            MPI_Cart_shift(A_New_MPI_World,1,1,&up,&down);
            printf("Task: %i My neighbors are u: %i d:%i 1:%i r:%i\n",rank,up,down,left,right);
    MPI_Finalize();
}


myshifts.h

A Process Synchronization Fix

Using the Topology