Commit 3aed0e79 authored by Pietro Incardona's avatar Pietro Incardona

CartDecomposition Parametis working

parent 56d0fc13
openfpm_data @ 7b47257e
Subproject commit 7e41886aadce576e0e46c8f0eb60ba11473b64ca
Subproject commit 7b47257e320d89574044006513fba47a469ac415
openfpm_io @ ffdf8f16
Subproject commit dbc37efff49ac7622db19f3944422e496fc5cdc6
Subproject commit ffdf8f1617461edd04f39af5a4363d7933ec5906
......@@ -29,7 +29,7 @@
#include "ie_loc_ghost.hpp"
#include "ie_ghost.hpp"
#include "nn_processor.hpp"
#include "GraphMLWriter.hpp"
#include "GraphMLWriter/GraphMLWriter.hpp"
#include "ParMetisDistribution.hpp"
#include "DistParMetisDistribution.hpp"
#include "MetisDistribution.hpp"
......@@ -79,7 +79,7 @@
*
*/
template<unsigned int dim, typename T, typename Memory = HeapMemory, typename Distribution = DistParMetisDistribution<dim, T>>
template<unsigned int dim, typename T, typename Memory = HeapMemory, typename Distribution = ParMetisDistribution<dim, T>>
class CartDecomposition: public ie_loc_ghost<dim, T>, public nn_prcs<dim, T>, public ie_ghost<dim, T>
{
......@@ -321,7 +321,7 @@ private:
float gh_v = (gh_s * b_s);
// multiply for sub-sub-domain side for each domain
for (int i = 2; i < dim; i++)
for (size_t i = 2; i < dim; i++)
gh_v *= b_s;
size_t norm = (size_t) (1.0 / gh_v);
......@@ -531,7 +531,7 @@ public:
*
*/
CartDecomposition(const CartDecomposition<dim,T,Memory> & cart)
:nn_prcs<dim,T>(cart.v_cl),v_cl(cart.v_cl),ref_cnt(0)
:nn_prcs<dim,T>(cart.v_cl),v_cl(cart.v_cl),dist(v_cl),ref_cnt(0)
{
this->operator=(cart);
}
......@@ -542,7 +542,7 @@ public:
*
*/
CartDecomposition(CartDecomposition<dim,T,Memory> && cart)
:nn_prcs<dim,T>(cart.v_cl),v_cl(cart.v_cl),ref_cnt(0)
:nn_prcs<dim,T>(cart.v_cl),v_cl(cart.v_cl),dist(v_cl),ref_cnt(0)
{
this->operator=(cart);
}
......@@ -824,6 +824,8 @@ public:
cart.ss_box = ss_box;
cart.ghost = g;
cart.dist = dist;
for (size_t i = 0 ; i < dim ; i++)
cart.bc[i] = bc[i];
......@@ -900,6 +902,7 @@ public:
cart.v_cl = v_cl;
cart.ghost = g;
cart.dist = dist;
for (size_t i = 0 ; i < dim ; i++)
cart.bc[i] = bc[i];
......@@ -1159,7 +1162,7 @@ public:
dist.decompose();
createSubdomains(v_cl);
createSubdomains(v_cl,bc);
}
/*! \brief Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call
......
......@@ -16,45 +16,37 @@ void setComputationCosts(CartDecomposition<2, float> &dec, size_t n_v, Point<2,
// Position structure for the single vertex
float pos[2];
for (int i = 0; i < n_v; i++)
for (size_t i = 0; i < n_v; i++)
{
dec.getSubSubDomainPosition(i, pos);
eq = pow((pos[0] - center.get(0)), 2) + pow((pos[1] - center.get(1)), 2);
if (eq <= radius2)
{
dec.setSubSubDomainComputationCost(i, weight_h);
}
else
{
dec.setSubSubDomainComputationCost(i, weight_l);
}
}
}
void setComputationCosts3D(CartDecomposition<3, float> &dec, size_t n_v, Point<3, float> center, float radius, size_t weight_h, size_t weight_l)
{
float radius2 = pow(radius, 2);
float radius2 = radius * radius;
float eq;
// Position structure for the single vertex
float pos[3];
for (int i = 0; i < n_v; i++)
for (size_t i = 0; i < n_v; i++)
{
dec.getSubSubDomainPosition(i, pos);
eq = pow((pos[0] - center.get(0)), 2) + pow((pos[1] - center.get(1)), 2) + pow((pos[2] - center.get(2)), 2);
if (eq <= radius2)
{
dec.setSubSubDomainComputationCost(i, weight_h);
}
else
{
dec.setSubSubDomainComputationCost(i, weight_l);
}
}
}
......@@ -65,6 +57,9 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_2D )
// Vcluster
Vcluster & vcl = *global_v_cluster;
// non-periodic boundary condition
size_t bc[2] = {NON_PERIODIC,NON_PERIODIC};
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
......@@ -93,7 +88,7 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_2D )
Ghost<2, float> g(0.01);
// Decompose
dec.setParameters(div, box, g);
dec.setParameters(div, box, bc, g);
// Set unbalance threshold
dlb.setHeurisitc(DLB::Heuristic::UNBALANCE_THRLD);
......@@ -185,6 +180,9 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_2D_sar)
// Vcluster
Vcluster & vcl = *global_v_cluster;
// non-periodic boundary condition
size_t bc[2] = {NON_PERIODIC,NON_PERIODIC};
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
......@@ -213,7 +211,7 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_2D_sar)
Ghost<2, float> g(0.01);
// Decompose
dec.setParameters(div, box, g);
dec.setParameters(div, box, bc, g);
// Set type of heuristic
dlb.setHeurisitc(DLB::Heuristic::SAR_HEURISTIC);
......@@ -321,6 +319,9 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_3D)
// Vcluster
Vcluster & vcl = *global_v_cluster;
// non-periodic boundary condition
size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
......@@ -349,7 +350,7 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_3D)
Ghost<3, float> g(0.01);
// Decompose
dec.setParameters(div, box, g);
dec.setParameters(div, box, bc, g);
// Set unbalance threshold
dlb.setHeurisitc(DLB::Heuristic::UNBALANCE_THRLD);
......@@ -376,7 +377,7 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_3D)
float stime = 0.0, etime = 10.0, tstep = 0.1;
for(float t = stime, i = 1, t_sim = 1; t < etime; t = t + tstep, i++)
for(float t = stime, i = 1; t < etime; t = t + tstep, i++)
{
if(t < etime/2)
......
......@@ -12,7 +12,7 @@
#ifndef SRC_DECOMPOSITION_DISTPARMETISDISTRIBUTION_HPP_
#define SRC_DECOMPOSITION_DISTPARMETISDISTRIBUTION_HPP_
template<unsigned int dim, typename T, template<unsigned int, typename > class Domain = Box>
template<unsigned int dim, typename T>
class DistParMetisDistribution
{
//! Vcluster
......@@ -22,7 +22,7 @@ class DistParMetisDistribution
grid_sm<dim, void> gr;
//! rectangular domain to decompose
Domain<dim, T> domain;
Box<dim, T> domain;
//! Processor sub-sub-domain graph
DistGraph_CSR<nm_v, nm_e> sub_g;
......@@ -83,7 +83,7 @@ public:
* /param grid Grid
* /param dom Domain
*/
void init(grid_sm<dim, void> & grid, Domain<dim, T> dom)
void init(grid_sm<dim, void> & grid, Box<dim, T> dom)
{
//! Set grid and domain
gr = grid;
......@@ -91,7 +91,7 @@ public:
//! Create sub graph
DistGraphFactory<dim, DistGraph_CSR<nm_v, nm_e>> dist_g_factory;
sub_g = dist_g_factory.template construct<NO_EDGE, nm_v::id, nm_v::global_id, nm_e::srcgid, nm_e::dstgid, T, dim - 1, 0, 1, 2>(gr.getSize(), domain);
sub_g = dist_g_factory.template construct<NO_EDGE, T, dim - 1, 0, 1, 2>(gr.getSize(), domain);
sub_g.getDecompositionVector(vtxdist);
for(size_t i=0; i< sub_g.getNVertex(); i++)
sub_g.vertex(i).template get<nm_v::x>()[2] = 0;
......@@ -122,7 +122,7 @@ public:
for (size_t i = 0; i < sub_g.getNVertex(); ++i)
{
if (partition[i] != v_cl.getProcessUnitID())
if ((size_t)partition[i] != v_cl.getProcessUnitID())
sub_g.q_move(i, partition[i]);
}
sub_g.redistribute();
......@@ -364,6 +364,34 @@ public:
sub_g.deleteGhosts();
}
}
const DistParMetisDistribution<dim,T> & operator=(const DistParMetisDistribution<dim,T> & dist)
{
v_cl = dist.v_cl;
gr = dist.gr;
domain = dist.domain;
sub_g = dist.sub_g;
vtxdist = dist.vtxdist;
partitions = dist.partitions;
v_per_proc = dist.v_per_proc;
verticesGotWeights = dist.verticesGotWeights;
return *this;
}
const DistParMetisDistribution<dim,T> & operator=(const DistParMetisDistribution<dim,T> && dist)
{
v_cl = dist.v_cl;
gr = dist.gr;
domain = dist.domain;
sub_g.swap(dist.sub_g);
vtxdist.swap(dist.vtxdist);
partitions.swap(dist.partitions);
v_per_proc.swap(dist.v_per_proc);
verticesGotWeights = dist.verticesGotWeights;
return *this;
}
};
#endif /* SRC_DECOMPOSITION_PARMETISDISTRIBUTION_HPP_ */
......@@ -204,7 +204,7 @@ public:
*/
void printCurrentDecomposition(int id)
{
VTKWriter<Graph_CSR<nm_v, nm_e>, GRAPH> gv2(gp);
VTKWriter<Graph_CSR<nm_v, nm_e>, VTK_GRAPH> gv2(gp);
gv2.write("test_graph_" + std::to_string(id) + ".vtk");
}
......
......@@ -11,7 +11,7 @@
#ifndef SRC_DECOMPOSITION_PARMETISDISTRIBUTION_HPP_
#define SRC_DECOMPOSITION_PARMETISDISTRIBUTION_HPP_
template<unsigned int dim, typename T, template<unsigned int, typename > class Domain = Box>
template<unsigned int dim, typename T>
class ParMetisDistribution
{
//! Vcluster
......@@ -21,7 +21,7 @@ class ParMetisDistribution
grid_sm<dim, void> gr;
//! rectangular domain to decompose
Domain<dim, T> domain;
Box<dim, T> domain;
//! Global sub-sub-domain graph
Graph_CSR<nm_v, nm_e> gp;
......@@ -126,9 +126,7 @@ class ParMetisDistribution
// Create new n_vtxdist (1) (just count processors vertices)
n_vtxdist.get(partitions.get(i).get(k) + 1)++;
if
( gp.vertexByMapId(l).template get<nm_v::proc_id>()
!= partitions.get(i).get(k))
if (gp.vertexByMapId(l).template get<nm_v::proc_id>() != (size_t)partitions.get(i).get(k))
{
moved++;
}
......@@ -178,15 +176,15 @@ class ParMetisDistribution
// Renumbering subgraph
sub_g.resetLocalToGlobalMap();
for (size_t j = vtxdist.get(p_id), i = 0; j < vtxdist.get(p_id + 1); j++, i++)
for (size_t j = (size_t)vtxdist.get(p_id), i = 0; j < (size_t)vtxdist.get(p_id + 1); j++, i++)
{
sub_g.setMapId<nm_v::id>(j, sub_g.vertex(i).template get<nm_v::global_id>(), i);
}
// Renumbering main graph
for (size_t p = 0; p < Np; p++)
for (size_t p = 0; p < (size_t)Np; p++)
{
for (size_t j = vtxdist.get(p), i = 0; j < vtxdist.get(p + 1); j++, i++)
for (size_t j = (size_t)vtxdist.get(p), i = 0; j < (size_t)vtxdist.get(p + 1); j++, i++)
{
gp.setMapId<nm_v::id>(j, v_per_proc.get(p).get(i), v_per_proc.get(p).get(i));
}
......@@ -234,15 +232,20 @@ public:
* @param grid
* @param dom
*/
void init(grid_sm<dim, void> & grid, Domain<dim, T> dom)
void init(grid_sm<dim, void> & grid, Box<dim, T> dom)
{
size_t bc[dim];
for (size_t i = 0 ; i < dim ; i++)
bc[i] = NON_PERIODIC;
// Set grid and domain
gr = grid;
domain = dom;
// Create a cartesian grid graph
CartesianGraphFactory<dim, Graph_CSR<nm_v, nm_e>> g_factory_part;
gp = g_factory_part.template construct<NO_EDGE, nm_v::id, T, dim - 1, 0, 1, 2>(gr.getSize(), domain);
gp = g_factory_part.template construct<NO_EDGE, nm_v::id, T, dim - 1, 0, 1, 2>(gr.getSize(), domain, bc);
gp.initLocalToGlobalMap();
// Create sub graph
......@@ -346,7 +349,7 @@ public:
std::copy(partition, partition + sub_g.getNVertex(), &partitions.get(p_id).get(0));
// Reset data structure to keep trace of new vertices distribution in processors (needed to update main graph)
for (int i = 0; i < Np; ++i)
for (size_t i = 0; i < Np; ++i)
{
v_per_proc.get(i).clear();
}
......@@ -587,11 +590,41 @@ public:
{
if (v_cl.getProcessUnitID() == 0)
{
VTKWriter<Graph_CSR<nm_v, nm_e>, GRAPH> gv2(gp);
VTKWriter<Graph_CSR<nm_v, nm_e>, VTK_GRAPH> gv2(gp);
gv2.write("test_graph_" + std::to_string(id) + ".vtk");
}
}
const ParMetisDistribution<dim,T> & operator=(const ParMetisDistribution<dim,T> & dist)
{
v_cl = dist.v_cl;
gr = dist.gr;
domain = dist.domain;
sub_g = dist.sub_g;
gp = dist.gp;
vtxdist = dist.vtxdist;
partitions = dist.partitions;
v_per_proc = dist.v_per_proc;
verticesGotWeights = dist.verticesGotWeights;
return *this;
}
const ParMetisDistribution<dim,T> & operator=(const ParMetisDistribution<dim,T> && dist)
{
v_cl = dist.v_cl;
gr = dist.gr;
domain = dist.domain;
sub_g.swap(dist.sub_g);
gp.swap(dist.gp);
vtxdist.swap(dist.vtxdist);
partitions.swap(dist.partitions);
v_per_proc.swap(dist.v_per_proc);
verticesGotWeights = dist.verticesGotWeights;
return *this;
}
};
#endif /* SRC_DECOMPOSITION_PARMETISDISTRIBUTION_HPP_ */
......@@ -14,6 +14,8 @@
#include "Space/Shape/Box.hpp"
#include "Space/Shape/HyperCube.hpp"
#define NO_VERTEX_ID -1
/*! \brief Operator to fill the property 'prp' with the linearization of indexes
*
* \tparam dim Dimension of the space
......@@ -34,7 +36,7 @@ struct fill_id
* \tparam G_v Graph
*/
template<unsigned int dim, typename G_v>
struct fill_id<dim, G_v, -1>
struct fill_id<dim, G_v, NO_VERTEX_ID>
{
static inline void fill(G_v & g_v, const grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs)
{
......@@ -203,7 +205,7 @@ 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];
g_v.template get<t_val::value>()[T::value] = gk.get(T::value) * static_cast<float>(szd[T::value]);
fill_id<dim, G_v, lin_id>::fill(g_v, gk, gs);
}
};
......@@ -522,7 +524,7 @@ public:
* 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 id_prp property 'id' that stores the vertex id
* \tparam id_prp property 'id' that stores the vertex id (with -1 it skip)
* \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
......@@ -531,7 +533,7 @@ public:
template<int se, int id_prp, typename T, unsigned int dim_c, int ... pos>
static Graph construct(const size_t (&sz)[dim], Box<dim, T> dom, const size_t (& bc)[dim])
{
return Graph_constructor_impl<dim, id_prp, Graph, se, T, dim_c, pos...>::construct(sz, dom);
return Graph_constructor_impl<dim, id_prp, Graph, se, T, dim_c, pos...>::construct(sz, dom, bc);
}
};
......
......@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use_np)
// Boundary conditions, non periodic
size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,float,2>(sz,box,bc);
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,NO_VERTEX_ID,float,2>(sz,box,bc);
// check that the number of vertex are equal to GS_SIZE^3
BOOST_REQUIRE_EQUAL(g.getNVertex(),(size_t)GS_SIZE*GS_SIZE*GS_SIZE);
......@@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use_p)
// Boundary conditions, non periodic
size_t bc[] = {PERIODIC,PERIODIC,PERIODIC};
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,float,2>(sz,box,bc);
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,NO_VERTEX_ID,float,2>(sz,box,bc);
// check that the number of vertex are equal to GS_SIZE^3
BOOST_REQUIRE_EQUAL(g.getNVertex(),(size_t)GS_SIZE*GS_SIZE*GS_SIZE);
......
......@@ -209,7 +209,7 @@ 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];
g_v.template get<t_val::value>()[T::value] = gk.get(T::value) * static_cast<float>(szd[T::value]);
dist_fill_id<dim, G_v, loc_id, glob_id>::fill(g_v, gk, gs);
}
};
......@@ -447,7 +447,7 @@ public:
size_t mod_v = g.size() % Np;
size_t div_v = g.size() / Np;
for (int i = 0; i <= Np; i++)
for (size_t i = 0; i <= Np; i++)
{
if (i < mod_v)
vtxdist.get(i) = (div_v + 1) * (i);
......@@ -480,7 +480,7 @@ public:
{
size_t v_id = g.LinId(k_it.get());
if (v_id < vtxdist.get(p_id + 1) && v_id >= vtxdist.get(p_id))
if (v_id < (size_t)vtxdist.get(p_id + 1) && v_id >= (size_t)vtxdist.get(p_id))
{
grid_key_dx<dim> key = k_it.get();
......
......@@ -3,11 +3,11 @@
#include "Graph/DistCartesianGraphFactory.hpp"
#include "Graph/map_graph.hpp"
#include "Packer.hpp"
#include "Unpacker.hpp"
#include "Packer_Unpacker/Packer.hpp"
#include "Packer_Unpacker/Unpacker.hpp"
#include "SubdomainGraphNodes.hpp"
#define GS_SIZE 4
#define DGS_SIZE 4
/*!
*
......@@ -89,6 +89,8 @@ BOOST_AUTO_TEST_SUITE (DistCartesianGraphFactory_test)
BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_3D_use)
{
// Boundary conditions, non periodic
size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
// Vcluster
Vcluster & vcl = *global_v_cluster;
......@@ -97,7 +99,7 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_3D_use)
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
// Cartesian grid
size_t sz[3] = { GS_SIZE, GS_SIZE, GS_SIZE };
size_t sz[3] = { DGS_SIZE, DGS_SIZE, DGS_SIZE };
// Box
Box<3, float> box( { 0.0, 0.0, 0.0 }, { 1.0, 1.0, 1.0 });
......@@ -106,7 +108,7 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_3D_use)
CartesianGraphFactory<3,Graph_CSR<Point_test<float>,Point_test<float>>> g_factory;
// Standard graph
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.template construct<NO_EDGE, node::id, float, 3 - 1, 0, 1, 2>(sz, box);
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.template construct<NO_EDGE, node::id, float, 3 - 1, 0, 1, 2>(sz, box, bc);
// Distribution vector
openfpm::vector<idx_t> vtxdist(vcl.getProcessingUnits() + 1);
......@@ -132,7 +134,7 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_3D_use)
BOOST_REQUIRE_EQUAL(count, gd.getNVertex());
for(size_t i = vtxdist.get(vcl.getProcessUnitID()), local_i = 0; i < vtxdist.get(vcl.getProcessUnitID()+1); i++, local_i++)
for(size_t i = (size_t)vtxdist.get(vcl.getProcessUnitID()), local_i = 0; i < (size_t)vtxdist.get(vcl.getProcessUnitID()+1); i++, local_i++)
{
BOOST_REQUIRE_EQUAL(gd.vertex(local_i).template get<node::id>(), g.vertex(i).template get<node::id>());
BOOST_REQUIRE_EQUAL(gd.getNChilds(local_i), g.getNChilds(i));
......@@ -148,6 +150,8 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_3D_use)
BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
{
// Boundary conditions, non periodic
size_t bc[] = {NON_PERIODIC,NON_PERIODIC};
// Vcluster
Vcluster & vcl = *global_v_cluster;
......@@ -159,7 +163,7 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
// Cartesian grid
size_t sz[2] = { GS_SIZE, GS_SIZE };
size_t sz[2] = { DGS_SIZE, DGS_SIZE };
// Box
Box<2, float> box( { 0.0, 0.0}, { 1.0, 1.0} );
......@@ -168,7 +172,7 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
CartesianGraphFactory<2,Graph_CSR<node, node>> g_factory;
// Standard graph
Graph_CSR<node, node> g = g_factory.template construct<NO_EDGE, node::id, float, 2 - 1, 0, 1, 2>(sz, box);
Graph_CSR<node, node> g = g_factory.template construct<NO_EDGE, node::id, float, 2 - 1, 0, 1, 2>(sz, box, bc);
// Distribution vector
openfpm::vector<idx_t> vtxdist(vcl.getProcessingUnits() + 1);
......@@ -194,7 +198,7 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
BOOST_REQUIRE_EQUAL(count, gd.getNVertex());
for(size_t i = vtxdist.get(vcl.getProcessUnitID()), local_i = 0; i < vtxdist.get(vcl.getProcessUnitID()+1); i++, local_i++)
for(size_t i = (size_t)vtxdist.get(vcl.getProcessUnitID()), local_i = 0; i < (size_t)vtxdist.get(vcl.getProcessUnitID()+1); i++, local_i++)
{
BOOST_REQUIRE_EQUAL(gd.vertex(local_i).template get<node::id>(), g.vertex(i).template get<node::id>());
BOOST_REQUIRE_EQUAL(gd.getNChilds(local_i), g.getNChilds(i));
......@@ -225,7 +229,6 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
// try to pack
Packer<size_t,HeapMemory>::pack(mem, 3, sts);
node n = gd.vertex(0);
Packer<decltype(gd.vertex(0)),HeapMemory>::pack(mem,gd.vertex(0), sts);
Packer<decltype(gd.vertex(0)),HeapMemory>::pack(mem,gd.vertex(1), sts);
Packer<decltype(gd.vertex(0)),HeapMemory>::pack(mem,gd.vertex(2), sts);
......@@ -247,14 +250,14 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
size_t size;
Unpacker<size_t,HeapMemory>::unpack(mem,size,ps);
BOOST_REQUIRE_EQUAL(size, 3);
BOOST_REQUIRE_EQUAL(size, 3ul);
Unpacker<node,HeapMemory>::unpack(mem,v1,ps);
Unpacker<node,HeapMemory>::unpack(mem,v2,ps);
Unpacker<node,HeapMemory>::unpack(mem,v3,ps);
BOOST_REQUIRE_EQUAL(v1.template get<node::id>(), 0);
BOOST_REQUIRE_EQUAL(v2.template get<node::id>(), 1);
BOOST_REQUIRE_EQUAL(v3.template get<node::id>(), 2);
BOOST_REQUIRE_EQUAL(v1.template get<node::id>(), 0ul);
BOOST_REQUIRE_EQUAL(v2.template get<node::id>(), 1ul);
BOOST_REQUIRE_EQUAL(v3.template get<node::id>(), 2ul);
}
//! [Exchange n vertices packed]
......@@ -308,18 +311,18 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
size_t size;
Unpacker<size_t,HeapMemory>::unpack(mem,size,ps);
BOOST_REQUIRE_EQUAL(size, 3);
BOOST_REQUIRE_EQUAL(size, 3ul);
v.resize(size);
for(int i = 0; i < size; i++){
for(size_t i = 0; i < size; i++){
node v_n;
Unpacker<node,HeapMemory>::unpack(mem,v_n,ps);
v.set(i, v_n);
}
BOOST_REQUIRE_EQUAL(v.get(0).template get<node::id>(), 0);
BOOST_REQUIRE_EQUAL(v.get(1).template get<node::id>(), 1);
BOOST_REQUIRE_EQUAL(v.get(2).template get<node::id>(), 2);
BOOST_REQUIRE_EQUAL(v.get(0).template get<node::id>(), 0ul);
BOOST_REQUIRE_EQUAL(v.get(1).template get<node::id>(), 1ul);
BOOST_REQUIRE_EQUAL(v.get(2).template get<node::id>(), 2ul);
}
if(vcl.getProcessUnitID() == 0){
......@@ -332,19 +335,19 @@ BOOST_AUTO_TEST_CASE( DistCartesianGraphFactory_2D_use)
size_t size;
Unpacker<size_t,HeapMemory>::unpack(mem,size,ps);
BOOST_REQUIRE_EQUAL(size, 3);
BOOST_REQUIRE_EQUAL(size, 3ul);
v.resize(size);
for(int i = 0; i < size; i++){
for(size_t i = 0; i < size; i++){
node v_n;
Unpacker<node,HeapMemory>::unpack(mem,v_n,ps);
v.set(i, v_n);
}
BOOST_REQUIRE_EQUAL(v.get(0).template get<node::id>(), 8);
BOOST_REQUIRE_EQUAL(v.get(1).template get<node::id>(), 9);
BOOST_REQUIRE_EQUAL(v.get(2).template get<node::id>(), 10);
BOOST_REQUIRE_EQUAL(v.get(0).template get<node::id>(), 8ul);
BOOST_REQUIRE_EQUAL(v.get(1).template get<node::id>(), 9ul);
BOOST_REQUIRE_EQUAL(v.get(2).template get<node::id>(), 10ul);
}
......
......@@ -62,8 +62,8 @@
#include "Vector/map_vector.hpp"
#include "Graph/map_graph.hpp"
#include <unordered_map>
#include "Packer.hpp"
#include "Unpacker.hpp"
#include "Packer_Unpacker/Packer.hpp"
#include "Packer_Unpacker/Unpacker.hpp"
#include "VCluster.hpp"
#define NO_EDGE -1
......@@ -429,7 +429,7 @@ class DistGraph_CSR
{
if (sgp.size() == vcl.getProcessingUnits())
{
for (int p = 0; p < vcl.getProcessingUnits(); ++p)
for (size_t p = 0; p < vcl.getProcessingUnits(); ++p)
{
sgp.get(p).send_v.clear();
sgp.get(p).send_v_m.clear();
......@@ -444,7 +444,7 @@ class DistGraph_CSR
{
sgp.resize(vcl.getProcessingUnits());
for (int p = 0; p < vcl.getProcessingUnits(); ++p)
for (size_t p = 0; p < vcl.getProcessingUnits(); ++p)
{
openfpm::vector<V> s_v;
openfpm::vector<v_info> s_v_m;
......@@ -882,7 +882,7 @@ class DistGraph_CSR
openfpm::vector<openfpm::vector<size_t>> resp_rmi(vcl.getProcessingUnits());
// Prepare re-mapping info response
for (int i = 0; i < req_rmi.size(); ++i)
for (size_t i = 0; i < req_rmi.size(); ++i)
{
for (size_t j = 0; j < req_rmi.get(i).size(); ++j)
{
......@@ -1169,6 +1169,8 @@ public:
DistGraph_CSR<V, E, VertexList, EdgeList, Memory> & operator=(const DistGraph_CSR<V, E, VertexList, EdgeList, Memory> & g)
{
swap(g.duplicate());
return *this;
}