8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu);
12 const char* program_name;
14 const char* platform_file;
15 const char* application_file;
17 int help_requested = 0;
18 bool version_requested = false;
20 cost_func comp_cost("1e9, 0"); // fixme: find better defaults
21 cost_func comm_cost("1e9, 0"); // fixme: find better defaults
25 int opt::parse_args(int* argc, char* argv[])
27 char *tmp = strrchr(argv[0], '/');
28 opt::program_name = (tmp ? tmp + 1 : argv[0]);
32 while ((c = getopt(*argc, argv, "hc:C:V")) != -1) {
35 opt::help_requested++;
38 opt::comp_cost = cost_func(optarg);
41 opt::comm_cost = cost_func(optarg);
44 opt::version_requested = true;
47 WARN1("invalid option -- '%c'", optopt);
51 if (opt::version_requested || opt::help_requested)
54 switch (*argc - optind) {
56 ERROR0("missing parameter -- <plaform_file>");
58 ERROR0("missing parameter -- <application_file>");
62 opt::platform_file = argv[optind];
63 opt::application_file = argv[optind + 1];
64 for (int i = optind + 2 ; i < *argc ; ++i)
65 WARN1("unused parameter -- \"%s\"", argv[i]);
74 INFO0(",----[ Simulation parameters ]");
75 INFO1("| platform_file.......: \"%s\"", opt::platform_file);
76 INFO1("| application_file....: \"%s\"", opt::application_file);
77 INFO1("| comp. cost factors..: [%s]", opt::comp_cost.to_string().c_str());
78 INFO1("| comm. cost factors..: [%s]", opt::comm_cost.to_string().c_str());
85 const int indent1 = 6;
86 const int indent2 = 12;
88 #define oo(opt, arg) std::setw(indent1) << (opt) << " " \
89 << std::setw(indent2) << std::left << (arg) << std::right
90 #define o(opt) oo(opt, "")
92 std::clog << "Usage: " << opt::program_name
93 << " [options] <platform_file> <application_file>\n";
96 << "print help and exit (use -hh or -hhh for extended help)\n";
97 if (opt::help_requested < 1)
99 std::clog << o("-V") << "print version and exit\n";
100 std::clog << oo("-c", "[fn,...]f0")
101 << "polynomial factors for computation cost ("
102 << opt::comp_cost.to_string() << ")\n";
103 std::clog << oo("-C", "[fn,...]f0")
104 << "polynomial factors for communication cost ("
105 << opt::comm_cost.to_string() << ")\n";