8#ifndef DEC_OPTIMIZE_HPP_
9#define DEC_OPTIMIZE_HPP_
12#include "Graph/CartesianGraphFactory.hpp"
13#include "Graph/map_graph.hpp"
14#include "Decomposition/Distribution/metis_util.hpp"
15#include "dec_optimizer.hpp"
16#include "util/SimpleRNG.hpp"
21BOOST_AUTO_TEST_SUITE( dec_optimizer_test )
23BOOST_AUTO_TEST_CASE( dec_optimizer_test_use_np)
29 size_t sz[3] = {GS_SIZE,GS_SIZE,GS_SIZE};
35 size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
48 met.decompose<nm_v_id>();
56 d_o.optimize<nm_v_sub_id,nm_v_id>(keyZero,g,ghe,bc);
59BOOST_AUTO_TEST_CASE( dec_optimizer_test_use_p)
65 size_t sz[3] = {GS_SIZE,GS_SIZE,GS_SIZE};
74 size_t bc[] = {PERIODIC,PERIODIC,PERIODIC};
87 for (
size_t i = 0 ; i < GS_SIZE ; i++)
89 p[0] = (i < GS_SIZE/2)?
false:true;
90 for (
size_t j = 0 ; j < GS_SIZE ; j++)
92 p[1] = (j < GS_SIZE/2)?
false:true;
93 for (
size_t k = 0 ; k < GS_SIZE ; k++)
95 p[2] = (k < GS_SIZE/2)?
false:true;
96 size_t id = 4*p[2] + 2*p[1] + p[0];
100 g.
vertex(gs.LinId(key)).get<nm_v_id>() = id;
119 d_o.optimize<nm_v_sub_id,nm_v_id>(g,-1,dec_o,box_nn_processor,ghe,bc);
121 BOOST_REQUIRE_EQUAL(box_nn_processor.
size(),8ul);
123 for(
size_t i = 0 ; i < box_nn_processor.
size() ; i++)
125 BOOST_REQUIRE_EQUAL(box_nn_processor.get(i).
size(),8ul);
126 for (
size_t j = 0 ; j < box_nn_processor.get(i).size(); j++)
128 BOOST_REQUIRE(box_nn_processor.get(i).get(j) < 8);
135BOOST_AUTO_TEST_CASE( dec_optimizer_disconnected_subdomains_np)
147 size_t sz[2] = {GS_SIZE,GS_SIZE};
153 size_t bc[] = {NON_PERIODIC,NON_PERIODIC};
166 g.
vertex_p<nm_v_proc_id>(vk) = rng.GetUniform() * 2.9999;
182 d_o.optimize<nm_v_sub_id, nm_v_proc_id>(g, vcl.
getProcessUnitID(), loc_box, box_nn_processor,ghe,bc);
184 std::stringstream str_g;
186 std::stringstream str_gt;
187 str_gt <<
"src/Decomposition/Distribution/test_data/dec_optimizer_disc_graph" << vcl.
getProcessUnitID() <<
"_test.vtk";
189 std::stringstream str_s;
191 std::stringstream str_st;
192 str_st <<
"src/Decomposition/Distribution/test_data/dec_optimizer_disc_sub" << vcl.
getProcessUnitID() <<
"_test.vtk";
195 wrt.write(
"dec_optimizer_disc_graph" + std::to_string(vcl.
getProcessUnitID()) +
".vtk");
198 vtk_box1.add(loc_box);
199 vtk_box1.write(
"dec_optimizer_disc_sub" + std::to_string(vcl.
getProcessUnitID()) + std::string(
".vtk"));
201 bool test = compare(str_g.str(), str_gt.str());
202 BOOST_REQUIRE_EQUAL(
true,test);
204 test = compare(str_s.str(),str_st.str());
205 BOOST_REQUIRE_EQUAL(
true,test);
208BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
This class construct a cartesian graph.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > &dom, const size_t(&bc)[dim])
Construct a cartesian graph, with V and E edge properties.
Structure that store a graph in CSR format or basically in compressed adjacency matrix format.
auto vertex(size_t id) -> decltype(v.get(id))
Function to access the vertex.
auto getVertexIterator() const -> decltype(v.getIterator())
Get the vertex iterator.
auto vertex_p(size_t id) -> decltype(v.template get< i >(id))
operator to access the vertex
Helper class to define Metis graph.
SimpleRNG is a simple random number generator based on George Marsaglia's MWC (multiply with carry) g...
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
This class take a graph representing the space decomposition and produce a simplified version.
grid_key_dx is the key to access any element in the grid
Implementation of 1-D std::vector like structure.
sub-domain edge graph node
static const unsigned int communication
computation property id in boost::fusion::vector
static const unsigned int id
partition id in the boost::fusion::vector