Skip to content

Instantly share code, notes, and snippets.

@NK-Nikunj
Last active January 9, 2020 21:57
Show Gist options
  • Save NK-Nikunj/c7845340d517f4c0e237226f5c9cb254 to your computer and use it in GitHub Desktop.
Save NK-Nikunj/c7845340d517f4c0e237226f5c9cb254 to your computer and use it in GitHub Desktop.
Basic non working MPI program
#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;
}
#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