]> AND Public Git Repository - simgrid.git/blobdiff - examples/s4u/io-file-remote/s4u-io-file-remote.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the wifi energy plugin to the SimGrid build system and let it compile
[simgrid.git] / examples / s4u / io-file-remote / s4u-io-file-remote.cpp
index d1dda9329a739cf37e4c7e349d32b23f31770c7f..a3b2fd919f6657395e0b6bbc1107dc8cfaea3abc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +11,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
 
-static int host(int argc, char* argv[])
+static void host(int argc, char* argv[])
 {
   simgrid::s4u::File file(argv[1], nullptr);
   const char* filename = file.get_path();
@@ -19,19 +19,19 @@ static int host(int argc, char* argv[])
   file.dump();
   XBT_INFO("Try to write %llu MiB to '%s'", file.size() / 1024, filename);
   sg_size_t write = file.write(file.size() * 1024);
-  XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
-
-  if (std::stoi(argv[4]) != 0) {
-    XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
-             simgrid::s4u::Host::current()->get_cname(), argv[2]);
-    file.remote_move(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
-  } else {
-    XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
-             simgrid::s4u::Host::current()->get_cname(), argv[2]);
-    file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
+  XBT_INFO("Have written %llu MiB to '%s'.", write / (1024 * 1024), filename);
+
+  if (argc > 4) {
+    if (std::stoi(argv[4]) != 0) {
+      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
+               simgrid::s4u::Host::current()->get_cname(), argv[2]);
+      file.remote_move(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
+    } else {
+      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
+               simgrid::s4u::Host::current()->get_cname(), argv[2]);
+      file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
+    }
   }
-
-  return 0;
 }
 
 int main(int argc, char** argv)
@@ -45,8 +45,8 @@ int main(int argc, char** argv)
 
   for (auto const& h : all_hosts) {
     for (auto const& d : h->get_disks())
-      XBT_INFO("Init: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
-               sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
+      XBT_INFO("Init: %s: %llu/%llu MiB used/free on '%s@%s'", h->get_cname(), sg_disk_get_size_used(d) / INMEGA,
+               sg_disk_get_size_free(d) / INMEGA, d->get_cname(), d->get_host()->get_cname());
   }
 
   e.run();