Commit 0c6528bd authored by incardon's avatar incardon

Fixing MPI_Init and Finalize

parent d8b66a8a
......@@ -14,16 +14,8 @@ void init_global_v_cluster(int *argc, char ***argv)
global_v_cluster = new Vcluster(argc,argv);
}
// Deallocator object, it deallocate the global_v_cluster at the end of the program
class init_glob_v_cluster
{
public:
~init_glob_v_cluster()
{
delete global_v_cluster;
};
};
// Global MPI initialization
bool global_mpi_init = false;
// Deallocate at the end
init_glob_v_cluster v_cls;
// number of vcluster instances
size_t n_vcluster = 0;
......@@ -22,6 +22,9 @@
}\
}
extern size_t n_vcluster;
extern bool global_mpi_init;
///////////////////// Post functions /////////////
template<typename T> void assign(T * ptr1, T * ptr2)
......@@ -125,11 +128,24 @@ public:
// Finalize the MPI program
~Vcluster()
{
n_vcluster--;
// if there are no other vcluster instances finalize
if (n_vcluster == 0)
MPI_Finalize();
}
//! \brief Virtual cluster constructor
Vcluster(int *argc, char ***argv)
{
n_vcluster++;
// Check if MPI is already initialized
if (global_mpi_init == false)
{
MPI_Init(argc,argv);
global_mpi_init = true;
}
//! Get the total number of process
//! and the rank of this process
......
......@@ -3,12 +3,12 @@
#include <boost/test/included/unit_test.hpp>
#include "VCluster.hpp"
struct MPIFixture {
/*struct MPIFixture {
MPIFixture() { MPI_Init(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);}
~MPIFixture() { MPI_Finalize(); }
};
BOOST_GLOBAL_FIXTURE(MPIFixture);
BOOST_GLOBAL_FIXTURE(MPIFixture);*/
#include "unit_test_init_cleanup.hpp"
#include "VCluster_unit_tests.hpp"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment