ソースを参照

Fix bug on devs graph building

Eric Ramat 10 年 前
コミット
8237640faa

+ 1 - 0
src/tests/CMakeLists.txt

@@ -10,6 +10,7 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIR})
 
 ADD_SUBDIRECTORY(boost_graph)
+ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(corsen)
 ADD_SUBDIRECTORY(dtss)
 ADD_SUBDIRECTORY(mixed)

+ 66 - 30
src/tests/boost_graph/graph_manager.hpp

@@ -223,6 +223,9 @@ public:
         BuiltFlatGraphManager < SchedulerHandle >::build_flat_graph(
             parameters._graph, parameters._input_edges);
         // input
+
+        // std::cout << "Input edges:" << std::endl;
+
         for (Edges::const_iterator it = parameters._input_edges.begin();
              it != parameters._input_edges.end(); ++it) {
             std::ostringstream ss_in;
@@ -235,8 +238,18 @@ public:
                 coordinator, ss_in.str(),
                 BuiltFlatGraphManager <
                     SchedulerHandle >::_normal_simulators[it->second], "in");
+
+            // std::cout << "link = " << coordinator->get_name()
+            //           << "::" << ss_in.str() << " -> "
+            //           << BuiltFlatGraphManager <
+            //               SchedulerHandle >::_normal_simulators[it->second]
+            //     ->get_name() << "::" << "in" << std::endl;
+
         }
         // output
+
+        // std::cout << "Output edges:" << std::endl;
+
         for (Edges::const_iterator it = parameters._output_edges.begin();
              it != parameters._output_edges.end(); ++it) {
             std::ostringstream ss_out;
@@ -245,14 +258,45 @@ public:
             if (not coordinator->exist_out_port(ss_out.str())) {
                 coordinator->add_out_port(ss_out.str());
             }
-            if (not BuiltFlatGraphManager < SchedulerHandle>::exist_link(
+
+            if (BuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators.find(it->first) !=
                 BuiltFlatGraphManager <
-                    SchedulerHandle >::_normal_simulators[it->first], "out",
-                coordinator, ss_out.str())) {
-                BuiltFlatGraphManager < SchedulerHandle>::add_link(
-                    BuiltFlatGraphManager <
-                        SchedulerHandle >::_normal_simulators[it->first], "out",
-                    coordinator, ss_out.str());
+                    SchedulerHandle >::_normal_simulators.end()) {
+                if (not BuiltFlatGraphManager < SchedulerHandle>::exist_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_normal_simulators[it->first],
+                        "out", coordinator, ss_out.str())) {
+                    BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_normal_simulators[it->first],
+                        "out", coordinator, ss_out.str());
+
+                    // std::cout << "link = " << BuiltFlatGraphManager <
+                    //     SchedulerHandle >::_normal_simulators[it->first]
+                    //     ->get_name() << "::" << "out -> "
+                    //           << coordinator->get_name()
+                    //           << "::" << ss_out.str()
+                    //           << std::endl;
+                }
+            } else {
+                if (not BuiltFlatGraphManager < SchedulerHandle>::exist_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_top_simulators[it->first],
+                        "out", coordinator, ss_out.str())) {
+                    BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_top_simulators[it->first],
+                        "out", coordinator, ss_out.str());
+
+                    // std::cout << "link = " << BuiltFlatGraphManager <
+                    //     SchedulerHandle >::_top_simulators[it->first]
+                    //     ->get_name() << "::" << "out -> "
+                    //           << coordinator->get_name()
+                    //           << "::" << ss_out.str()
+                    //           << std::endl;
+
+                }
             }
         }
     }
@@ -298,7 +342,7 @@ public:
             if (not coordinator->exist_out_port(ss_out.str())) {
                 coordinator->add_out_port(ss_out.str());
             }
-            if (not ParallelBuiltFlatGraphManager < SchedulerHandle>::exist_link(
+            if (not ParallelBuiltFlatGraphManager < SchedulerHandle >::exist_link(
                 ParallelBuiltFlatGraphManager <
                     SchedulerHandle >::_normal_simulators[it->first], "out",
                 coordinator, ss_out.str())) {
@@ -397,31 +441,12 @@ public:
         graph_builder.build(graphs, input_edges, output_edges,
                             parent_connections);
 
-        // for (unsigned int i = 0; i < graphs.size(); ++i) {
-        //     std::cout << "graph[" << i << "]:" << std::endl;
-        //     const OrientedGraph& og = graphs[i];
-        //     OrientedGraph::vertex_iterator it_og, end_og;
-        //     tie(it_og, end_og) = vertices(og);
-        //     for (; it_og != end_og; ++it_og) {
-        //         OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-        //         std::cout << og[*it_og]._index << " is connected with ";
-        //         tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og,
-        //                                                              og);
-        //         for (; neighbour_it != neighbour_end; ++neighbour_it)
-        //             std::cout << og[*neighbour_it]._index << " ";
-        //         std::cout << " and weight = " << og[*it_og]._weight
-        //                   << std::endl;
-        //     }
-        //     std::cout << "===" << std::endl;
-        // }
-
         // build coordinators (graphs)
         for (unsigned int i = 0; i < graphs.size(); ++i) {
             Coordinator* coordinator = 0;
             std::ostringstream ss;
 
-            ss << "S" << (i + 1);
+            ss << "S" << i;
             coordinator =
                 new Coordinator(ss.str(), paradevs::common::NoParameters(),
                                 GraphParameters(graphs[i], input_edges[i],
@@ -433,6 +458,8 @@ public:
 
         }
 
+        // std::cout << "Root:" << std::endl;
+
         // builds internal connections (edges)
         for (Connections::const_iterator it = parent_connections.begin();
              it != parent_connections.end(); ++it) {
@@ -449,6 +476,15 @@ public:
                         ss_out.str(),
                         _coordinators[connection.second.first - 1],
                         ss_in.str())) {
+
+                // std::cout << "link = "
+                //           << _coordinators[connection.first.first - 1]
+                //     ->get_name()
+                //           << "::" << ss_out.str() << " -> "
+                //           << _coordinators[connection.second.first - 1]
+                //     ->get_name()
+                //           << "::" << ss_in.str() << std::endl;
+
                 HeapHierarchicalGraphManager <
                     SchedulerHandle, GraphBuilder >::add_link(
                         _coordinators[connection.first.first - 1],
@@ -512,7 +548,7 @@ public:
             Coordinator* coordinator = 0;
             std::ostringstream ss;
 
-            ss << "S" << (i + 1);
+            ss << "S" << i;
             coordinator =
                 new Coordinator(ss.str(), paradevs::common::NoParameters(),
                                 GraphParameters(graphs[i], input_edges[i],
@@ -604,7 +640,7 @@ public:
             ParallelCoordinator* coordinator = 0;
             std::ostringstream ss;
 
-            ss << "S" << (i + 1);
+            ss << "S" << i;
             coordinator =
                 new ParallelCoordinator(ss.str(),
                                         paradevs::common::NoParameters(),

+ 62 - 11
src/tests/boost_graph/graph_partitioning.hpp

@@ -48,26 +48,23 @@ public:
                OutputEdgeList& output_edges,
                Connections& parent_connections)
     {
-        srand((unsigned)time(NULL));
-    	//srand(7266);
-
         UnorientedGraph* g = new UnorientedGraph();
         OrientedGraph go;
         UnorientedGraph graph_origin;
 
         // internal examples
-        // {
-        //     build_graph(*g, go);
-        //     boost::copy_graph(*g, graph_origin);
-        // }
-
-        // corsen examples
         {
-            build_corsen_graph(go);
-            make_unoriented_graph(go, *g);
+            build_graph(*g, go);
             boost::copy_graph(*g, graph_origin);
         }
 
+        // corsen examples
+        // {
+        //     build_corsen_graph(go);
+        //     make_unoriented_graph(go, *g);
+        //     boost::copy_graph(*g, graph_origin);
+        // }
+
         Edges edge_partie;
         Connections connections;
 
@@ -89,6 +86,60 @@ public:
                                  output_edges, input_edges,
                                  parent_connections);
         }
+
+        std::cout << "*********************************" << std::endl;
+        std::cout << "Graphs:" << std::endl;
+        for (unsigned int i = 0; i < graphs.size(); ++i) {
+            std::cout << "graph[" << i << "]:" << std::endl;
+            const OrientedGraph& og = graphs[i];
+            OrientedGraph::vertex_iterator it_og, end_og;
+
+            tie(it_og, end_og) = vertices(og);
+            for (; it_og != end_og; ++it_og) {
+                OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+                std::cout << og[*it_og]._index << " -> { ";
+                tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og,
+                                                                     og);
+                for (; neighbour_it != neighbour_end; ++neighbour_it) {
+                    std::cout << og[*neighbour_it]._index << " ";
+                }
+                std::cout << "}" << std::endl;
+            }
+        }
+        {
+            unsigned int i = 0;
+
+            std::cout << "Input edges:" << std::endl;
+            for (InputEdgeList::const_iterator it = input_edges.begin();
+                 it != input_edges.end(); ++it, ++i) {
+                std::cout << "S" << i << " = {";
+                for (InputEdges::const_iterator it2 = it->begin();
+                     it2 != it->end(); ++it2) {
+                    std::cout << " ( " << it2->first << " -> " << it2->second
+                              << " )";
+                }
+                std::cout << " }" << std::endl;;
+            }
+        }
+        {
+            unsigned int i = 0;
+
+            std::cout << "Output edges:" << std::endl;
+            for (OutputEdgeList::const_iterator it = output_edges.begin();
+                 it != output_edges.end(); ++it, ++i) {
+                std::cout << "S" << i << " = {";
+                for (OutputEdges::const_iterator it2 = it->begin();
+                     it2 != it->end(); ++it2) {
+                    std::cout << " ( " << it2->first << " -> " << it2->second
+                              << " )";
+                }
+                std::cout << " }" << std::endl;;
+            }
+        }
+
+        std::cout << "*********************************" << std::endl;
+
     }
 
 private:

+ 21 - 4
src/tests/boost_graph/models.hpp

@@ -33,6 +33,8 @@
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
+int N;
+
 struct TopPixelParameters
 { };
 
@@ -57,6 +59,8 @@ public:
         // std::cout << TopPixel < SchedulerHandle >::get_name() << " at "
         //           << t << ": dint" << std::endl;
 
+        N++;
+
     }
 
     virtual typename common::DoubleTime::type start(
@@ -106,7 +110,7 @@ public:
     virtual ~NormalPixel()
     { }
 
-    virtual void dint(typename common::DoubleTime::type /* t */)
+    virtual void dint(typename common::DoubleTime::type t)
     {
 
         // std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
@@ -115,10 +119,11 @@ public:
         if (_phase == SEND) {
             _phase = WAIT;
             _received = 0;
+            _last_time = t;
         }
     }
 
-    virtual void dext(typename common::DoubleTime::type /* t */,
+    virtual void dext(typename common::DoubleTime::type t,
                       typename common::DoubleTime::type /* e */,
                       const common::Bag < common::DoubleTime,
                                           SchedulerHandle >& bag)
@@ -132,8 +137,14 @@ public:
                                     SchedulerHandle >::const_iterator it =
                  bag.begin(); it != bag.end(); ++it) {
             if (it->on_port("in")) {
+                if (_last_time == t) {
+                    std::cout << "oups !" << std::endl;
+                }
                 ++_received;
                 if (_received == _neighbour_number) {
+
+                    N++;
+
                     _phase = SEND;
                 }
             }
@@ -149,8 +160,13 @@ public:
     virtual typename common::DoubleTime::type start(
         typename common::DoubleTime::type /* t */)
     {
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name()
+        //           << " = " <<_neighbour_number << std::endl;
+
         _phase = WAIT;
         _received = 0;
+        _last_time = common::DoubleTime::negative_infinity;
         return common::DoubleTime::infinity;
     }
 
@@ -189,8 +205,9 @@ private:
 
     unsigned int _neighbour_number;
 
-    Phase _phase;
-    unsigned int _received;
+    Phase                             _phase;
+    unsigned int                      _received;
+    typename common::DoubleTime::type _last_time;
 };
 
 } } } // namespace paradevs tests boost_graph

+ 2 - 2
src/tests/boost_graph/partitioning/gggp.cpp

@@ -747,7 +747,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
                            std::string choix_affinage,
                            std::string type_cut,
                            Edges& /* edge_partie */,
-                           OutputEdgeList& outputedgeslist,
+                           OutputEdgeList& outputedgelist,
                            InputEdgeList& inputedgelist,
                            Connections& connections)
 {
@@ -893,7 +893,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
 
     }
 
-    OrientedGraphs Graphes = Graph_Partition(Partition, go, g, outputedgeslist,
+    OrientedGraphs Graphes = Graph_Partition(Partition, go, g, outputedgelist,
                                              inputedgelist, connections);
 
     // std::cout<<std::endl;

+ 25 - 12
src/tests/boost_graph/tests.cpp

@@ -197,10 +197,18 @@ void test(double duration, std::string partitioning_method_name,
                 double t1 = t.elapsed();
 
                 for (unsigned int i = 0; i < 20; ++i) {
+
+                    N = 0;
+
+                    std::cout << "********************" << std::endl;
+
                     partitionning_heap_test(duration, n,
                                             partitioning_method_name,
                                             contraction_coef,
                                             contraction_coef_flag);
+
+                    std::cout << "N=" << N << std::endl;
+
                 }
 
                 double t2 = t.elapsed();
@@ -264,7 +272,7 @@ void test_flat_38()
 {
     boost::timer t;
 
-    std::cout << "== 38 nodes == " << std::endl;
+    std::cout << "== 38 nodes ==" << std::endl;
     std::cout << "flat graph with heap = ";
     for (unsigned int i = 0; i < 20; ++i) {
         flat_heap_test< FlatGraphBuilder >(10000);
@@ -286,15 +294,18 @@ void test_flat_38()
 
 void test_partiotining_38()
 {
-    for (int i = 1; i <= 2; ++i) {
-        test(10000, "ggp", 2, 16, 2, true, true, i, true);
-        test(10000, "gggp_pond", 2, 16, 2, true, true, i, true);
-        test(10000, "random", 2, 16, 2, true, true, i, true);
-    }
 
-    for (int i = 2; i <= 8; i += 2) {
-        test(10000, "gggp_pond", 0, 0, 0, true, true, i, false);
-    }
+    test(0, "gggp_pond", 4, 4, 2, false, true, 1, true);
+
+    // for (int i = 1; i <= 2; ++i) {
+    //     test(10000, "ggp", 2, 16, 2, true, true, i, true);
+    //     test(10000, "gggp_pond", 2, 16, 2, true, true, i, true);
+    //     test(10000, "random", 2, 16, 2, true, true, i, true);
+    // }
+
+    // for (int i = 2; i <= 8; i += 2) {
+    //     test(10000, "gggp_pond", 0, 0, 0, true, true, i, false);
+    // }
 }
 
 void test_flat_corsen()
@@ -364,11 +375,13 @@ void test_partitioning_corsen()
 
 int main()
 {
+    srand(7262);
+
     // test_flat_38();
-    // test_partiotining_38();
+    test_partiotining_38();
 
-    test_flat_corsen();
-    test_partitioning_corsen();
+    // test_flat_corsen();
+    // test_partitioning_corsen();
 
     return 0;
 }