1 /* Copyright (c) 2017-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 "simgrid/s4u.hpp"
7 #include "simgrid/plugins/jbod.hpp"
9 XBT_LOG_NEW_DEFAULT_CATEGORY(jbod_test, "Messages specific for this simulation");
10 namespace sg4 = simgrid::s4u;
12 static void write_then_read(simgrid::plugin::Jbod* jbod)
14 simgrid::plugin::JbodIoPtr io = jbod->write_async(1e7);
15 XBT_INFO("asynchronous write posted, wait for it");
17 XBT_INFO("asynchronous write done");
19 XBT_INFO("synchonous read done");
21 XBT_INFO("synchonous write done");
22 io = jbod->read_async(1e7);
23 XBT_INFO("asynchronous read posted, wait for it");
25 XBT_INFO("asynchonous read done");
27 XBT_INFO("synchonous write done");
29 XBT_INFO("synchonous read done");
31 XBT_INFO("synchonous read done");
34 int main(int argc, char** argv)
36 sg4::Engine e(&argc, argv);
37 auto* zone = sg4::create_full_zone("zone");
38 auto* host = zone->create_host("host", "1Gf");
39 // set up link so that data transfer from host to JBOD takes exactly 1 second (without crosstraffic)
40 auto* link = zone->create_link("link", 1e7/0.97)->set_latency(0);
43 simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid0", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID0, 1e7, 5e6);
44 zone->add_route(host, jbod_raid0, {link});
47 simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid1", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID1, 1e7, 5e6);
48 zone->add_route(host, jbod_raid1, {link});
51 simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid4", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID4, 1e7, 5e6);
52 zone->add_route(host, jbod_raid4, {link});
55 simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid5", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID5, 1e7, 5e6);
56 zone->add_route(host, jbod_raid5, {link});
59 simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid6", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID6, 1e7, 5e6);
60 zone->add_route(host, jbod_raid6, {link});
64 XBT_INFO("XXXXXXXXXXXXXXX RAID 0 XXXXXXXXXXXXXXXX");
65 sg4::Actor::create("", host, write_then_read, jbod_raid0);
68 XBT_INFO("XXXXXXXXXXXXXXX RAID 1 XXXXXXXXXXXXXXXX");
69 sg4::Actor::create("", host, write_then_read, jbod_raid1);
72 XBT_INFO("XXXXXXXXXXXXXXX RAID 4 XXXXXXXXXXXXXXXX");
73 sg4::Actor::create("", host, write_then_read, jbod_raid4);
76 XBT_INFO("XXXXXXXXXXXXXXX RAID 5 XXXXXXXXXXXXXXXX");
77 sg4::Actor::create("", host, write_then_read, jbod_raid5);
80 XBT_INFO("XXXXXXXXXXXXXXX RAID 6 XXXXXXXXXXXXXXXX");
81 sg4::Actor::create("", host, write_then_read, jbod_raid6);
84 XBT_INFO("Simulated time: %g", sg4::Engine::get_clock());