1 /* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include <xbt/xbt_os_time.h>
8 #include "simgrid/kernel/routing/NetPoint.hpp"
9 #include "simgrid/s4u/Engine.hpp"
10 #include "simgrid/s4u/Host.hpp"
11 #include "simgrid/s4u/Link.hpp"
12 #include "src/kernel/resource/StandardLinkImpl.hpp"
18 XBT_LOG_NEW_DEFAULT_CATEGORY(flatifier, "Logging specific to this platform parsing tool");
20 namespace sg4 = simgrid::s4u;
22 static bool parse_cmdline(bool* timings, char** platformFile, int argc, char** argv)
25 for (int i = 1; i < argc; i++) {
26 if (std::strlen(argv[i]) > 1 && argv[i][0] == '-' && argv[i][1] == '-') {
27 if (not std::strcmp(argv[i], "--timings")) {
34 *platformFile = argv[i];
37 return parse_ok && platformFile != nullptr;
40 int main(int argc, char** argv)
42 char* platformFile = nullptr;
45 xbt_os_timer_t parse_time = xbt_os_timer_new();
47 sg4::Engine e(&argc, argv);
49 xbt_assert(parse_cmdline(&timings, &platformFile, argc, argv),
50 "Invalid command line arguments: expected [--timings] platformFile");
52 xbt_os_cputimer_start(parse_time);
53 e.load_platform(platformFile);
55 xbt_os_cputimer_stop(parse_time);
58 XBT_INFO("Parsing time: %fs (%zu hosts, %zu links)", xbt_os_timer_elapsed(parse_time), e.get_host_count(),
61 std::printf("%s", e.flatify_platform().c_str());
64 xbt_os_timer_free(parse_time);