Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Oops, forgotten files
authorBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 27 Jul 2021 19:09:30 +0000 (21:09 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 30 Jul 2021 12:54:11 +0000 (14:54 +0200)
teshsuite/s4u/io-set-bw/io-set-bw.cpp [new file with mode: 0644]
teshsuite/s4u/io-set-bw/io-set-bw.tesh [new file with mode: 0644]

diff --git a/teshsuite/s4u/io-set-bw/io-set-bw.cpp b/teshsuite/s4u/io-set-bw/io-set-bw.cpp
new file mode 100644 (file)
index 0000000..cb0c5e2
--- /dev/null
@@ -0,0 +1,95 @@
+/* Copyright (c) 2017-2021. 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. */
+
+#include <simgrid/s4u.hpp>
+
+namespace sg4 = simgrid::s4u;
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(io_set_bw, "Messages specific for this simulation");
+
+static void io(const sg4::Disk* disk)
+{
+  double cur_time = sg4::Engine::get_clock();
+  disk->read(1e6);
+  XBT_INFO("Read finished. Took: %lf", sg4::Engine::get_clock() - cur_time);
+  cur_time = sg4::Engine::get_clock();
+  disk->write(1e6);
+  XBT_INFO("Write finished. Took: %lf", sg4::Engine::get_clock() - cur_time);
+}
+
+static void host()
+{
+  auto* disk = sg4::Host::current()->get_disks()[0];
+  XBT_INFO("I/O operations: size 1e6. Should take 1s each");
+  io(disk);
+
+  XBT_INFO("Setting read limit to half (.5e6). Read should take 2s, write still 1s");
+  disk->set_read_bandwidth(.5e6);
+  io(disk);
+
+  XBT_INFO("Setting write limit to half (.5e6). Write should take 2s, read still 1s");
+  disk->set_read_bandwidth(1e6);
+  disk->set_write_bandwidth(.5e6);
+  io(disk);
+
+  XBT_INFO("Setting readwrite limit to half (.5e6). Write and read should take 2s now");
+  disk->set_readwrite_bandwidth(.5e6);
+  disk->set_write_bandwidth(1e6);
+  io(disk);
+
+  disk->set_readwrite_bandwidth(1e6);
+  sg4::IoPtr act;
+  double cur_time;
+  XBT_INFO("Change bandwidth in the middle of I/O operation");
+  XBT_INFO("Setting read limit to half (.5e6) in the middle of IO. Read should take 1.5s");
+  cur_time = sg4::Engine::get_clock();
+  act      = disk->read_async(1e6);
+  sg4::this_actor::sleep_for(.5);
+  disk->set_read_bandwidth(.5e6);
+  act->wait();
+  XBT_INFO("Read finished. Took: %lf", sg4::Engine::get_clock() - cur_time);
+  disk->set_read_bandwidth(1e6);
+
+  XBT_INFO("Setting write limit to half (.5e6) in the middle of IO. Write should take 1.5s");
+  cur_time = sg4::Engine::get_clock();
+  act      = disk->write_async(1e6);
+  sg4::this_actor::sleep_for(.5);
+  disk->set_write_bandwidth(.5e6);
+  act->wait();
+  XBT_INFO("Write finished. Took: %lf", sg4::Engine::get_clock() - cur_time);
+  disk->set_write_bandwidth(1e6);
+
+  XBT_INFO("Setting readwrite limit to half (.5e6) in the middle of IO. Read and write should take 1.5s");
+  cur_time        = sg4::Engine::get_clock();
+  act             = disk->write_async(1e6 / 2);
+  sg4::IoPtr act2 = disk->read_async(1e6 / 2);
+  sg4::this_actor::sleep_for(.5);
+  disk->set_readwrite_bandwidth(.5e6);
+  act->wait();
+  act2->wait();
+  XBT_INFO("Read and write finished. Took: %lf", sg4::Engine::get_clock() - cur_time);
+}
+
+/*************************************************************************************************/
+int main(int argc, char** argv)
+{
+  sg4::Engine e(&argc, argv);
+
+  /* simple platform containing 1 host and 2 disk */
+  auto* zone = sg4::create_full_zone("bob_zone");
+  auto* bob  = zone->create_host("bob", 1e6);
+  auto* disk = bob->create_disk("bob_disk", 1e3, 1e3);
+  /* manually setting before seal */
+  disk->set_read_bandwidth(1e6);
+  disk->set_write_bandwidth(1e6);
+  disk->set_readwrite_bandwidth(1e6);
+  zone->seal();
+
+  sg4::Actor::create("", bob, host);
+
+  e.run();
+
+  return 0;
+}
diff --git a/teshsuite/s4u/io-set-bw/io-set-bw.tesh b/teshsuite/s4u/io-set-bw/io-set-bw.tesh
new file mode 100644 (file)
index 0000000..c3b39ed
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/io-set-bw  "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n"
+> [  0.000000] [1:@bob] I/O operations: size 1e6. Should take 1s each
+> [  1.000000] [1:@bob] Read finished. Took: 1.000000
+> [  2.000000] [1:@bob] Write finished. Took: 1.000000
+> [  2.000000] [1:@bob] Setting read limit to half (.5e6). Read should take 2s, write still 1s
+> [  4.000000] [1:@bob] Read finished. Took: 2.000000
+> [  5.000000] [1:@bob] Write finished. Took: 1.000000
+> [  5.000000] [1:@bob] Setting write limit to half (.5e6). Write should take 2s, read still 1s
+> [  6.000000] [1:@bob] Read finished. Took: 1.000000
+> [  8.000000] [1:@bob] Write finished. Took: 2.000000
+> [  8.000000] [1:@bob] Setting readwrite limit to half (.5e6). Write and read should take 2s now
+> [ 10.000000] [1:@bob] Read finished. Took: 2.000000
+> [ 12.000000] [1:@bob] Write finished. Took: 2.000000
+> [ 12.000000] [1:@bob] Change bandwidth in the middle of I/O operation
+> [ 12.000000] [1:@bob] Setting read limit to half (.5e6) in the middle of IO. Read should take 1.5s
+> [ 13.500000] [1:@bob] Read finished. Took: 1.500000
+> [ 13.500000] [1:@bob] Setting write limit to half (.5e6) in the middle of IO. Write should take 1.5s
+> [ 15.000000] [1:@bob] Write finished. Took: 1.500000
+> [ 15.000000] [1:@bob] Setting readwrite limit to half (.5e6) in the middle of IO. Read and write should take 1.5s
+> [ 16.500000] [1:@bob] Read and write finished. Took: 1.500000