X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/fc5dcac1115a7112e7ad9d67ce7fe233790e0887..325b135f0ee33c6c0242a14e2f58a54fb571b032:/options.cpp diff --git a/options.cpp b/options.cpp index d51fee2..4f9c52c 100644 --- a/options.cpp +++ b/options.cpp @@ -1,11 +1,14 @@ -#include +#include "options.h" + +#include // strrchr +#include #include -#include +#include +#include // getopt #include -#include "options.h" #include "misc.h" -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu); +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main); namespace opt { @@ -17,9 +20,15 @@ namespace opt { int help_requested = 0; bool version_requested = false; + unsigned log_rate = 1; + + unsigned maxiter = 4; + bool exit_on_close = false; + bool bookkeeping = false; cost_func comp_cost("1e9, 0"); // fixme: find better defaults + cost_func comm_cost("1, 0"); // fixme: find better defaults } // namespace opt @@ -41,17 +50,29 @@ int opt::parse_args(int* argc, char* argv[]) int c; opterr = 0; - while ((c = getopt(*argc, argv, "bc:hV")) != -1) { + while ((c = getopt(*argc, argv, "bc:C:ehi:l:V")) != -1) { switch (c) { case 'b': opt::bookkeeping = true; break; + case 'e': + opt::exit_on_close = true; + break; case 'h': opt::help_requested++; break; case 'c': opt::comp_cost = cost_func(optarg); break; + case 'C': + opt::comm_cost = cost_func(optarg); + break; + case 'i': + std::istringstream(optarg) >> opt::maxiter; + break; + case 'l': + std::istringstream(optarg) >> opt::log_rate; + break; case 'V': opt::version_requested = true; break; @@ -92,12 +113,15 @@ void opt::print() INFO0(",----[ Simulation parameters ]"); INFO1("| platform_file.......: \"%s\"", opt::platform_file); INFO1("| application_file....: \"%s\"", opt::application_file); + 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()); INFO0("`----"); } -#include void opt::usage() { const int indent1 = 6; @@ -116,10 +140,21 @@ void opt::usage() return; std::clog << o("-V") << "print version and exit\n"; + std::clog << o("-b") << "activate bookkeeping\n"; std::clog << oo("-c", "[fn,...]f0") << "polynomial factors for computation cost (" << opt::comp_cost.to_string() << ")\n"; + std::clog << oo("-C", "[fn,...]f0") + << "polynomial factors for communication cost (" + << opt::comm_cost.to_string() << ")\n"; + std::clog << o("-e") << "exit on close reception\n"; + std::clog << oo("-i", "value") + << "maximum number of iterations, 0 for infinity (" + << opt::maxiter << ")\n"; + std::clog << oo("-l", "value") + << "print current load every \"value\" iterations, 0 to disable (" + << opt::log_rate << ")\n"; #undef o #undef oo