Skip to content

Instantly share code, notes, and snippets.

@calorie
Created October 19, 2014 14:43
Show Gist options
  • Save calorie/102710b69f659a7577f7 to your computer and use it in GitHub Desktop.
Save calorie/102710b69f659a7577f7 to your computer and use it in GitHub Desktop.
#include "mpi.h"
#include <stdio.h>
int
sync()
{
int rank, val = 0;
MPI_Request request;
MPI_Status status;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 1) {
MPI_Recv(&val, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
}
if (rank == 0) {
val = 1;
MPI_Send(&val, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
}
return val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment