From 19afe1932263bbbc2aaf33394b2272dc687f3902 Mon Sep 17 00:00:00 2001 From: Pietro Incardona Date: Tue, 11 Apr 2017 00:32:12 +0200 Subject: [PATCH] enabling metis --- .../Distribution/Distribution_unit_tests.hpp | 19 +- .../Distribution/MetisDistribution.hpp | 306 +++++++++++++----- .../Distribution/ParMetisDistribution.hpp | 49 ++- src/Decomposition/Distribution/metis_util.hpp | 63 +++- src/Vector/vector_dist.hpp | 31 +- src/Vector/vector_dist_cell_list_tests.hpp | 6 +- src/Vector/vector_dist_dlb_test.hpp | 23 +- 7 files changed, 387 insertions(+), 110 deletions(-) diff --git a/src/Decomposition/Distribution/Distribution_unit_tests.hpp b/src/Decomposition/Distribution/Distribution_unit_tests.hpp index 1572013..43cb97a 100644 --- a/src/Decomposition/Distribution/Distribution_unit_tests.hpp +++ b/src/Decomposition/Distribution/Distribution_unit_tests.hpp @@ -64,9 +64,6 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test) if (v_cl.getProcessingUnits() != 3) return; - if (v_cl.getProcessUnitID() != 0) - return; - //! [Initialize a Metis Cartesian graph and decompose] MetisDistribution<3, float> met_dist(v_cl); @@ -100,17 +97,21 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test) // Initialize the weights to 1.0 // not required, if we set ALL Computation,Migration,Communication cost - met_dist.initWeights(); // Change set some weight on the graph and re-decompose - for (size_t i = 0; i < met_dist.getNSubSubDomains(); i++) + for (size_t k = 0; k < met_dist.getNOwnerSubSubDomains(); k++) { + size_t i = met_dist.getOwnerSubSubDomain(k); + if (i == 0 || i == b || i == 2*b || i == 3*b || i == 4*b) - met_dist.setComputationCost(i,10); + met_dist.setComputationCost(i,10); else - met_dist.setComputationCost(i,1); + met_dist.setComputationCost(i,1); + } + for (size_t i = 0 ; i < met_dist.getNSubSubDomains() ; i++) + { // We also show how to set some Communication and Migration cost met_dist.setMigrationCost(i,1); @@ -163,7 +164,7 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test) // operator= functions // operator== functions - BOOST_REQUIRE_EQUAL(sizeof(MetisDistribution<3,float>),472ul); + BOOST_REQUIRE_EQUAL(sizeof(MetisDistribution<3,float>),712ul); } BOOST_AUTO_TEST_CASE( Parmetis_distribution_test) @@ -264,7 +265,7 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test) //! [refine with parmetis the decomposition] - BOOST_REQUIRE_EQUAL(sizeof(MetisDistribution<3,float>),472ul); + BOOST_REQUIRE_EQUAL(sizeof(ParMetisDistribution<3,float>),872ul); } BOOST_AUTO_TEST_CASE( DistParmetis_distribution_test) diff --git a/src/Decomposition/Distribution/MetisDistribution.hpp b/src/Decomposition/Distribution/MetisDistribution.hpp index 86e035e..f7598ca 100644 --- a/src/Decomposition/Distribution/MetisDistribution.hpp +++ b/src/Decomposition/Distribution/MetisDistribution.hpp @@ -41,12 +41,35 @@ class MetisDistribution //! Global sub-sub-domain graph Graph_CSR gp; - //! Flag to check if weights are used on vertices - bool useWeights = false; - //! Flag that indicate if we are doing a test (In general it fix the seed) bool testing = false; + //! Metis decomposer utility + Metis> metis_graph; + + /*! \brief sub-domain list and weight + * + */ + struct met_sub_w + { + //! sub-domain id + size_t id; + + //! sub-domain weight / assignment (it depend in which context is used) + size_t w; + + static bool noPointers() {return true;} + }; + + //! unordered map that map global sub-sub-domain to owned_cost_sub id + std::unordered_map owner_scs; + + //! list owned sub-sub-domains set for computation cost + openfpm::vector owner_cost_sub; + + //! received assignment + openfpm::vector recv_ass; + /*! \brief Check that the sub-sub-domain id exist * * \param id sub-sub-domain id @@ -83,9 +106,13 @@ public: static constexpr unsigned int computation = nm_v::computation; - //! constructor - MetisDistribution(Vcluster & v_cl) : - v_cl(v_cl) + /*! \brief constructor + * + * \param v_cl vcluster + * + */ + MetisDistribution(Vcluster & v_cl) + :v_cl(v_cl),metis_graph(gp) { #ifdef SE_CLASS2 check_new(this,8,VECTOR_EVENT,1); @@ -94,6 +121,7 @@ public: /*! \brief Copy constructor * + * \param mt distribution to copy * */ MetisDistribution(const MetisDistribution & mt) @@ -108,6 +136,7 @@ public: /*! \brief Copy constructor * + * \param mt distribution to copy * */ MetisDistribution(MetisDistribution && mt) @@ -190,16 +219,76 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif - Metis> met(gp, v_cl.getProcessingUnits(), useWeights); - met.onTest(testing); - // decompose - met.decompose(); + // Gather the sub-domain weight in one processor + recv_ass.clear(); + v_cl.SGather(owner_cost_sub,recv_ass,0); + + if (v_cl.getProcessUnitID() == 0) + { + if (recv_ass.size() != 0) + { + // we fill the assignment + for (size_t i = 0 ; i < recv_ass.size() ; i++) + gp.template vertex_p(recv_ass.get(i).id) = recv_ass.get(i).w; + + metis_graph.initMetisGraph(v_cl.getProcessingUnits(),true); + } + else + metis_graph.initMetisGraph(v_cl.getProcessingUnits(),false); + metis_graph.onTest(testing); + + // decompose + metis_graph.decompose(); + + if (recv_ass.size() != 0) + { + // we fill the assignment + for (size_t i = 0 ; i < recv_ass.size() ; i++) + recv_ass.get(i).w = gp.template vertex_p(recv_ass.get(i).id); + } + else + { + recv_ass.resize(gp.getNVertex()); + + // we fill the assignment + for (size_t i = 0 ; i < gp.getNVertex() ; i++) + { + recv_ass.get(i).id = i; + recv_ass.get(i).w = gp.template vertex_p(i); + } + } + } + + recv_ass.resize(gp.getNVertex()); + + // broad cast the result + v_cl.Bcast(recv_ass,0); + v_cl.execute(); + owner_scs.clear(); + owner_cost_sub.clear(); + + size_t j = 0; + + // Fill the metis graph + for (size_t i = 0 ; i < recv_ass.size() ; i++) + { + gp.template vertex_p(recv_ass.get(i).id) = recv_ass.get(i).w; + + if (recv_ass.get(i).w == v_cl.getProcessUnitID()) + { + owner_scs[recv_ass.get(i).id] = j; + j++; + owner_cost_sub.add(); + owner_cost_sub.last().id = recv_ass.get(i).id; + owner_cost_sub.last().w = 1; + } + } } - /*! \brief Refine current decomposition (NOT AVAILABLE on Metis) + /*! \brief Refine current decomposition * - * Disabled for MetisDistribution + * In metis case it just re-decompose * */ void refine() @@ -207,10 +296,22 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif - std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " MetisDistribution does not have refine functionality"; - ACTION_ON_ERROR(METIS_DISTRIBUTION_ERROR_OBJECT); + + decompose(); } + /*! \brief Redecompose current decomposition + * + */ + void redecompose() + { +#ifdef SE_CLASS2 + check_valid(this,8); +#endif + decompose(); + } + + /*! \brief Function that return the position (point P1) of the sub-sub domain box in the space * * \param id vertex id @@ -231,19 +332,6 @@ public: pos[2] = gp.vertex(id).template get()[2]; } - /*! \brief Checks if Computational/Migration/Communication Cost are used - * - * \return true if such weights are used - * - */ - bool weightsAreUsed() - { -#ifdef SE_CLASS2 - check_valid(this,8); -#endif - return useWeights; - } - /*! \brief function that get the computational cost of the sub-sub-domain * * \param id sub-sub-domain @@ -260,24 +348,6 @@ public: return gp.vertex(id).template get(); } - /*! \brief Initialize all the weight - * - * Initialize Computation/Communication/Migration costs to 1 - * - */ - void initWeights() - { -#ifdef SE_CLASS2 - check_valid(this,8); -#endif - for (size_t i = 0 ; i < getNSubSubDomains() ; i++) - { - setComputationCost(i,1); - setMigrationCost(i,1); - for (size_t j = 0 ; j < getNSubSubDomainNeighbors(i) ; j++) - setCommunicationCost(i,j,1); - } - } /*! \brief Set computation cost on a sub-sub domain * @@ -290,11 +360,20 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif +#ifdef SE_CLASS1 check_overflow(id); +#endif - useWeights = true; - - gp.vertex(id).template get() = cost; + auto fnd = owner_scs.find(id); + if (fnd == owner_scs.end()) + { + std::cerr << __FILE__ << ":" << __LINE__ << " Error you are setting a sub-sub-domain the processor does not own" << std::endl; + } + else + { + size_t id = fnd->second; + owner_cost_sub.get(id).w = cost; + } } /*! \brief Set migration cost on a sub-sub domain @@ -307,7 +386,9 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif +#ifdef SE_CLASS1 check_overflow(id); +#endif gp.vertex(id).template get() = cost; } @@ -323,8 +404,10 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif +#ifdef SE_CLASS1 check_overflow(id); check_overflowe(id,e); +#endif gp.getChildEdge(id, e).template get() = cost; } @@ -351,12 +434,16 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif +#ifdef SE_CLASS1 check_overflow(id); +#endif return gp.getNChilds(id); } /*! \brief Compute the unbalance of the processor compared to the optimal balance + * + * \warning all processor must call this function * * \return the unbalance from the optimal one 0.01 mean 1% */ @@ -365,30 +452,46 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif - long int min, max, sum; - openfpm::vector loads(v_cl.getProcessingUnits()); + size_t load_p = getProcessorLoad(); - for (size_t i = 0; i < loads.size(); i++) - loads.get(i) = 0; + float load_avg = load_p; + v_cl.sum(load_avg); + v_cl.execute(); - if (useWeights == false) - { - for (size_t i = 0; i < gp.getNVertex(); i++) - loads.get(gp.vertex(i).template get())++; - } - else + if (load_avg == 0) { - for (size_t i = 0; i < gp.getNVertex(); i++) - loads.get(gp.vertex(i).template get()) += (gp.vertex(i).template get() == 0)?1:gp.vertex(i).template get(); + // count the number if sub-sub-domain assigned + load_avg = owner_cost_sub.size(); + + v_cl.sum(load_avg); + v_cl.execute(); } - max = *std::max_element(loads.begin(), loads.end()); - min = *std::min_element(loads.begin(), loads.end()); - sum = std::accumulate(loads.begin(),loads.end(),0); + load_avg /= v_cl.getProcessingUnits(); + + return ((float)load_p - load_avg) / load_avg; + } - float unbalance = ((float) (max - min)) / ((float) sum / v_cl.getProcessingUnits()); + /*! \brief Return the total number of sub-sub-domains in the distribution graph + * + * \return the total number of sub-sub-domains set + * + */ + size_t getNOwnerSubSubDomains() const + { + return owner_cost_sub.size(); + } - return unbalance; + /*! \brief Return the id of the set sub-sub-domain + * + * \param id id in the list of the set sub-sub-domains + * + * \return the id + * + */ + size_t getOwnerSubSubDomain(size_t id) const + { + return owner_cost_sub.get(id).id; } /*! \brief It set the Classs on test mode @@ -414,12 +517,15 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif + VTKWriter, VTK_GRAPH> gv2(gp); - gv2.write(out); + gv2.write(std::to_string(v_cl.getProcessUnitID()) + "_" + out + ".vtk"); } - /*! \brief Compute the total computational cost of the processor + /*! \brief Compute the processor load + * + * \warning all processors must call this function * * \return the total computation cost */ @@ -428,19 +534,31 @@ public: #ifdef SE_CLASS2 check_valid(this,8); #endif + openfpm::vector loads(v_cl.getProcessingUnits()); + size_t load = 0; - for (size_t i = 0; i < gp.getNVertex(); i++) + if (v_cl.getProcessUnitID() == 0) { - if (gp.vertex(i).template get() == v_cl.getProcessUnitID()) - load += gp.vertex(i).template get(); + for (size_t i = 0; i < gp.getNVertex(); i++) + loads.get(gp.template vertex_p(i)) += gp.template vertex_p(i); + + for (size_t i = 0 ; i < v_cl.getProcessingUnits() ; i++) + { + v_cl.send(i,1234,&loads.get(i),sizeof(size_t)); + } } + v_cl.recv(0,1234,&load,sizeof(size_t)); + v_cl.execute(); return load; } /*! \brief operator= * + * \param mt object to copy + * + * \return itself * */ MetisDistribution & operator=(const MetisDistribution & mt) @@ -452,12 +570,16 @@ public: this->gr = mt.gr; this->domain = mt.domain; this->gp = mt.gp; - this->useWeights = mt.useWeights; + this->owner_cost_sub = mt.owner_cost_sub; + this->owner_scs = mt.owner_scs; return *this; } /*! \brief operator= * + * \param mt object to copy + * + * \return itself * */ MetisDistribution & operator=(MetisDistribution && mt) @@ -469,11 +591,14 @@ public: this->gr = mt.gr; this->domain = mt.domain; this->gp.swap(mt.gp); - this->useWeights = mt.useWeights; + this->owner_cost_sub.swap(mt.owner_cost_sub); + this->owner_scs.swap(mt.owner_scs); return *this; } /*! \brief operator== + * + * \param mt Metis distribution to compare with * * \return true if the distribution match * @@ -489,9 +614,44 @@ public: ret &= (this->gr == mt.gr); ret &= (this->domain == mt.domain); ret &= (this->gp == mt.gp); - ret &= (this->useWeights == mt.useWeights); + return ret; } + + /*! \brief Set the tolerance for each partition + * + * \param tol tolerance + * + */ + void setDistTol(double tol) + { + metis_graph.setDistTol(tol); + } + + + + /*! \brief function that get the weight of the vertex + * + * \param id vertex id + * + */ + size_t getSubSubDomainComputationCost(size_t id) + { +#ifdef SE_CLASS1 + if (id >= gp.getNVertex()) + std::cerr << __FILE__ << ":" << __LINE__ << "Such vertex doesn't exist (id = " << id << ", " << "total size = " << gp.getNVertex() << ")\n"; +#endif + + auto fnd = owner_scs.find(id); + if (fnd == owner_scs.end()) + { + std::cerr << __FILE__ << ":" << __LINE__ << " Error you are setting a sub-sub-domain that the processor does not own" << std::endl; + return 0; + } + + size_t ids = fnd->second; + return owner_cost_sub.get(ids).w; + } }; #endif /* SRC_DECOMPOSITION_METISDISTRIBUTION_HPP_ */ diff --git a/src/Decomposition/Distribution/ParMetisDistribution.hpp b/src/Decomposition/Distribution/ParMetisDistribution.hpp index 231cc39..9ee2435 100644 --- a/src/Decomposition/Distribution/ParMetisDistribution.hpp +++ b/src/Decomposition/Distribution/ParMetisDistribution.hpp @@ -52,6 +52,9 @@ class ParMetisDistribution //! Convert the graph to parmetis format Parmetis> parmetis_graph; + //! Id of the sub-sub-domain where we set the costs + openfpm::vector sub_sub_owner; + //! Init vtxdist needed for Parmetis // // vtxdist is a common array across processor, it indicate how @@ -86,6 +89,8 @@ class ParMetisDistribution */ void updateGraphs() { + sub_sub_owner.clear(); + size_t Np = v_cl.getProcessingUnits(); // Init n_vtxdist to gather informations about the new decomposition @@ -105,8 +110,14 @@ class ParMetisDistribution // Create new n_vtxdist (just count processors vertices) ++n_vtxdist.get(partitions.get(i).get(k) + 1); + // vertex id from vtx to grobal id + auto v_id = m2g.find(l)->second.id; + // Update proc id in the vertex (using the old map) - vertexByMapId(l).template get() = partitions.get(i).get(k); + gp.template vertex_p(v_id) = partitions.get(i).get(k); + + if (partitions.get(i).get(k) == (long int)v_cl.getProcessUnitID()) + sub_sub_owner.add(v_id); // Add vertex to temporary structure of distribution (needed to update main graph) v_per_proc.get(partitions.get(i).get(k)).add(getVertexGlobalId(l)); @@ -515,9 +526,8 @@ public: for (rid i = vtxdist.get(p_id); i < vtxdist.get(p_id+1) ; ++i) - { load += gp.vertex(m2g.find(i)->second.id).template get(); - } + //std::cout << v_cl.getProcessUnitID() << " weight " << load << " size " << sub_g.getNVertex() << "\n"; return load; } @@ -557,16 +567,43 @@ public: } /*! \brief Returns total number of sub-sub-domains in the distribution graph + * + * \return the total number of sub-sub-domains * */ - size_t getNSubSubDomains() + size_t getNSubSubDomains() const { return gp.getNVertex(); } + /*! \brief Return the total number of sub-sub-domains this processor own + * + * \return the total number of sub-sub-domains owned by this processor + * + */ + size_t getNOwnerSubSubDomains() const + { + return sub_sub_owner.size(); + } + + /*! \brief Return the global id of the owned sub-sub-domain + * + * \param id in the list of owned sub-sub-domains + * + * \return the global id + * + */ + size_t getOwnerSubSubDomain(size_t id) const + { + return sub_sub_owner.get(id); + } + /*! \brief Returns total number of neighbors of the sub-sub-domain id * * \param id id of the sub-sub-domain + * + * \return the number of neighborhood sub-sub-domains for each sub-domain + * */ size_t getNSubSubDomainNeighbors(size_t id) { @@ -599,6 +636,8 @@ public: partitions = dist.partitions; v_per_proc = dist.v_per_proc; verticesGotWeights = dist.verticesGotWeights; + sub_sub_owner = dist.sub_sub_owner; + m2g = dist.m2g; return *this; } @@ -614,6 +653,8 @@ public: partitions.swap(dist.partitions); v_per_proc.swap(dist.v_per_proc); verticesGotWeights = dist.verticesGotWeights; + sub_sub_owner.swap(dist.sub_sub_owner); + m2g.swap(dist.m2g); return *this; } diff --git a/src/Decomposition/Distribution/metis_util.hpp b/src/Decomposition/Distribution/metis_util.hpp index 50a47e1..15c998e 100644 --- a/src/Decomposition/Distribution/metis_util.hpp +++ b/src/Decomposition/Distribution/metis_util.hpp @@ -72,14 +72,17 @@ struct Metis_graph template class Metis { - // Graph in metis reppresentation + //! Graph in metis reppresentation Metis_graph Mg; - // Original graph + //! Original graph Graph & g; //Check if weights are available - bool useWeights = false; +// bool useWeights = false; + + //! Distribution tolerance + real_t dist_tol = 1.05; /*! \brief Construct Adjacency list * @@ -147,7 +150,7 @@ class Metis { // Add weight to vertex and migration cost Mg.vwgt[i] = g.vertex(i).template get(); - Mg.vwgt[i] = (Mg.adjwgt[i] == 0)?1:Mg.vwgt[i]; + Mg.vwgt[i] = (Mg.vwgt[i] == 0)?1:Mg.vwgt[i]; Mg.vsize[i] = g.vertex(i).template get(); Mg.vsize[i] = (Mg.vsize[i] == 0)?1:Mg.vsize[i]; @@ -185,10 +188,10 @@ public: * \param useWeights tells if weights are used or not * */ - Metis(Graph & g, size_t nc, bool useWeights) : - g(g), useWeights(useWeights) + Metis(Graph & g, size_t nc, bool useWeights) + :g(g) { - initMetisGraph(nc); + initMetisGraph(nc,useWeights); } /*! \brief Constructor @@ -202,10 +205,42 @@ public: Metis(Graph & g, size_t nc) : g(g) { - initMetisGraph(nc); + initMetisGraph(nc,false); + } + + /*! \brief Constructor + * + * This constructor does not initialize the internal metis graph + * you have to use initMetisGraph to initialize + * + * \param g Graph we want to convert to decompose + * + */ + Metis(Graph & g) + :g(g) + { + Mg.nvtxs = NULL; + Mg.ncon = NULL; + Mg.xadj = NULL; + Mg.adjncy = NULL; + Mg.vwgt = NULL; + Mg.adjwgt = NULL; + Mg.nparts = NULL; + Mg.tpwgts = NULL; + Mg.ubvec = NULL; + Mg.options = NULL; + Mg.objval = NULL; + Mg.part = NULL; } - void initMetisGraph(int nc) + + /*! \brief Initialize the METIS graph + * + * \param nc number of partitions + * \param useWeights use the weights on the graph + * + */ + void initMetisGraph(int nc, bool useWeights) { // Get the number of vertex @@ -422,6 +457,16 @@ public: Mg.options[METIS_OPTION_SEED] = 0; } + + /*! \brief Distribution tolerance + * + * \param tol tolerance + * + */ + const void setDistTol(real_t tol) + { + dist_tol = tol; + } }; #endif diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp index a0c8368..09ad10b 100644 --- a/src/Vector/vector_dist.hpp +++ b/src/Vector/vector_dist.hpp @@ -1571,11 +1571,12 @@ public: CellDecomposer_sm> cdsm; Decomposition & dec = getDecomposition(); + auto & dist = getDecomposition().getDistribution(); cdsm.setDimensions(dec.getDomain(), dec.getDistGrid().getSize(), 0); - for (size_t i = 0; i < getDecomposition().getNSubSubDomains(); i++) - dec.setSubSubDomainComputationCost(i, 1); + for (size_t i = 0; i < dist.getNOwnerSubSubDomains() ; i++) + dec.setSubSubDomainComputationCost(dist.getOwnerSubSubDomain(i) , 1); auto it = getDomainIterator(); @@ -1592,10 +1593,10 @@ public: // Go throught all the sub-sub-domains and apply the model - for (size_t i = 0 ; i < dec.getDistribution().getNSubSubDomains(); i++) - md.applyModel(dec,i); + for (size_t i = 0 ; i < dist.getNOwnerSubSubDomains(); i++) + md.applyModel(dec,dist.getOwnerSubSubDomain(i)); - dec.getDistribution().setDistTol(md.distributionTol()); + dist.setDistTol(md.distributionTol()); } /*! \brief Output particle position and properties @@ -1779,6 +1780,26 @@ public: return v_pos; } + /*! \brief return the property vector of all the particles + * + * \return the particle property vector + * + */ + const openfpm::vector & getPropVector() const + { + return v_prp; + } + + /*! \brief return the property vector of all the particles + * + * \return the particle property vector + * + */ + openfpm::vector & getPropVector() + { + return v_prp; + } + /*! \brief It return the sum of the particles in the previous processors * * \return the particles number diff --git a/src/Vector/vector_dist_cell_list_tests.hpp b/src/Vector/vector_dist_cell_list_tests.hpp index ef17290..71afdf2 100644 --- a/src/Vector/vector_dist_cell_list_tests.hpp +++ b/src/Vector/vector_dist_cell_list_tests.hpp @@ -1611,8 +1611,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_checking_unloaded_processors ) float L = 200.0; - bool ret = true; - // set the seed // create the random generator engine std::srand(0); @@ -1674,7 +1672,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_checking_unloaded_processors ) v_cl.min(min); v_cl.execute(); - BOOST_REQUIRE_EQUAL(min,0); + BOOST_REQUIRE_EQUAL(min,0ul); } @@ -1689,7 +1687,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_checking_unloaded_processors ) v_cl.min(min); v_cl.execute(); - BOOST_REQUIRE_EQUAL(min,0); + BOOST_REQUIRE_EQUAL(min,0ul); } } diff --git a/src/Vector/vector_dist_dlb_test.hpp b/src/Vector/vector_dist_dlb_test.hpp index 8abed0d..6d21034 100644 --- a/src/Vector/vector_dist_dlb_test.hpp +++ b/src/Vector/vector_dist_dlb_test.hpp @@ -10,7 +10,7 @@ BOOST_AUTO_TEST_SUITE( vector_dist_dlb_test ) -BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) +template void test_dlb_vector() { Vcluster & v_cl = create_vcluster(); @@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) Ghost<3,float> g(0.1); size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC}; - vector_dist<3,float,aggregate> vd(0,domain,bc,g,DEC_GRAN(2048)); + vector_type vd(0,domain,bc,g,DEC_GRAN(2048)); // Only processor 0 initialy add particles on a corner of a domain @@ -37,10 +37,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) } } - - vd.map(); - vd.ghost_get<>(); + vd.template ghost_get<>(); ModelSquare md; md.factor = 10; @@ -48,6 +46,9 @@ BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) vd.getDecomposition().decompose(); vd.map(); + vd.getDecomposition().getDistribution().write("dist_out_"); + vd.getDecomposition().write("dec_out_"); + vd.addComputationCosts(md); openfpm::vector loads; @@ -92,7 +93,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) BOOST_REQUIRE(vd.size_local() != 0); - vd.ghost_get<>(); + vd.template ghost_get<>(); vd.addComputationCosts(md); @@ -111,6 +112,16 @@ BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) } } +BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part ) +{ + test_dlb_vector>>(); +} + +BOOST_AUTO_TEST_CASE( vector_dist_dlb_metis_test_part ) +{ + test_dlb_vector,CartDecomposition<3,float,HeapMemory,MetisDistribution<3,float>>>>(); +} + BOOST_AUTO_TEST_SUITE_END() #endif /* SRC_VECTOR_VECTOR_DIST_DLB_TEST_HPP_ */ -- GitLab