Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
revisit pingpong in s4u
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 12 Jul 2017 13:19:25 +0000 (15:19 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 12 Jul 2017 13:19:25 +0000 (15:19 +0200)
examples/msg/app-pingpong/app-pingpong.c
examples/s4u/CMakeLists.txt
examples/s4u/app-pingpong/s4u_app-pingpong [new file with mode: 0755]
examples/s4u/app-pingpong/s4u_app-pingpong.cpp [new file with mode: 0644]
examples/s4u/app-pingpong/s4u_app-pingpong.tesh [new file with mode: 0644]

index 91a5b0f..3e12e81 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "simgrid/msg.h"
 
 
 #include "simgrid/msg.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(mag_app_pingpong,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_app_pingpong, "Messages specific for this msg example");
 
 static int pinger(int argc, char *argv[])
 {
 
 static int pinger(int argc, char *argv[])
 {
index 7f5486e..72a43da 100644 (file)
@@ -1,5 +1,5 @@
 foreach (example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend 
 foreach (example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend 
-                 app-masterworker app-token-ring plugin-hostload io mutex )
+                 app-masterworker app-pingpong app-token-ring plugin-hostload io mutex )
   add_executable       (s4u_${example}  ${example}/s4u_${example}.cpp)
   target_link_libraries(s4u_${example}  simgrid)
   set_target_properties(s4u_${example}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
   add_executable       (s4u_${example}  ${example}/s4u_${example}.cpp)
   target_link_libraries(s4u_${example}  simgrid)
   set_target_properties(s4u_${example}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
@@ -32,6 +32,6 @@ set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u_a
                                   ${CMAKE_CURRENT_SOURCE_DIR}/README.doc                                   PARENT_SCOPE)
 
 foreach(example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend 
                                   ${CMAKE_CURRENT_SOURCE_DIR}/README.doc                                   PARENT_SCOPE)
 
 foreach(example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend 
-                 app-masterworker app-token-ring dht-chord plugin-hostload io mutex )
+                 app-masterworker app-pingpong app-token-ring dht-chord plugin-hostload io mutex )
   ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u_${example}.tesh)
 endforeach()
   ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u_${example}.tesh)
 endforeach()
diff --git a/examples/s4u/app-pingpong/s4u_app-pingpong b/examples/s4u/app-pingpong/s4u_app-pingpong
new file mode 100755 (executable)
index 0000000..bd61f7b
Binary files /dev/null and b/examples/s4u/app-pingpong/s4u_app-pingpong differ
diff --git a/examples/s4u/app-pingpong/s4u_app-pingpong.cpp b/examples/s4u/app-pingpong/s4u_app-pingpong.cpp
new file mode 100644 (file)
index 0000000..d8c0384
--- /dev/null
@@ -0,0 +1,73 @@
+/* Copyright (c) 2007-2017. 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"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_pingpong, "Messages specific for this s4u example");
+
+static void pinger(std::vector<std::string> args)
+{
+  xbt_assert(args.size() == 1, "The pinger function one argument from the XML deployment file");
+  XBT_INFO("Ping -> %s", args[0].c_str());
+  xbt_assert(simgrid::s4u::Host::by_name_or_null(args[0]) != nullptr, "Unknown host %s. Stopping Now! ",
+             args[0].c_str());
+
+  /* - Do the ping with a 1-Byte task (latency bound) ... */
+  double* payload = new double();
+  *payload        = simgrid::s4u::Engine::getClock();
+
+  simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1);
+  /* - ... then wait for the (large) pong */
+  double sender_time =
+      *(static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get()));
+
+  double communication_time = simgrid::s4u::Engine::getClock() - sender_time;
+  XBT_INFO("Task received : large communication (bandwidth bound)");
+  XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
+}
+
+static void ponger(std::vector<std::string> args)
+{
+  xbt_assert(args.size() == 1, "The ponger function one argument from the XML deployment file");
+  XBT_INFO("Pong -> %s", args[0].c_str());
+  xbt_assert(simgrid::s4u::Host::by_name_or_null(args[0]) != nullptr, "Unknown host %s. Stopping Now! ",
+             args[0].c_str());
+
+  /* - Receive the (small) ping first ....*/
+  double* sender_time =
+      (static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get()));
+  double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
+  XBT_INFO("Task received : small communication (latency bound)");
+  XBT_INFO(" Ping time (latency bound) %f", communication_time);
+
+  /*  - ... Then send a 1GB pong back (bandwidth bound) */
+  double* payload = new double();
+  *payload        = simgrid::s4u::Engine::getClock();
+  XBT_INFO("task_bw->data = %.3f", *payload);
+
+  simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1e9);
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+
+  e->loadPlatform(argv[1]);
+  std::vector<std::string> args;
+  args.push_back("Jupiter");
+  simgrid::s4u::Actor::createActor("pinger", simgrid::s4u::Host::by_name("Tremblay"), pinger, args);
+
+  args.pop_back();
+  args.push_back("Tremblay");
+
+  simgrid::s4u::Actor::createActor("ponger", simgrid::s4u::Host::by_name("Jupiter"), ponger, args);
+
+  e->run();
+
+  XBT_INFO("Total simulation time: %.3f", e->getClock());
+  delete e;
+
+  return 0;
+}
diff --git a/examples/s4u/app-pingpong/s4u_app-pingpong.tesh b/examples/s4u/app-pingpong/s4u_app-pingpong.tesh
new file mode 100644 (file)
index 0000000..22a6bb3
--- /dev/null
@@ -0,0 +1,57 @@
+#! ./tesh
+
+p Testing with default compound
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [  0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [  0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [  0.019014] (2:ponger@Jupiter)  Ping time (latency bound) 0.019014
+> [  0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
+> [150.178356] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [150.178356] (1:pinger@Tremblay) Pong time (bandwidth bound): 150.159
+> [150.178356] (0:maestro@) Total simulation time: 150.178
+
+p Testing the deprecated CM02 network model
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
+> [  0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02'
+> [  0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [  0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [  0.001462] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [  0.001462] (2:ponger@Jupiter)  Ping time (latency bound) 0.001462
+> [  0.001462] (2:ponger@Jupiter) task_bw->data = 0.001
+> [145.639041] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [145.639041] (1:pinger@Tremblay) Pong time (bandwidth bound): 145.638
+> [145.639041] (0:maestro@) Total simulation time: 145.639
+
+p Testing the surf network Reno fairness model using lagrangian approach
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Reno" --log=surf_lagrange.thres=critical "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
+> [  0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
+> [  0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Reno'
+> [  0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [  0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [  0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [  0.019014] (2:ponger@Jupiter)  Ping time (latency bound) 0.019014
+> [  0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
+> [150.178356] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [150.178356] (1:pinger@Tremblay) Pong time (bandwidth bound): 150.159
+> [150.178356] (0:maestro@) Total simulation time: 150.178
+
+p Testing the surf network Vegas fairness model using lagrangian approach
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Vegas" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
+> [  0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
+> [  0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Vegas'
+> [  0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [  0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [  0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [  0.019014] (2:ponger@Jupiter)  Ping time (latency bound) 0.019014
+> [  0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
+> [150.178356] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [150.178356] (1:pinger@Tremblay) Pong time (bandwidth bound): 150.159
+> [150.178356] (0:maestro@) Total simulation time: 150.178