-
-
Save ikirill/30118fc521144e0e7d71a066261cbdde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
#include <thread> | |
#include <unistd.h> | |
#include "mpi.h" | |
using namespace std; | |
#define db(x) #x << "=" << (x) << " " | |
int main(int argc, char** argv) { | |
MPI_Init(&argc, &argv); | |
// int provided; | |
// MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided); | |
// cerr << db(provided) << endl; | |
int rank, size; | |
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
MPI_Comm_size(MPI_COMM_WORLD, &size); | |
cerr << db(rank) << db(size) << endl; | |
cerr << db(rank) << "posting barrier" << endl; | |
MPI_Request barrier; | |
MPI_Ibarrier(MPI_COMM_WORLD, &barrier); | |
cerr << db(rank) << "posted barrier" << endl; | |
sleep(1); | |
cerr << db(rank) << "done sleeping" << endl; | |
int flag1; | |
MPI_Test(&barrier, &flag1, MPI_STATUS_IGNORE); | |
cerr << db(rank) << db(flag1) << endl; | |
int flag2; | |
MPI_Test(&barrier, &flag2, MPI_STATUS_IGNORE); | |
cerr << db(rank) << db(flag2) << endl; | |
MPI_Wait(&barrier, MPI_STATUS_IGNORE); | |
cerr << db(rank) << "done" << endl; | |
MPI_Finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment