Simple MPI message passing program stuck in loop

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Simple MPI message passing program stuck in loop



I'm writing this MPI program where two processes pass messages back and forth to one another. My issue is that the program is stuck in an infinite loop. The issue is most certainly with my send and receive commands, I'm not familiar with using them and I'm not sure what is wrong with them.



Here is the code:


#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#define COUNTS 5

int main(int argc, char *argv)
int id;
int p;

MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
MPI_Comm_size(MPI_COMM_WORLD, &p);

int num = 0;
if (id == 0)
tic = MPI_Wtime();
for (int i = 0; i < COUNTS; i++)
MPI_Ssend(&num, 1, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD);

MPI_Recv(&num, 1, MPI_DOUBLE, 1, 0,
MPI_COMM_WORLD, MPI_STATUS_IGNORE);


else
for (int j = 0; j < COUNTS; j++)
MPI_Recv(&num, 0, MPI_DOUBLE, 0, 1,
MPI_COMM_WORLD, MPI_STATUS_IGNORE);

MPI_Ssend(&num, 0, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);



MPI_Finalize();










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS