Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more legacy MSG functions
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 19 Jun 2018 08:30:36 +0000 (10:30 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 19 Jun 2018 08:30:36 +0000 (10:30 +0200)
12 files changed:
ChangeLog
include/simgrid/engine.h
include/simgrid/mailbox.h [new file with mode: 0644]
include/simgrid/msg.h
src/bindings/java/jmsg_host.cpp
src/msg/msg_global.cpp
src/msg/msg_gos.cpp
src/msg/msg_legacy.cpp
src/msg/msg_mailbox.cpp [deleted file]
src/s4u/s4u_Engine.cpp
src/s4u/s4u_Mailbox.cpp
tools/cmake/DefinePackages.cmake

index e747902..884042c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@ TRACE
  - Change --cfg=tracing/msg/vm to --cfg=tracing/vm as virtual machine
    behavior tracing is no longer limited to MSG
 
+MSG
+ - The deprecation of MSG is ongoing. A lot of functions are now simple
+   wrappers on the C API of S4U. All these wrappers (and their S4U counterparts
+   can be found in src/msg/msg_legacy.cpp).
+
 S4U:
  - Introduced new function simgrid::s4u::Host::get_actor_count. This function
    returns the number of actors running on a specific host.
index 3908e45..e355a9d 100644 (file)
@@ -12,6 +12,7 @@
 SG_BEGIN_DECL()
 XBT_PUBLIC void sg_engine_load_platform(const char* filename);
 XBT_PUBLIC void sg_engine_load_deployment(const char* filename);
+XBT_PUBLIC void sg_engine_run();
 XBT_PUBLIC void sg_engine_register_function(const char* name, int (*code)(int, char**));
 XBT_PUBLIC void sg_engine_register_default(int (*code)(int, char**));
 XBT_PUBLIC double sg_engine_get_clock();
diff --git a/include/simgrid/mailbox.h b/include/simgrid/mailbox.h
new file mode 100644 (file)
index 0000000..6e91ff0
--- /dev/null
@@ -0,0 +1,20 @@
+/* Copyright (c) 2018. 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. */
+
+#ifndef INCLUDE_SIMGRID_MAILBOX_H_
+#define INCLUDE_SIMGRID_MAILBOX_H_
+
+#include <simgrid/forward.h>
+#include <xbt/base.h>
+
+/* C interface */
+SG_BEGIN_DECL()
+
+void sg_mailbox_set_receiver(const char* alias);
+int sg_mailbox_listen(const char* alias);
+
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_MAILBOX_H_ */
index c22f433..b562b47 100644 (file)
@@ -11,6 +11,7 @@
 #include <simgrid/forward.h>
 #include <simgrid/host.h>
 #include <simgrid/instr.h>
+#include <simgrid/mailbox.h>
 #include <simgrid/plugins/live_migration.h>
 #include <simgrid/storage.h>
 #include <simgrid/vm.h>
index 166b570..7076f7a 100644 (file)
@@ -326,7 +326,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setAsyncMailbox(JNIEnv * env, jclass cls_arg, jobject jname)
 {
   const char *name = env->GetStringUTFChars((jstring) jname, 0);
-  MSG_mailbox_set_async(name);
+  sg_mailbox_set_receiver(name);
   env->ReleaseStringUTFChars((jstring) jname, name);
 }
 
index cab13d9..e6dd156 100644 (file)
@@ -55,23 +55,6 @@ void MSG_init_nocheck(int *argc, char **argv) {
     atexit(MSG_exit);
 }
 
-/** \ingroup msg_simulation
- * \brief Launch the MSG simulation
- */
-msg_error_t MSG_main()
-{
-  /* Clean IO before the run */
-  fflush(stdout);
-  fflush(stderr);
-
-  if (MC_is_active()) {
-    MC_run();
-  } else {
-    SIMIX_run();
-  }
-  return MSG_OK;
-}
-
 /** \ingroup msg_simulation
  * \brief set a configuration variable
  *
index dfc6ca9..e9f5b1c 100644 (file)
@@ -849,19 +849,6 @@ msg_error_t MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alia
   return MSG_task_send_with_timeout(task, alias, timeout);
 }
 
-/** \ingroup msg_task_usage
- * \brief Check if there is a communication going on in a mailbox.
- *
- * \param alias the name of the mailbox to be considered
- *
- * \return Returns 1 if there is a communication, 0 otherwise
- */
-int MSG_task_listen(const char *alias)
-{
-  simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(alias);
-  return mbox->listen() ? 1 : 0;
-}
-
 /** \ingroup msg_task_usage
  * \brief Look if there is a communication on a mailbox and return the PID of the sender process.
  *
index 43ac177..bb1148f 100644 (file)
@@ -17,6 +17,11 @@ void MSG_launch_application(const char* filename)
 {
   sg_engine_load_deployment(filename);
 }
+msg_error_t MSG_main()
+{
+  sg_engine_run();
+  return MSG_OK;
+}
 void MSG_function_register(const char* name, xbt_main_func_t code)
 {
   sg_engine_register_function(name, code);
@@ -29,6 +34,17 @@ double MSG_get_clock()
 {
   return sg_engine_get_clock();
 }
+
+/* ************************** Mailboxes ************************ */
+void MSG_mailbox_set_async(const char* alias)
+{
+  sg_mailbox_set_receiver(alias);
+}
+int MSG_task_listen(const char* alias)
+{
+  return sg_mailbox_listen(alias);
+}
+
 /* ************************** Actors *************************** */
 int MSG_process_get_PID(sg_actor_t actor)
 {
diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp
deleted file mode 100644 (file)
index 12bb632..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Mailboxes in MSG */
-
-/* Copyright (c) 2008-2018. 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/Mailbox.hpp"
-#include "src/msg/msg_private.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_mailbox, msg, "Logging specific to MSG (mailbox)");
-
-/** \ingroup msg_mailbox_management
- * \brief Set the mailbox to receive in asynchronous mode
- *
- * All messages sent to this mailbox will be transferred to the receiver without waiting for the receive call.
- * The receive call will still be necessary to use the received data.
- * If there is a need to receive some messages asynchronously, and some not, two different mailboxes should be used.
- *
- * \param alias The name of the mailbox
- */
-void MSG_mailbox_set_async(const char *alias){
-  simgrid::s4u::Mailbox::by_name(alias)->set_receiver(simgrid::s4u::Actor::self());
-  XBT_VERB("%s mailbox set to receive eagerly for myself\n",alias);
-}
index ac01c07..330b7ea 100644 (file)
@@ -249,6 +249,10 @@ std::vector<ActorPtr> Engine::get_filtered_actors(std::function<bool(ActorPtr)>
 
 void Engine::run()
 {
+  /* Clean IO before the run */
+  fflush(stdout);
+  fflush(stderr);
+
   if (MC_is_active()) {
     MC_run();
   } else {
@@ -346,7 +350,10 @@ void sg_engine_load_deployment(const char* file)
 {
   simgrid::s4u::Engine::get_instance()->load_deployment(file);
 }
-
+void sg_engine_run()
+{
+  simgrid::s4u::Engine::get_instance()->run();
+}
 void sg_engine_register_function(const char* name, int (*code)(int, char**))
 {
   simgrid::s4u::Engine::get_instance()->register_function(name, code);
index a294219..7c3841e 100644 (file)
@@ -145,3 +145,28 @@ void* Mailbox::get(double timeout)
 }
 } // namespace s4u
 } // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+/** \brief Set the mailbox to receive in asynchronous mode
+ *
+ * All messages sent to this mailbox will be transferred to the receiver without waiting for the receive call.
+ * The receive call will still be necessary to use the received data.
+ * If there is a need to receive some messages asynchronously, and some not, two different mailboxes should be used.
+ *
+ * \param alias The name of the mailbox
+ */
+void sg_mailbox_set_receiver(const char* alias)
+{
+  simgrid::s4u::Mailbox::by_name(alias)->set_receiver(simgrid::s4u::Actor::self());
+  XBT_VERB("%s mailbox set to receive eagerly for myself\n", alias);
+}
+
+/** \brief Check if there is a communication going on in a mailbox.
+ *
+ * \param alias the name of the mailbox to be considered
+ * \return Returns 1 if there is a communication, 0 otherwise
+ */
+int sg_mailbox_listen(const char* alias)
+{
+  return simgrid::s4u::Mailbox::by_name(alias)->listen() ? 1 : 0;
+}
index 0d0ed04..be8804d 100644 (file)
@@ -444,7 +444,6 @@ set(MSG_SRC
   src/msg/msg_global.cpp
   src/msg/msg_gos.cpp
   src/msg/msg_legacy.cpp
-  src/msg/msg_mailbox.cpp
   src/msg/msg_process.cpp
   src/msg/msg_synchro.cpp
   src/msg/msg_task.cpp
@@ -670,6 +669,7 @@ set(headers_to_install
   include/simgrid/plugins/load_balancer.h
   include/simgrid/smpi/replay.hpp
   include/simgrid/instr.h
+  include/simgrid/mailbox.h
   include/simgrid/msg.h
   include/simgrid/simdag.h
   include/simgrid/modelchecker.h