Commit 56d0fc13 authored by Pietro Incardona's avatar Pietro Incardona

DLB Merged

parents b8bc0474 b7fafe44
......@@ -29,9 +29,7 @@ m4_ifdef([ACX_MPI],,[m4_include([m4/acx_mpi.m4])])
m4_ifdef([AX_OPENMP],,[m4_include([m4/ax_openmp.m4])])
m4_ifdef([AX_CUDA],,[m4_include([m4/ax_cuda.m4])])
m4_ifdef([IMMDX_LIB_METIS],,[m4_include([m4/immdx_lib_metis.m4])])
<<<<<<< HEAD
m4_ifdef([IMMDX_LIB_PARMETIS],,[m4_include([m4/immdx_lib_parmetis.m4])])
=======
m4_ifdef([AX_BOOST_BASE],,[m4_include([m4/ax_boost_base.m4])])
m4_ifdef([AX_BOOST_IOSTREAMS],,[m4_include([m4/ax_boost_iostreams.m4])])
m4_ifdef([AX_BOOST_PROGRAM_OPTIONS],,[m4_include([m4/ax_boost_program_options.m4])])
......@@ -52,7 +50,6 @@ case $host_os in
CXXFLAGS+=" --std=c++11 "
;;
esac
>>>>>>> master
NVCCFLAGS=" "
INCLUDES_PATH=" "
......
......@@ -151,7 +151,7 @@ private:
* \param v_cl Virtual cluster, used internally for communications
*
*/
void CreateDecomposition(Vcluster & v_cl, const size_t (& bc)[dim])
void createSubdomains(Vcluster & v_cl, const size_t (& bc)[dim])
{
#ifdef SE_CLASS1
if (&v_cl == NULL)
......@@ -179,7 +179,7 @@ private:
// Optimize the decomposition creating bigger spaces
// And reducing Ghost over-stress
dec_optimizer<dim, DistGraph_CSR<nm_v, nm_e>> d_o(dist.getGraph(), gr.getSize());
dec_optimizer<dim, Graph_CSR<nm_v, nm_e>> d_o(dist.getGraph(), gr.getSize());
// set of Boxes produced by the decomposition optimizer
openfpm::vector<::Box<dim, size_t>> loc_box;
......@@ -1159,7 +1159,7 @@ public:
dist.decompose();
//CreateDecomposition(v_cl);
createSubdomains(v_cl);
}
/*! \brief Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call
......@@ -1185,7 +1185,7 @@ public:
dlb.setUnbalance(unbalance);
if (v_cl.getProcessUnitID() == 0)
{
std::cout << std::setprecision(3) << unbalance << "\n";
//std::cout << std::setprecision(3) << unbalance << "\n";
}
}
......
......@@ -284,7 +284,7 @@ public:
//! Get the number of processing units
size_t Np = v_cl.getProcessingUnits();
parmetis_graph.initSubGraph(sub_g);
parmetis_graph.initSubGraph(sub_g, verticesGotWeights);
//! Decompose
parmetis_graph.decompose<nm_v::proc_id>(vtxdist, sub_g);
......@@ -487,7 +487,7 @@ public:
{
load += sub_g.vertex(i).template get<nm_v::computation>();
}
std::cout << v_cl.getProcessUnitID() << " weight " << load << " size " << sub_g.getNVertex() << "\n";
//std::cout << v_cl.getProcessUnitID() << " weight " << load << " size " << sub_g.getNVertex() << "\n";
return load;
}
......
......@@ -65,6 +65,11 @@ struct node
return *this;
}
static bool noPointers()
{
return true;
}
};
......@@ -80,8 +85,6 @@ static void * message_receive(size_t msg_i, size_t total_msg, size_t total_p, si
}
BOOST_AUTO_TEST_SUITE (DistCartesianGraphFactory_test)
BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_3D_use)
......@@ -149,6 +152,9 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
// Vcluster
Vcluster & vcl = *global_v_cluster;
if(vcl.getProcessingUnits() != 2)
return;
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
......
......@@ -16,37 +16,6 @@
#include "Space/Shape/HyperCube.hpp"
#include "parmetis.h"
/*! \brief Operator to fill the property 'prp' with the linearization of indexes
*
* \tparam dim Dimension of the space
* \tparam G_v Graph
* \tparam prp Property to fill
*/
template<unsigned int dim, typename G_v, int prp_l, int prp_g>
struct fill_lin_id
{
static inline void fill(G_v & g_v, const grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs)
{
// Local id
g_v.template get<prp_l>() = gs.LinId(gk);
// Global id
g_v.template get<prp_g>() = gs.LinId(gk);
}
};
/*! \brief Operator to fill the property in case there are no properties
*
* \tparam dim Dimension of the space
* \tparam G_v Graph
*/
template<unsigned int dim, typename G_v>
struct fill_lin_id<dim, G_v, -1, -1>
{
static inline void fill(G_v & g_v, const grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs)
{
}
};
/*! \brief This class work as a functor
*
* For each number in the boost::mpl::vector (for example 3 6) set the properties of the vertex at the
......@@ -75,7 +44,7 @@ struct fill_lin_id<dim, G_v, -1, -1>
*
*/
template<unsigned int dim, int vid, int gid, typename dT, typename G_v, typename v, int impl>
template<unsigned int dim, typename dT, typename G_v, typename v, int impl>
class fill_prop_v
{
//! Reference to an array containing the spacing
......@@ -105,10 +74,10 @@ public:
typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<T::value>>::type t_val;
g_v.template get<t_val::value>() = gk.get(T::value) * szd[T::value];
fill_lin_id<dim, G_v, vid, gid>::fill(g_v, gk, gs);
}
};
/*! \brief This class work as a functor
*
* For each number in the boost::mpl::vector (for example 3 6) set the properties of the vertex at the
......@@ -135,8 +104,8 @@ public:
*
*/
template<unsigned int dim, int vid, int gid, typename dT, typename G_v, typename v>
class fill_prop_v<dim, vid, gid, dT, G_v, v, 0>
template<unsigned int dim, typename dT, typename G_v, typename v>
class fill_prop_v<dim, dT, G_v, v, 0>
{
public:
......@@ -179,8 +148,8 @@ public:
*
*/
template<unsigned int dim, int vid, int gid, typename dT, typename G_v, typename v>
class fill_prop_v<dim, vid, gid, dT, G_v, v, 2>
template<unsigned int dim, typename dT, typename G_v, typename v>
class fill_prop_v<dim, dT, G_v, v, 2>
{
//! Reference to an array containing the spacing
......@@ -210,7 +179,6 @@ public:
typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<0>>::type t_val;
g_v.template get<t_val::value>()[T::value] = gk.get(T::value) * szd[T::value];
fill_lin_id<dim, G_v, vid, gid>::fill(g_v, gk, gs);
}
};
......@@ -260,7 +228,7 @@ struct fill_prop_v_by_type<0, p, Graph, pos...>
*
*/
template<unsigned int dim, int vid, int gid, int sgid, int dgid, typename Graph, int se, typename T, unsigned int dim_c, int ... pos>
template<unsigned int dim, typename Graph, int se, typename T, unsigned int dim_c, int ... pos>
class DistGraph_constr_impl
{
public:
......@@ -349,7 +317,7 @@ public:
// vertex spatial properties functor
fill_prop_v<dim, vid, gid, T, decltype(gp.vertex(local_it)), typename to_boost_vmpl<pos...>::type, fill_prop_v_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
fill_prop_v<dim, T, decltype(gp.vertex(local_it)), typename to_boost_vmpl<pos...>::type, fill_prop_v_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
// fill properties
......@@ -414,8 +382,8 @@ public:
*
*/
template<unsigned int dim, int vid, int gid, int sgid, int dgid, typename Graph, typename T, unsigned int dim_c, int ... pos>
class DistGraph_constr_impl<dim, vid, gid, sgid, dgid, Graph, NO_EDGE, T, dim_c, pos...>
template<unsigned int dim, typename Graph, typename T, unsigned int dim_c, int ... pos>
class DistGraph_constr_impl<dim, Graph, NO_EDGE, T, dim_c, pos...>
{
public:
//! Construct Cartesian graph
......@@ -501,7 +469,7 @@ public:
// vertex spatial properties functor
fill_prop_v<dim, vid, gid, T, decltype(gp.vertex(local_it)), typename to_boost_vmpl<pos...>::type, fill_prop_v_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
fill_prop_v<dim, T, decltype(gp.vertex(local_it)), typename to_boost_vmpl<pos...>::type, fill_prop_v_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
// fill properties
......@@ -544,7 +512,7 @@ public:
if (end_v < g.size())
{
// Add an edge and set the the edge property to the size of the face (communication weight)
gp.template addEdge<NoCheck, sgid, dgid>(start_v, end_v, v_id, end_v);
gp.template addEdge_new(start_v, end_v, v_id, end_v);
}
}
}
......@@ -570,11 +538,7 @@ class DistGraphFactory
public:
/*!
*
* \brief Construct a cartesian graph, with V and E edge properties
*
* Construct a cartesian graph, with V and E edge properties
/*! \brief Construct a cartesian graph, with V and E edge properties
*
* Each vertex is a subspace (Hyper-cube) of dimension dim, each vertex is
* connected with an edge if two vertex (Hyper-cube) share a element of dimension grater than
......@@ -596,41 +560,8 @@ public:
template<int se, typename T, unsigned int dim_c, int ... pos>
static Graph construct(const size_t (&sz)[dim], Box<dim, T> dom)
{
return DistGraph_constr_impl<dim, -1, -1, -1, -1, Graph, se, T, dim_c, pos...>::construct(sz, dom);
}
/*!
*
* \brief Construct a cartesian graph, with V and E edge properties
*
* Construct a cartesian graph, with V and E edge properties
*
* Each vertex is a subspace (Hyper-cube) of dimension dim, each vertex is
* connected with an edge if two vertex (Hyper-cube) share a element of dimension grater than
* dim_c. One property can be used to store the contact size or the d-dimensional
* surface in common between two connected hyper-cube.
*
* \param sz Vector that store the size of the grid on each dimension
* \param dom Box enclosing the physical domain
*
* \tparam se Indicate which properties fill with the contact size. The
* contact size is the point, line , surface, d-dimensional object size
* in contact (in common) between two hyper-cube. NO_EDGE indicate
* no property will store this information
* \tparam vid property that stores the local vertex id
* \tparam gid property that stores the local vertex id
* \tparam sgid property that stores on the edge global id of the source vertex
* \tparam dgid property that stores on the edge global id of the destination vertex
* \tparam T type of the domain like (int real complex ... )
* \tparam dim_c Connectivity dimension
* \tparam pos... (optional)one or more integer indicating the spatial properties
*
*/
template<int se, int vid, int gid, int sgid, int dgid, typename T, unsigned int dim_c, int ... pos>
static Graph construct(const size_t (&sz)[dim], Box<dim, T> dom)
{
return DistGraph_constr_impl<dim, vid, gid, sgid, dgid, Graph, se, T, dim_c, pos...>::construct(sz, dom);
return DistGraph_constr_impl<dim, Graph, se, T, dim_c, pos...>::construct(sz, dom);
}
};
#endif /* DISTCARTESIANGRAPHFACTORY_HPP_ */
#endif /* DISTGRAPHFACTORY_HPP_ */
This diff is collapsed.
This diff is collapsed.
......@@ -494,6 +494,8 @@ class grid_dist_id
// fill the global size of the grid
for (size_t i = 0 ; i < dim ; i++) {this->g_sz[i] = g_sz[i];}
dec.decompose();
// Create local grid
Create();
}
......
......@@ -1062,12 +1062,15 @@ void Test3D_dup(const Box<3,float> & domain, long int k)
//! [Construct two grid with the same decomposition]
<<<<<<< HEAD
bool ret = g_dist2.getDecomposition().check_consistency();
BOOST_REQUIRE_EQUAL(ret,true);
ret = g_dist2.getDecomposition().is_equal(g_dist2.getDecomposition());
BOOST_REQUIRE_EQUAL(ret,true);
=======
>>>>>>> b7fafe4436dc0bbd95c31dc205b0ee8def38730d
auto dom_g1 = g_dist1.getDomainIterator();
auto dom_g2 = g_dist2.getDomainIterator();
......
......@@ -694,6 +694,7 @@ public:
// Create the sub-domains
dec.setParameters(div,box,bc,g);
dec.decompose();
// and create the ghost boxes
dec.calculateGhostBoxes();
......
......@@ -29,7 +29,7 @@
#include "dec_optimizer_unit_test.hpp"
#include "Grid/grid_dist_id_unit_test.hpp"
#include "Vector/vector_dist_unit_test.hpp"
#include "Decomposition/DLB_unit_test.hpp"
#include "Graph/dist_map_graph_unit_test.hpp"
//#include "Decomposition/DLB_unit_test.hpp"
//#include "Graph/dist_map_graph_unit_test.hpp"
#include "Graph/DistGraphFactory.hpp"
//#include "Decomposition/nn_processor_unit_test.hpp"
......@@ -129,7 +129,8 @@ class Metis
*/
void constructAdjListWithWeights(Graph & g)
{
// create xadj and adjlist
Mg.vwgt = new idx_t[1];
Mg.vwgt[0] = 2;
// create xadj, adjlist, vwgt, adjwgt and vsize
Mg.xadj = new idx_t[g.getNVertex() + 1];
......@@ -334,8 +335,7 @@ public:
if (Mg.nparts[0] != 1)
{
// Decompose
METIS_PartGraphRecursive(Mg.nvtxs, Mg.ncon, Mg.xadj, Mg.adjncy, Mg.vwgt, Mg.vsize, Mg.adjwgt, Mg.nparts,
Mg.tpwgts, Mg.ubvec, Mg.options, Mg.objval, Mg.part);
METIS_PartGraphRecursive(Mg.nvtxs, Mg.ncon, Mg.xadj, Mg.adjncy, Mg.vwgt, Mg.vsize, Mg.adjwgt, Mg.nparts, Mg.tpwgts, Mg.ubvec, Mg.options, Mg.objval, Mg.part);
// vertex id
......@@ -378,8 +378,7 @@ public:
void decompose(Graph_part & gp)
{
// Decompose
METIS_PartGraphRecursive(Mg.nvtxs, Mg.ncon, Mg.xadj, Mg.adjncy, Mg.vwgt, Mg.vsize, Mg.adjwgt, Mg.nparts, Mg.tpwgts,
Mg.ubvec, Mg.options, Mg.objval, Mg.part);
METIS_PartGraphRecursive(Mg.nvtxs, Mg.ncon, Mg.xadj, Mg.adjncy, Mg.vwgt, Mg.vsize, Mg.adjwgt, Mg.nparts, Mg.tpwgts, Mg.ubvec, Mg.options, Mg.objval, Mg.part);
// vertex id
......
......@@ -377,9 +377,9 @@ public:
/*! \brief Set the Sub-graph
*
* \param sub_g Sub-graph to set
*
* \param w true if vertices have weights
*/
void initSubGraph(Graph & sub_g)
void initSubGraph(Graph & sub_g, bool w)
{
p_id = v_cl.getProcessUnitID();
......@@ -448,7 +448,11 @@ public:
//! This is used to indicate if the graph is weighted. wgtflag can take one of four values:
Mg.wgtflag = new idx_t[1];
Mg.wgtflag[0] = 3;
if(w)
Mg.wgtflag[0] = 3;
else
Mg.wgtflag[0] = 0;
}
/*! \brief Decompose the graph
......
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