Commit cfa6f9ba authored by incardon's avatar incardon

Fixing Metis decomposition

parent 106625f9
...@@ -85,6 +85,8 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test) ...@@ -85,6 +85,8 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test)
met_dist.createCartGraph(info,box); met_dist.createCartGraph(info,box);
met_dist.decompose(); met_dist.decompose();
BOOST_REQUIRE_EQUAL(met_dist.get_ndec(),1ul);
//! [Initialize a Metis Cartesian graph and decompose] //! [Initialize a Metis Cartesian graph and decompose]
BOOST_REQUIRE(met_dist.getUnbalance() < 0.03); BOOST_REQUIRE(met_dist.getUnbalance() < 0.03);
...@@ -122,6 +124,8 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test) ...@@ -122,6 +124,8 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test)
met_dist.decompose(); met_dist.decompose();
BOOST_REQUIRE_EQUAL(met_dist.get_ndec(),2ul);
//! [Decomposition Metis with weights] //! [Decomposition Metis with weights]
BOOST_REQUIRE(met_dist.getUnbalance() < 0.06); BOOST_REQUIRE(met_dist.getUnbalance() < 0.06);
...@@ -164,7 +168,7 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test) ...@@ -164,7 +168,7 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test)
// operator= functions // operator= functions
// operator== functions // operator== functions
BOOST_REQUIRE_EQUAL(sizeof(MetisDistribution<3,float>),712ul); BOOST_REQUIRE_EQUAL(sizeof(MetisDistribution<3,float>),720ul);
} }
BOOST_AUTO_TEST_CASE( Parmetis_distribution_test) BOOST_AUTO_TEST_CASE( Parmetis_distribution_test)
...@@ -197,6 +201,8 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test) ...@@ -197,6 +201,8 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test)
// first decomposition // first decomposition
pmet_dist.decompose(); pmet_dist.decompose();
BOOST_REQUIRE_EQUAL(pmet_dist.get_ndec(),1ul);
//! [Initialize a ParMetis Cartesian graph and decompose] //! [Initialize a ParMetis Cartesian graph and decompose]
if (v_cl.getProcessUnitID() == 0) if (v_cl.getProcessUnitID() == 0)
...@@ -225,6 +231,7 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test) ...@@ -225,6 +231,7 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test)
Point<3, float> shift( { tstep, tstep, tstep }); Point<3, float> shift( { tstep, tstep, tstep });
size_t iter = 1; size_t iter = 1;
size_t n_dec = 1;
for(float t = stime; t < etime; t = t + tstep, iter++) for(float t = stime; t < etime; t = t + tstep, iter++)
{ {
...@@ -239,6 +246,8 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test) ...@@ -239,6 +246,8 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test)
if ((size_t)iter % 10 == 0) if ((size_t)iter % 10 == 0)
{ {
pmet_dist.refine(); pmet_dist.refine();
n_dec++;
BOOST_REQUIRE_EQUAL(pmet_dist.get_ndec(),n_dec);
if (v_cl.getProcessUnitID() == 0) if (v_cl.getProcessUnitID() == 0)
{ {
......
...@@ -259,6 +259,10 @@ public: ...@@ -259,6 +259,10 @@ public:
} }
} }
} }
else
{
metis_graph.inc_dec();
}
recv_ass.resize(gp.getNVertex()); recv_ass.resize(gp.getNVertex());
...@@ -652,6 +656,16 @@ public: ...@@ -652,6 +656,16 @@ public:
size_t ids = fnd->second; size_t ids = fnd->second;
return owner_cost_sub.get(ids).w; return owner_cost_sub.get(ids).w;
} }
/*! \brief Get the decomposition counter
*
* \return the decomposition counter
*
*/
size_t get_ndec()
{
return metis_graph.get_ndec();
}
}; };
#endif /* SRC_DECOMPOSITION_METISDISTRIBUTION_HPP_ */ #endif /* SRC_DECOMPOSITION_METISDISTRIBUTION_HPP_ */
...@@ -78,8 +78,8 @@ class Metis ...@@ -78,8 +78,8 @@ class Metis
//! Original graph //! Original graph
Graph & g; Graph & g;
//Check if weights are available //! indicate how many time decompose/refine/re-decompose has been called
// bool useWeights = false; size_t n_dec;
//! Distribution tolerance //! Distribution tolerance
real_t dist_tol = 1.05; real_t dist_tol = 1.05;
...@@ -189,7 +189,7 @@ public: ...@@ -189,7 +189,7 @@ public:
* *
*/ */
Metis(Graph & g, size_t nc, bool useWeights) Metis(Graph & g, size_t nc, bool useWeights)
:g(g) :g(g),n_dec(0)
{ {
initMetisGraph(nc,useWeights); initMetisGraph(nc,useWeights);
} }
...@@ -202,8 +202,8 @@ public: ...@@ -202,8 +202,8 @@ public:
* \param nc number of partitions * \param nc number of partitions
* *
*/ */
Metis(Graph & g, size_t nc) : Metis(Graph & g, size_t nc)
g(g) :g(g),n_dec(0)
{ {
initMetisGraph(nc,false); initMetisGraph(nc,false);
} }
...@@ -217,7 +217,7 @@ public: ...@@ -217,7 +217,7 @@ public:
* *
*/ */
Metis(Graph & g) Metis(Graph & g)
:g(g) :g(g),n_dec(0)
{ {
Mg.nvtxs = NULL; Mg.nvtxs = NULL;
Mg.ncon = NULL; Mg.ncon = NULL;
...@@ -402,6 +402,8 @@ public: ...@@ -402,6 +402,8 @@ public:
++it; ++it;
} }
} }
n_dec++;
} }
/*! \brief Decompose the graph /*! \brief Decompose the graph
...@@ -431,6 +433,8 @@ public: ...@@ -431,6 +433,8 @@ public:
++id; ++id;
++it; ++it;
} }
n_dec++;
} }
/*! \brief It set Metis on test /*! \brief It set Metis on test
...@@ -467,6 +471,25 @@ public: ...@@ -467,6 +471,25 @@ public:
{ {
dist_tol = tol; dist_tol = tol;
} }
/*! \brief Get the decomposition counter
*
* \return the decomposition counter
*
*/
size_t get_ndec()
{
return n_dec;
}
/*! \brief Increment the decomposition counter
*
*
*/
void inc_dec()
{
n_dec++;
}
}; };
#endif #endif
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