1 #ifndef DIST_MAP_GRAPH_UNIT_TEST_HPP 2 #define DIST_MAP_GRAPH_UNIT_TEST_HPP 4 #include "Graph/DistGraphFactory.hpp" 5 #include "Graph/dist_map_graph.hpp" 6 #include "Packer_Unpacker/Packer.hpp" 7 #include "Packer_Unpacker/Unpacker.hpp" 9 #define DGRAPH_GS_SIZE 4 13 typedef boost::fusion::vector<float[3]> type;
18 static const std::string name[];
28 static const unsigned int x = 0;
37 inline vx(
const vx & p)
39 boost::fusion::at_c<0>(
data)[0] = boost::fusion::at_c<0>(p.
data)[0];
40 boost::fusion::at_c<0>(
data)[1] = boost::fusion::at_c<0>(p.
data)[1];
41 boost::fusion::at_c<0>(
data)[2] = boost::fusion::at_c<0>(p.
data)[2];
44 template<
unsigned int id>
inline auto get() -> decltype(boost::fusion::at_c < id > (
data))
46 return boost::fusion::at_c<id>(
data);
49 template<
unsigned int id>
inline auto get() const -> const decltype(boost::fusion::at_c <
id > (
data))
51 return boost::fusion::at_c<id>(
data);
61 boost::fusion::at_c<0>(
data)[0] = p.template get<0>()[0];
62 boost::fusion::at_c<0>(
data)[1] = p.template get<0>()[1];
63 boost::fusion::at_c<0>(
data)[2] = p.template get<0>()[2];
68 static bool noPointers()
74 const std::string vx::attributes::name[] = {
"x" };
78 typedef boost::fusion::vector<size_t> type;
83 static const std::string name[];
90 static const unsigned int prop = 0;
99 template<
unsigned int id>
inline auto get() -> decltype(boost::fusion::at_c < id > (
data))
101 return boost::fusion::at_c<id>(
data);
111 boost::fusion::at_c<0>(
data) = p.template get<0>();
116 static bool noPointers()
122 const std::string ed::attributes::name[] = {
"prop" };
124 BOOST_AUTO_TEST_SUITE (dist_map_graph_test)
126 BOOST_AUTO_TEST_CASE( dist_map_graph_use)
136 size_t sz[2] = { DGRAPH_GS_SIZE, DGRAPH_GS_SIZE };
165 for(
size_t i = 0; i < 4; i++)
171 for(
size_t i = 0; i < 4; i++)
177 for(
size_t i = 0; i < 2; i++)
183 for(
size_t i = 0; i < 4; i++)
197 BOOST_REQUIRE_EQUAL(gd.
getChild(0,0), 1ul);
198 BOOST_REQUIRE_EQUAL(gd.
getChild(0,1), 14ul);
199 BOOST_REQUIRE_EQUAL(gd.
getChild(0,2), 4ul);
201 BOOST_REQUIRE_EQUAL(gd.
getChild(1,0), 2ul);
202 BOOST_REQUIRE_EQUAL(gd.
getChild(1,1), 0ul);
203 BOOST_REQUIRE_EQUAL(gd.
getChild(1,2), 15ul);
204 BOOST_REQUIRE_EQUAL(gd.
getChild(1,3), 5ul);
206 BOOST_REQUIRE_EQUAL(gd.
getChild(2,0), 3ul);
207 BOOST_REQUIRE_EQUAL(gd.
getChild(2,1), 1ul);
208 BOOST_REQUIRE_EQUAL(gd.
getChild(2,2), 8ul);
209 BOOST_REQUIRE_EQUAL(gd.
getChild(2,3), 6ul);
211 BOOST_REQUIRE_EQUAL(gd.
getChild(3,0), 2ul);
212 BOOST_REQUIRE_EQUAL(gd.
getChild(3,1), 9ul);
213 BOOST_REQUIRE_EQUAL(gd.
getChild(3,2), 7ul);
241 BOOST_AUTO_TEST_CASE( dist_map_graph_use_redistribution)
250 size_t sz[2] = { 4, 4 };
291 gv2.write(
"dist_graph_redistribution_0.vtk");
295 bool test = compare(
"dist_graph_redistribution_0.vtk",
"src/Graph/test_data/dist_graph_redistribution_0_test.vtk");
296 BOOST_REQUIRE_EQUAL(
true,test);
313 gv2.write(
"dist_graph_redistribution_1.vtk");
317 bool test = compare(
"dist_graph_redistribution_1.vtk",
"src/Graph/test_data/dist_graph_redistribution_1_test.vtk");
318 BOOST_REQUIRE_EQUAL(
true,test);
324 BOOST_AUTO_TEST_CASE( dist_map_graph_use_free_add)
338 for (
size_t i = 0; i < 4; ++i)
342 v.get<
vx::x>()[1] = i;
343 v.get<
vx::x>()[2] = 0;
398 for (
size_t i = 0; i < 4; ++i)
406 for (
size_t i = 8, j = 0; i < 12 && j < gd.
getNVertex(); ++i, ++j)
449 gv2.write(
"dist_graph_free_0.vtk");
453 bool test = compare(
"dist_graph_free_0.vtk",
"src/Graph/test_data/dist_graph_free_0_test.vtk");
454 BOOST_REQUIRE_EQUAL(
true,test);
471 gv2.write(
"dist_graph_free_1.vtk");
475 bool test = compare(
"dist_graph_free_1.vtk",
"src/Graph/test_data/dist_graph_free_1_test.vtk");
476 BOOST_REQUIRE_EQUAL(
true,test);
480 BOOST_AUTO_TEST_CASE( dist_map_graph_use_multi_free_add)
541 BOOST_AUTO_TEST_SUITE_END()
void syncEdge()
Execute a synchronization through processor to finalize the add of the edges requested in the e_queue...
static const unsigned int max_prop
total number of properties boost::fusion::vector
void add_vertex(const V &vrt, size_t id, size_t gid)
Add vertex vrt with global id and id properties.
size_t getNChilds(size_t c) const
Return the number of children of a vertex.
void q_move(size_t i, size_t t)
Prepare to send vertex i from the local processor to the target processor.
size_t getProcessUnitID()
Get the process unit id.
size_t getNVertex() const
Return the number of the vertices in this subgraph.
static const unsigned int x
x property id in boost::fusion::vector
void reqVertex(size_t gid)
Put a vertex request in queue.
size_t getChild(size_t v, size_t i) const
Get the child edge.
void deleteGhosts()
Remove all the ghosts from this graph.
static const unsigned int prop
srcgid property id in boost::fusion::vector
size_t getVertexId(size_t i) const
Get the id of a vertex given its index position.
void sync()
Execute all vertex requests and add them as ghosts inside this graph, they will be available until a ...
Implementation of VCluster class.
static const unsigned int max_prop
total number of properties boost::fusion::vector
size_t getProcessingUnits()
Get the total number of processors.
Structure that store a graph in CSR format or basically in compressed adjacency matrix format.
void redistribute()
Redistribute function that wraps different stages of the redistribution.
This class represent an N-dimensional box.
This class construct a cartesian graph.
void add_edge(size_t v1, size_t v2)
Add an edge between vertices v1 end v2, needs syncEdge() to complete the action.
auto vertex(size_t id) -> decltype(v.get(id))
Function to access the vertexes.
void init()
Once added all the vertices this function must be called to initialize all the properties,...
float s_type
type of the positional field