Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move this first C example to the example directory + cosmetics in outputs
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Feb 2020 09:34:22 +0000 (10:34 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Feb 2020 09:34:22 +0000 (10:34 +0100)
examples/c/CMakeLists.txt [moved from teshsuite/c/CMakeLists.txt with 67% similarity]
examples/c/async-waitany/async-waitany.c [moved from teshsuite/c/async-waitany/async-waitany.c with 92% similarity]
examples/c/async-waitany/async-waitany.tesh [moved from teshsuite/c/async-waitany/async-waitany.tesh with 100% similarity]
examples/c/async-waitany/async-waitany_d.xml [moved from teshsuite/c/async-waitany/async-waitany_d.xml with 100% similarity]
examples/s4u/async-wait/s4u-async-wait.cpp
examples/s4u/async-wait/s4u-async-wait.tesh
examples/s4u/async-waitall/s4u-async-waitall.cpp
examples/s4u/async-waitany/s4u-async-waitany.cpp
tools/cmake/DefinePackages.cmake

similarity index 67%
rename from teshsuite/c/CMakeLists.txt
rename to examples/c/CMakeLists.txt
index 29e6483..0b073d1 100644 (file)
@@ -12,8 +12,8 @@ set(teshsuite_src ${teshsuite_src}  PARENT_SCOPE)
 set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml    PARENT_SCOPE)
 
 foreach(x async-waitany)
-  ADD_TESH(tesh-c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
-                       --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/c/${x}
-                       --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/c/${x}
-                       ${CMAKE_HOME_DIRECTORY}/teshsuite/c/${x}/${x}.tesh)
+  ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+                  --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x}
+                  --cd ${CMAKE_HOME_DIRECTORY}/examples/c/${x}
+                  ${CMAKE_HOME_DIRECTORY}/examples/c/${x}/${x}.tesh)
 endforeach()
similarity index 92%
rename from teshsuite/c/async-waitany/async-waitany.c
rename to examples/c/async-waitany/async-waitany.c
index d1b2d21..cff2764 100644 (file)
@@ -31,7 +31,7 @@ static int sender(int argc, char* argv[])
   sg_mailbox_t* mboxes = malloc(sizeof(sg_mailbox_t) * receivers_count);
   for (long i = 0; i < receivers_count; i++) {
     char mailbox_name[80];
-    snprintf(mailbox_name, 79, "receiver-%ld", (i));
+    snprintf(mailbox_name, 79, "receiver-%ld", i);
     sg_mailbox_t mbox = sg_mailbox_by_name(mailbox_name);
     mboxes[i]         = mbox;
   }
@@ -39,20 +39,19 @@ static int sender(int argc, char* argv[])
   /* Start dispatching all messages to receivers, in a round robin fashion */
   for (int i = 0; i < messages_count; i++) {
     char msg_content[80];
-    snprintf(msg_content, 79, "Message_%d", i);
+    snprintf(msg_content, 79, "Message %d", i);
     sg_mailbox_t mbox = mboxes[i % receivers_count];
     XBT_INFO("Send '%s' to '%s'", msg_content, sg_mailbox_get_name(mbox));
 
-    sg_comm_t comm                       = sg_mailbox_put_async(mbox, xbt_strdup(msg_content), msg_size);
-    pending_comms[pending_comms_count++] = comm;
+    /* Create a communication representing the ongoing communication, and store it in pending_comms */
+    pending_comms[pending_comms_count++] = sg_mailbox_put_async(mbox, xbt_strdup(msg_content), msg_size);
   }
   /* Start sending messages to let the workers know that they should stop */
   for (int i = 0; i < receivers_count; i++) {
     XBT_INFO("Send 'finalize' to 'receiver-%d'", i);
     char* end_msg                        = xbt_strdup("finalize");
     sg_mailbox_t mbox                    = mboxes[i % receivers_count];
-    sg_comm_t comm                       = sg_mailbox_put_async(mbox, end_msg, 0);
-    pending_comms[pending_comms_count++] = comm;
+    pending_comms[pending_comms_count++] = sg_mailbox_put_async(mbox, end_msg, 0);
   }
 
   XBT_INFO("Done dispatching all messages");
index 24a3e2b..8dec966 100644 (file)
@@ -36,8 +36,8 @@ static int sender(int argc, char** argv)
   /* Start dispatching all messages to receivers, in a round robin fashion */
   for (int i = 0; i < messages_count; i++) {
     std::string msg_content = std::string("Message ") + std::to_string(i);
-    // Copy the data we send: 'msg_content' is not a stable storage location.
-    // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
+    // Copy the data we send: the 'msg_content' variable is not a stable storage location.
+    // It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
     std::string* payload = new std::string(msg_content);
 
     XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
index dcdaac0..93edebf 100644 (file)
@@ -13,4 +13,4 @@ $ ${bindir:=.}/s4u-async-wait ${platfdir}/small_platform_fatpipe.xml s4u-async-w
 > [  0.210917] (2:receiver@Ruby) I got a 'Message 1'.
 > [  0.316375] (2:receiver@Ruby) I got a 'Message 2'.
 > [  0.318326] (2:receiver@Ruby) I got a 'finalize'.
-> [  0.318326] (1:sender@Tremblay) Goodbye now!
\ No newline at end of file
+> [  0.318326] (1:sender@Tremblay) Goodbye now!
index 14d53cc..da09d44 100644 (file)
@@ -47,7 +47,7 @@ public:
     /* Start dispatching all messages to receivers, in a round robin fashion */
     for (int i = 0; i < messages_count; i++) {
       std::string msg_content = std::string("Message ") + std::to_string(i);
-      // Copy the data we send: 'msg_content' is not a stable storage location.
+      // Copy the data we send: the 'msg_content' variable is not a stable storage location.
       // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
       std::string* payload = new std::string(msg_content);
 
index dba580e..293deec 100644 (file)
@@ -50,7 +50,7 @@ public:
     /* Start dispatching all messages to receivers, in a round robin fashion */
     for (int i = 0; i < messages_count; i++) {
       std::string msg_content = std::string("Message ") + std::to_string(i);
-      // Copy the data we send: 'msg_content' is not a stable storage location.
+      // Copy the data we send: the 'msg_content' variable is not a stable storage location.
       // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
       std::string* payload = new std::string(msg_content);
 
index 0a1c3b4..b5f5345 100644 (file)
@@ -1003,6 +1003,7 @@ set(txt_files
 # The list of cmake build directories is constructed from the following list.
 # Add your CMakeLists file here to see your subdir built.
 set(CMAKEFILES_TXT
+  examples/c/CMakeLists.txt
   examples/s4u/CMakeLists.txt
   examples/smpi/CMakeLists.txt
   examples/smpi/NAS/CMakeLists.txt
@@ -1015,7 +1016,6 @@ set(CMAKEFILES_TXT
   examples/deprecated/msg/mc/CMakeLists.txt
   examples/deprecated/simdag/CMakeLists.txt
 
-  teshsuite/c/CMakeLists.txt
   teshsuite/java/CMakeLists.txt
   teshsuite/lua/CMakeLists.txt
   teshsuite/mc/CMakeLists.txt