X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0bfafcab47ae9cd7856bd8d129404c33079d6afe..a63884b15fee21a09274893023af54be40b0bbe2:/examples/cpp/comm-pingpong/s4u-comm-pingpong.cpp diff --git a/examples/cpp/comm-pingpong/s4u-comm-pingpong.cpp b/examples/cpp/comm-pingpong/s4u-comm-pingpong.cpp index 5ae5a3f263..c4c934e2b3 100644 --- a/examples/cpp/comm-pingpong/s4u-comm-pingpong.cpp +++ b/examples/cpp/comm-pingpong/s4u-comm-pingpong.cpp @@ -1,40 +1,41 @@ -/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2023. 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 +namespace sg4 = simgrid::s4u; XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_pingpong, "Messages specific for this s4u example"); -static void pinger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mailbox_out) +static void pinger(sg4::Mailbox* mailbox_in, sg4::Mailbox* mailbox_out) { XBT_INFO("Ping from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str()); /* - Do the ping with a 1-Byte payload (latency bound) ... */ - auto* payload = new double(simgrid::s4u::Engine::get_clock()); + auto* payload = new double(sg4::Engine::get_clock()); mailbox_out->put(payload, 1); /* - ... then wait for the (large) pong */ auto sender_time = mailbox_in->get_unique(); - double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time; + double communication_time = sg4::Engine::get_clock() - *sender_time; XBT_INFO("Payload received : large communication (bandwidth bound)"); XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time); } -static void ponger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mailbox_out) +static void ponger(sg4::Mailbox* mailbox_in, sg4::Mailbox* mailbox_out) { XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str()); /* - Receive the (small) ping first ....*/ auto sender_time = mailbox_in->get_unique(); - double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time; + double communication_time = sg4::Engine::get_clock() - *sender_time; XBT_INFO("Payload received : small communication (latency bound)"); XBT_INFO("Ping time (latency bound) %f", communication_time); /* - ... Then send a 1GB pong back (bandwidth bound) */ - auto* payload = new double(simgrid::s4u::Engine::get_clock()); + auto* payload = new double(sg4::Engine::get_clock()); XBT_INFO("payload = %.3f", *payload); mailbox_out->put(payload, 1e9); @@ -42,18 +43,18 @@ static void ponger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai int main(int argc, char* argv[]) { - simgrid::s4u::Engine e(&argc, argv); + sg4::Engine e(&argc, argv); e.load_platform(argv[1]); - simgrid::s4u::Mailbox* mb1 = simgrid::s4u::Mailbox::by_name("Mailbox 1"); - simgrid::s4u::Mailbox* mb2 = simgrid::s4u::Mailbox::by_name("Mailbox 2"); + sg4::Mailbox* mb1 = e.mailbox_by_name_or_create("Mailbox 1"); + sg4::Mailbox* mb2 = e.mailbox_by_name_or_create("Mailbox 2"); - simgrid::s4u::Actor::create("pinger", simgrid::s4u::Host::by_name("Tremblay"), pinger, mb1, mb2); - simgrid::s4u::Actor::create("ponger", simgrid::s4u::Host::by_name("Jupiter"), ponger, mb2, mb1); + sg4::Actor::create("pinger", e.host_by_name("Tremblay"), pinger, mb1, mb2); + sg4::Actor::create("ponger", e.host_by_name("Jupiter"), ponger, mb2, mb1); e.run(); - XBT_INFO("Total simulation time: %.3f", e.get_clock()); + XBT_INFO("Total simulation time: %.3f", sg4::Engine::get_clock()); return 0; }