Last active
January 9, 2020 21:57
-
-
Save NK-Nikunj/c7845340d517f4c0e237226f5c9cb254 to your computer and use it in GitHub Desktop.
Basic non working MPI program
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 <mpi.h> | |
#include <iostream> | |
int main(int argc, char ** argv) | |
{ | |
MPI_Init(&argc, &argv); | |
MPI::COMM_WORLD.Set_errhandler ( MPI::ERRORS_THROW_EXCEPTIONS ); | |
try{ | |
MPI_Init(&argc, &argv); | |
} catch(MPI::Exception e){} | |
MPI_Finalize(); | |
return 0; | |
} |
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 <mpi.h> | |
#include <iostream> | |
#include <cassert> | |
int main(int argc, char ** argv) | |
{ | |
MPI_Init(&argc, &argv); | |
// MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); | |
// MPI::COMM_WORLD.Set_errhandler ( MPI::RETURN_ERRORS ); | |
// MPI_Comm_set_errhandler (MPI_COMM_WORLD, MPI_ERRORS_RETURN); | |
// assert(MPI_COMM_WORLD == MPI_COMM_NULL); | |
int is_initialized = -1; | |
MPI_Initialized(&is_initialized); | |
if(!is_initialized) | |
{ | |
MPI_Init(&argc, &argv); | |
} | |
else | |
{ | |
std::cout << "MPI environment is already initialized" << std::endl; | |
} | |
MPI_Finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment