Posts

Showing posts with the label mpi

Collective diagonal neighborhood communication

Image
Clash Royale CLAN TAG #URR8PPP Collective diagonal neighborhood communication I have a Cartesian process topology in 3D. However, I describe my problem in 2D to simplify it. For the collective nearest neighbor communication (left image) I use MPI_Neighbor_alltoallw() which allows send and receive of different datatypes. However this function does not work for diagonal neighbors (right image) and I need another function for diagonal neighbors. Left: nearest neighbors are green neighbors. Right: red grids are nearest diagonal neighbor. What I have in my mind to implement diagonal neighbor communication is: int main_rank; // rank of the gray process int main_coords[2]; // coordinates of the gray process MPI_Comm_rank (comm_cart, &main_rank); MPI_Cart_coords (comm_cart, main_rank, 2, main_coords); // finding the rank of the top-right neighbor int top_right_rank; int top_right_coords[2] = {main_coords[0]+1, main_coords[1]+1}; MPI_Cart_rank (comm_cart, top_right_coords,...

mpi program hangs at MPI_SEND

mpi program hangs at MPI_SEND I got the above mentioned error on running the following program in C. It uses the MPI library. #include "mpi.h" #include <stdio.h> #include <stdlib.h> int main (int argc, char *argv) { int numranks, rank, dest, tag, source, rc, count; char inmsg, outmsg='x'; MPI_Status Stat; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD, &numranks); MPI_Comm_rank(MPI_COMM_WORLD, &rank); printf("Task %d starting...n",rank); if (rank == 0) { if (numranks > 2) printf("Numranks=%d. Only 2 needed. Ignoring extra...n",numranks); dest = rank + 1; source = dest; tag = rank; rc = MPI_Send(&outmsg, 1, MPI_CHAR, dest, tag, MPI_COMM_WORLD); printf("Sent to task %d...n",dest); rc = MPI_Recv(&inmsg, 1, MPI_CHAR, source, tag, MPI_COMM_WORLD, &Stat); printf("Received from task %d...n",source); } else if (rank == 1) { dest = rank - 1; s...