]> AND Private Git Repository - loba.git/blobdiff - options.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Remove redundant includes.
[loba.git] / options.cpp
index 0a9fb5ce1fa1b0b7e76ac88b719fd95b33075311..54fd53d19000426dbf487e7491d3675e32b99173 100644 (file)
@@ -26,13 +26,13 @@ namespace opt {
     // Automatic deployment
     namespace auto_depl {
         bool        enabled = false;
     // Automatic deployment
     namespace auto_depl {
         bool        enabled = false;
-        std::string topology;
+        std::string topology("clique");
         unsigned    nhosts = 0;
         double      load = 0.0;
     }
 
     // Load balancing algorithm
         unsigned    nhosts = 0;
         double      load = 0.0;
     }
 
     // Load balancing algorithm
-    std::string loba_algo("none");
+    std::string loba_algo("simple");
     bool bookkeeping = false;
 
     // Application parameters
     bool bookkeeping = false;
 
     // Application parameters
@@ -45,20 +45,24 @@ namespace opt {
     loba_algorithms_type loba_algorithms;
     loba_algorithms_type::loba_algorithms_type()
     {
     loba_algorithms_type loba_algorithms;
     loba_algorithms_type::loba_algorithms_type()
     {
-        THIS_INSERT("none", "no load-balancing", process);
-        THIS_INSERT("simple", "balance with least loaded neighbor",
-                    loba_simple);
+        NOL_INSERT("none", "no load-balancing (for testing)", process);
+        NOL_INSERT("simple", "balance with least loaded neighbor", loba_simple);
     }
 
     }
 
-#if 0
     topologies_type topologies;
     topologies_type::topologies_type()
     {
     topologies_type topologies;
     topologies_type::topologies_type()
     {
-        THIS_INSERT("none", "no load-balancing", process);
-        THIS_INSERT("simple", "balance with least loaded neighbor",
-                    loba_simple);
+        NOL_INSERT("btree", "binary tree topologym intiial load at root", 
+                   deployment_btree);
+        NOL_INSERT("clique", "all connected topology", deployment_clique);
+        NOL_INSERT("hcube", "hypercube topology", deployment_hcube);
+        NOL_INSERT("line", "line topology, initial load at one end",
+                   deployment_line);
+        NOL_INSERT("ring", "ring topology", deployment_ring);
+        NOL_INSERT("star", "star topology, initial load at center",
+                   deployment_star);
+        // NOL_INSERT("torus", "torus topology", deployment_torus);
     }
     }
-#endif
 
 } // namespace opt
 
 
 } // namespace opt
 
@@ -84,6 +88,11 @@ int opt::parse_args(int* argc, char* argv[])
         switch (c) {
         case 'a':
             opt::loba_algo = optarg;
         switch (c) {
         case 'a':
             opt::loba_algo = optarg;
+            if (!opt::loba_algorithms.exists(opt::loba_algo)) {
+                ERROR1("unknownw load balancing algorithm -- %s",
+                       opt::loba_algo.c_str());
+                result = 0;
+            }
             break;
         case 'b':
             opt::bookkeeping = true;
             break;
         case 'b':
             opt::bookkeeping = true;
@@ -113,7 +122,12 @@ int opt::parse_args(int* argc, char* argv[])
             std::istringstream(optarg) >> opt::auto_depl::nhosts;
             break;
         case 'T':
             std::istringstream(optarg) >> opt::auto_depl::nhosts;
             break;
         case 'T':
-            opt::auto_depl::topology = optarg;
+            opt::auto_depl::topology = optarg; 
+            if (!opt::topologies.exists(opt::auto_depl::topology)) {
+                ERROR1("unknownw topology -- %s",
+                       opt::auto_depl::topology.c_str());
+                result = 0;
+            }
             break;
         case 'V':
             opt::version_requested = true;
             break;
         case 'V':
             opt::version_requested = true;
@@ -124,7 +138,6 @@ int opt::parse_args(int* argc, char* argv[])
             break;
         }
     }
             break;
         }
     }
-    opt::auto_depl::enabled = !opt::auto_depl::topology.empty();
 
     if (opt::version_requested || opt::help_requested)
         return 1;
 
     if (opt::version_requested || opt::help_requested)
         return 1;
@@ -135,14 +148,10 @@ int opt::parse_args(int* argc, char* argv[])
         ERROR0("missing parameter -- <plaform_file>");
         result = 0;
     }
         ERROR0("missing parameter -- <plaform_file>");
         result = 0;
     }
-    if (!opt::auto_depl::enabled) {
-        if (optind < *argc) {
-            opt::deployment_file = argv[optind++];
-        } else {
-            ERROR0("missing parameter -- <deployment_file>");
-            result = 0;
-        }
+    if (optind < *argc) {
+        opt::deployment_file = argv[optind++];
     }
     }
+    opt::auto_depl::enabled = opt::deployment_file.empty();
 
     while (optind < *argc) {
         ERROR1("unused parameter -- \"%s\"", argv[optind++]);
 
     while (optind < *argc) {
         ERROR1("unused parameter -- \"%s\"", argv[optind++]);
@@ -155,21 +164,22 @@ int opt::parse_args(int* argc, char* argv[])
 void opt::print()
 {
     INFO0(",----[ Simulation parameters ]");
 void opt::print()
 {
     INFO0(",----[ Simulation parameters ]");
-    INFO1("| platform file.......: \"%s\"", opt::platform_file.c_str());
+    INFO1("| log rate.....................: %u",     opt::log_rate);
+    INFO1("| platform file................: \"%s\"", opt::platform_file.c_str());
     if (opt::auto_depl::enabled) {
     if (opt::auto_depl::enabled) {
-        INFO0("| automatic deployment enabled with:");
-        INFO1("|     topology........: %s", opt::auto_depl::topology.c_str());
-        INFO1("|     number of hosts.: %u", opt::auto_depl::nhosts);
-        INFO1("|     initial load....: %g", opt::auto_depl::load);
+        INFO0("| automatic deployment enabled");
+        INFO1("| - topology...................: %s", opt::auto_depl::topology.c_str());
+        INFO1("| - number of hosts............: %u", opt::auto_depl::nhosts);
+        INFO1("| - initial load...............: %g", opt::auto_depl::load);
     } else {
     } else {
-        INFO1("| deployment file.....: \"%s\"", opt::deployment_file.c_str());
+        INFO1("| deployment file..............: \"%s\"", opt::deployment_file.c_str());
     }
     }
-    INFO1("| log rate............: %u",     opt::log_rate);
-    INFO1("| maxiter.............: %u",     opt::maxiter);
-    INFO1("| exit on close.......: %s",     on_off(opt::exit_on_close));
-    INFO1("| bookkeeping.........: %s",     on_off(opt::bookkeeping));
-    INFO1("| comp. cost factors..: [%s]",   opt::comp_cost.to_string().c_str());
-    INFO1("| comm. cost factors..: [%s]",   opt::comm_cost.to_string().c_str());
+    INFO1("| load balancing algorithm.....: %s",   opt::loba_algo.c_str());
+    INFO1("| bookkeeping..................: %s",   on_off(opt::bookkeeping));
+    INFO1("| computation cost factors.....: [%s]", opt::comp_cost.to_string().c_str());
+    INFO1("| communication cost factors...: [%s]", opt::comm_cost.to_string().c_str());
+    INFO1("| maximum number of iterations.: %u",   opt::maxiter);
+    INFO1("| exit on close................: %s",   on_off(opt::exit_on_close));
     INFO0("`----");
 }
 
     INFO0("`----");
 }
 
@@ -190,9 +200,7 @@ void opt::usage()
 
 
     std::clog << "Usage: " << opt::program_name
 
 
     std::clog << "Usage: " << opt::program_name
-              << " [options] <platform_file> <deployment_file>\n";
-    std::clog << "       " << opt::program_name
-              << " [options] -T type <platform_file>\n";
+              << " [options] <platform_file> [<deployment_file>]\n";
 
     std::clog << "\nGlobal options\n";
     std::clog << o("-h")
 
     std::clog << "\nGlobal options\n";
     std::clog << o("-h")
@@ -210,13 +218,10 @@ void opt::usage()
 
     std::clog << "\nAutomatic deployment options\n";
     std::clog << o("-T name")
 
     std::clog << "\nAutomatic deployment options\n";
     std::clog << o("-T name")
-              << "enable automatic deployment with selected topology\n";
+              << "enable automatic deployment with selected topology"
+              << " (" << opt::auto_depl::topology << ")\n";
     if (opt::help_requested > 1)
     if (opt::help_requested > 1)
-#if 0
         so_list(opt::topologies);
         so_list(opt::topologies);
-#else
-        std::clog << so("name") << "FIXME\n"; // fixme
-#endif
     std::clog << o("-L value")
               << "total load with auto deployment, 0 for number of hosts"
               << " (" << opt::auto_depl::load << ")\n";
     std::clog << o("-L value")
               << "total load with auto deployment, 0 for number of hosts"
               << " (" << opt::auto_depl::load << ")\n";