From 2f7b6f8fa3f4a8031dd4ed4be7d589205271be5f Mon Sep 17 00:00:00 2001 From: Pietro Incardona <incardon@mpi-cbg.de> Date: Wed, 28 Jan 2015 19:37:23 +0100 Subject: [PATCH] Fix dec optimizer --- src/Graph/CartesianGraphFactory.hpp | 3 ++- src/dec_optimizer.hpp | 21 +++++++++++---------- src/dec_optimizer_unit_test.hpp | 6 +++--- src/grid_dist.hpp | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Graph/CartesianGraphFactory.hpp b/src/Graph/CartesianGraphFactory.hpp index 25e099f4..c8c9568c 100644 --- a/src/Graph/CartesianGraphFactory.hpp +++ b/src/Graph/CartesianGraphFactory.hpp @@ -10,8 +10,9 @@ #include "map_vector.hpp" #include "map_graph.hpp" -#include "grid.hpp" +#include "Grid/grid.hpp" #include "Space/Shape/Box.hpp" +#include "Space/Shape/HyperCube.hpp" /*! \brief This class work as a functor * diff --git a/src/dec_optimizer.hpp b/src/dec_optimizer.hpp index 3eeba645..7ae526a5 100644 --- a/src/dec_optimizer.hpp +++ b/src/dec_optimizer.hpp @@ -59,7 +59,7 @@ public: * */ - template<typename encap> static Box<dim,size_t> getBox(encap & enc) + template<typename encap> static Box<dim,size_t> getBox(encap && enc) { Box<dim,size_t> bx; @@ -80,7 +80,7 @@ public: * */ - template<typename encap> static void getBox(encap & enc, Box<dim,size_t> & bx) + template<typename encap> static void getBox(const encap & enc, Box<dim,size_t> & bx) { // Create the object from the encapsulation @@ -145,7 +145,7 @@ private: * */ - template<unsigned int p_sub> void fill_domain(Graph & graph, Box<dim,size_t> & box, size_t ids) + template<unsigned int p_sub> void fill_domain(Graph & graph,const Box<dim,size_t> & box, size_t ids) { // Create a subgrid iterator grid_key_dx_iterator_sub<dim> g_sub(gh,box.getKP1(),box.getKP2()); @@ -283,11 +283,15 @@ private: // get the wavefront sub-domain id size_t sub_w = gh.LinId(it.get()); + // get the sub-domain id of the expanded wavefront + grid_key_dx<dim> k_exp = it.get() + w_comb[d]; + size_t sub_w_e = gh.LinId(k_exp); + // we get the processor id of the neighborhood sub-domain on direction d - size_t exp_p = graph.vertex(graph.getChild(sub_w,d)).template get<p_id>(); + size_t exp_p = graph.vertex(sub_w_e).template get<p_id>(); // we check if it is the same processor id - w_can_expand &= exp_p != domain_id; + w_can_expand &= exp_p == domain_id; // next domain ++it; @@ -310,9 +314,6 @@ private: { v_w.template get<wavefront<dim>::stop>(d)[j] = v_w.template get<wavefront<dim>::stop>(d)[j] + w_comb[d].c[j]; v_w.template get<wavefront<dim>::start>(d)[j] = v_w.template get<wavefront<dim>::start>(d)[j] + w_comb[d].c[j]; - - std::cout << "stop: " << v_w.template get<wavefront<dim>::stop>(d)[j] << "\n"; - std::cout << "start: " << v_w.template get<wavefront<dim>::start>(d)[j] << "\n"; } // expand the intersection of the wavefronts @@ -346,9 +347,9 @@ private: for (int s = 0 ; s < dim ; s++) { if (is_pos == true) - {v_w.template get<wavefront<dim>::stop>(id)[j] = v_w.template get<wavefront<dim>::stop>(d)[j] + w_comb[id].c[j];} + {v_w.template get<wavefront<dim>::stop>(id)[j] = v_w.template get<wavefront<dim>::stop>(id)[j] + w_comb[id].c[j];} else - {v_w.template get<wavefront<dim>::start>(id)[j] = v_w.template get<wavefront<dim>::start>(d)[j] + w_comb[id].c[j];} + {v_w.template get<wavefront<dim>::start>(id)[j] = v_w.template get<wavefront<dim>::start>(id)[j] + w_comb[id].c[j];} } } } diff --git a/src/dec_optimizer_unit_test.hpp b/src/dec_optimizer_unit_test.hpp index 7ab5aa20..31818a60 100644 --- a/src/dec_optimizer_unit_test.hpp +++ b/src/dec_optimizer_unit_test.hpp @@ -26,9 +26,9 @@ BOOST_AUTO_TEST_CASE( dec_optimizer_test_use) // Cartesian grid std::vector<size_t> sz; - sz.push_back(4); - sz.push_back(4); - sz.push_back(1); + sz.push_back(GS_SIZE); + sz.push_back(GS_SIZE); + sz.push_back(GS_SIZE); // Box Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); diff --git a/src/grid_dist.hpp b/src/grid_dist.hpp index 23658bad..728d5f61 100644 --- a/src/grid_dist.hpp +++ b/src/grid_dist.hpp @@ -2,7 +2,7 @@ #define COM_UNIT_HPP #include <vector> -#include "map_grid.hpp" +#include "Grid/map_grid.hpp" #include "VCluster.hpp" #include "Space/SpaceBox.hpp" -- GitLab