Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more legacy MSG functions
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 6 May 2018 14:20:31 +0000 (16:20 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 6 May 2018 14:20:31 +0000 (16:20 +0200)
include/simgrid/actor.h
include/simgrid/engine.h [new file with mode: 0644]
include/simgrid/msg.h
src/msg/msg_deployment.cpp [deleted file]
src/msg/msg_environment.cpp [deleted file]
src/msg/msg_global.cpp
src/msg/msg_legacy.cpp
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Engine.cpp
tools/cmake/DefinePackages.cmake

index ebbc070..0e72156 100644 (file)
@@ -1,5 +1,3 @@
-/* Public interface to the Link datatype                                    */
-
 /* Copyright (c) 2018. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -22,7 +20,6 @@ SG_BEGIN_DECL()
     You should not access directly to the fields of the pointed structure, but always use the provided API to interact
     with actors.
  */
-
 XBT_PUBLIC int sg_actor_get_PID(sg_actor_t actor);
 XBT_PUBLIC int sg_actor_get_PPID(sg_actor_t actor);
 XBT_PUBLIC sg_actor_t sg_actor_by_PID(aid_t pid);
@@ -38,7 +35,9 @@ XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
 XBT_PUBLIC void sg_actor_migrate(sg_actor_t process, sg_host_t host);
 XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
 XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_kill_all();
 XBT_PUBLIC void sg_actor_set_kill_time(sg_actor_t actor, double kill_time);
+XBT_PUBLIC void sg_actor_yield();
 SG_END_DECL()
 
 #endif /* INCLUDE_SIMGRID_ACTOR_H_ */
diff --git a/include/simgrid/engine.h b/include/simgrid/engine.h
new file mode 100644 (file)
index 0000000..3908e45
--- /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_ENGINE_H_
+#define INCLUDE_SIMGRID_ENGINE_H_
+
+#include <simgrid/forward.h>
+
+/* C interface */
+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_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();
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_ENGINE_H_ */
index 1ea45bf..173a1de 100644 (file)
@@ -7,6 +7,7 @@
 #define SIMGRID_MSG_H
 
 #include <simgrid/actor.h>
+#include <simgrid/engine.h>
 #include <simgrid/forward.h>
 #include <simgrid/host.h>
 #include <simgrid/instr.h>
@@ -143,7 +144,9 @@ XBT_PUBLIC void MSG_process_daemonize(msg_process_t process);
 XBT_PUBLIC void MSG_process_migrate(msg_process_t process, msg_host_t host);
 XBT_PUBLIC void MSG_process_join(msg_process_t process, double timeout);
 XBT_PUBLIC void MSG_process_kill(msg_process_t process);
+XBT_PUBLIC void MSG_process_killall();
 XBT_PUBLIC void MSG_process_set_kill_time(msg_process_t process, double kill_time);
+XBT_PUBLIC void MSG_process_yield();
 
 /* ******************************** File ************************************ */
 typedef sg_file_t msg_file_t;
@@ -241,9 +244,6 @@ XBT_PUBLIC msg_process_t MSG_process_create_with_environment(const char* name, x
 XBT_PUBLIC msg_process_t MSG_process_attach(const char* name, void* data, msg_host_t host, xbt_dict_t properties);
 XBT_PUBLIC void MSG_process_detach();
 
-XBT_PUBLIC int MSG_process_killall();
-XBT_PUBLIC void MSG_process_yield();
-
 XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
 XBT_PUBLIC int MSG_process_self_PID();
 XBT_PUBLIC int MSG_process_self_PPID();
diff --git a/src/msg/msg_deployment.cpp b/src/msg/msg_deployment.cpp
deleted file mode 100644 (file)
index 8382a62..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (c) 2004-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 "src/msg/msg_private.hpp"
-
-/** \ingroup msg_simulation
- * \brief An application deployer.
- *
- * Creates the process described in \a file.
- * \param file a filename of a xml description of the application. This file follows this DTD :
- *
- *     \include simgrid.dtd
- *
- * Here is a small example of such a platform
- *
- *     \include msg/masterslave/deployment_masterslave.xml
- *
- * Have a look in the directory examples/msg/ to have a bigger example.
- */
-void MSG_launch_application(const char *file)
-{
-  xbt_assert(msg_global, "MSG_init has to be called before MSG_launch_application.");
-  SIMIX_launch_application(file);
-}
-
-/** \ingroup msg_simulation
- * \brief Registers the main function of a process in a global table.
- *
- * Registers a code function in a global table.
- * This table is then used by #MSG_launch_application.
- * \param name the reference name of the function.
- * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
- */
-void MSG_function_register(const char *name, xbt_main_func_t code)
-{
-  SIMIX_function_register(name, code);
-}
-
-/** \ingroup msg_simulation
- * \brief Registers a function as the default main function of processes.
- *
- * Registers a code function as being the default value. This function will get used by MSG_launch_application() when there is no registered function of the requested name in.
- * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
- */
-void MSG_function_register_default(xbt_main_func_t code)
-{
-  SIMIX_function_register_default(code);
-}
-
-/**
- * \brief register functions bypassing the parser
- */
-
-void MSG_set_function(const char *host_id, const char *function_name, xbt_dynar_t arguments)
-{
-  SIMIX_process_set_function(host_id, function_name, arguments, -1, -1);
-}
diff --git a/src/msg/msg_environment.cpp b/src/msg/msg_environment.cpp
deleted file mode 100644 (file)
index 5bdf7ae..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (c) 2004-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/msg.h"
-
-#if SIMGRID_HAVE_LUA
-#include <lua.h>
-#include <lauxlib.h>
-#include <lualib.h>
-#endif
-
-/********************************* MSG **************************************/
-
-/** \ingroup msg_simulation
- * \brief A platform constructor.
- *
- * Creates a new platform, including hosts, links and the routing_table.
- * \param file a filename of a xml description of a platform. This file follows this DTD :
- *
- *     \include simgrid.dtd
- *
- * Here is a small example of such a platform
- *
- *     \include small_platform.xml
- *
- * Have a look in the directory examples/msg/ to have a big example.
- */
-void MSG_create_environment(const char *file)
-{
-  SIMIX_create_environment(file);
-}
index cf4cda0..c90d181 100644 (file)
@@ -3,7 +3,6 @@
 /* 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/Actor.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 
@@ -86,16 +85,6 @@ void MSG_config(const char *key, const char *value){
   simgrid::config::set_as_string(key, value);
 }
 
-/** \ingroup msg_simulation
- * \brief Kill all running process
-
- */
-int MSG_process_killall()
-{
-  simgrid::s4u::Actor::kill_all();
-  return 0;
-}
-
 static void MSG_exit() {
   if (msg_global==nullptr)
     return;
@@ -104,15 +93,13 @@ static void MSG_exit() {
   msg_global = nullptr;
 }
 
-/** \ingroup msg_simulation
- * \brief A clock (in second).
- */
-double MSG_get_clock()
+unsigned long int MSG_get_sent_msg()
 {
-  return SIMIX_get_clock();
+  return msg_global->sent_msg;
 }
 
-unsigned long int MSG_get_sent_msg()
+/** \brief register functions bypassing the parser */
+void MSG_set_function(const char* host_id, const char* function_name, xbt_dynar_t arguments)
 {
-  return msg_global->sent_msg;
+  SIMIX_process_set_function(host_id, function_name, arguments, -1, -1);
 }
index 304dab0..c3a28cb 100644 (file)
@@ -7,6 +7,28 @@
 
 #define MSG_CALL(type, oldname, args)
 
+/* ************************** Engine *************************** */
+void MSG_create_environment(const char* filename)
+{
+  sg_engine_load_platform(filename);
+}
+
+void MSG_launch_application(const char* filename)
+{
+  sg_engine_load_deployment(filename);
+}
+void MSG_function_register(const char* name, xbt_main_func_t code)
+{
+  sg_engine_register_function(name, code);
+}
+void MSG_function_register_default(xbt_main_func_t code)
+{
+  sg_engine_register_default(code);
+}
+double MSG_get_clock()
+{
+  return sg_engine_get_clock();
+}
 /* ************************** Actors *************************** */
 int MSG_process_get_PID(sg_actor_t actor)
 {
@@ -68,11 +90,18 @@ void MSG_process_kill(sg_actor_t actor)
 {
   sg_actor_kill(actor);
 }
-
+void MSG_process_kill_all()
+{
+  sg_actor_kill_all();
+}
 void MSG_process_set_kill_time(sg_actor_t actor, double kill_time)
 {
   sg_actor_set_kill_time(actor, kill_time);
 }
+void MSG_process_yield()
+{
+  sg_actor_yield();
+}
 
 /* ************************** NetZones *************************** */
 sg_netzone_t MSG_zone_get_root()
index bbadeab..3a82a9a 100644 (file)
@@ -196,12 +196,6 @@ void MSG_process_detach()
   SIMIX_process_detach();
 }
 
-/** Yield the current actor; let the other actors execute first */
-void MSG_process_yield()
-{
-  simgrid::simix::kernelImmediate([] { /* do nothing*/ });
-}
-
 /** \ingroup m_process_management
  * \brief Returns the user data of a process.
  *
index b342ac4..e67eaa1 100644 (file)
@@ -570,6 +570,11 @@ void sg_actor_kill(sg_actor_t actor)
   actor->kill();
 }
 
+void sg_actor_kill_all()
+{
+  simgrid::s4u::Actor::kill_all();
+}
+
 /** \ingroup m_actor_management
  * \brief Set the kill time of an actor.
  *
@@ -580,3 +585,9 @@ void sg_actor_set_kill_time(sg_actor_t actor, double kill_time)
 {
   actor->set_kill_time(kill_time);
 }
+
+/** Yield the current actor; let the other actors execute first */
+void sg_actor_yield()
+{
+  simgrid::s4u::this_actor::yield();
+}
index 1263f11..9bcbae9 100644 (file)
@@ -260,3 +260,27 @@ void Engine::set_config(std::string str)
 }
 } // namespace s4u
 } // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+void sg_engine_load_platform(const char* file)
+{
+  simgrid::s4u::Engine::get_instance()->load_platform(file);
+}
+
+void sg_engine_load_deployment(const char* file)
+{
+  simgrid::s4u::Engine::get_instance()->load_deployment(file);
+}
+
+void sg_engine_register_function(const char* name, int (*code)(int, char**))
+{
+  simgrid::s4u::Engine::get_instance()->register_function(name, code);
+}
+void sg_engine_register_default(int (*code)(int, char**))
+{
+  simgrid::s4u::Engine::get_instance()->register_default(code);
+}
+double sg_engine_get_clock()
+{
+  return simgrid::s4u::Engine::get_clock();
+}
index ba4852d..981ba71 100644 (file)
@@ -442,8 +442,6 @@ set(SIMGRID_SRC
 set(MSG_SRC
   src/msg/instr_msg_process.cpp
   src/msg/instr_msg_task.cpp
-  src/msg/msg_deployment.cpp
-  src/msg/msg_environment.cpp
   src/msg/msg_global.cpp
   src/msg/msg_gos.cpp
   src/msg/msg_legacy.cpp
@@ -662,6 +660,7 @@ set(MC_SIMGRID_MC_SRC  src/mc/checker/simgrid_mc.cpp)
 set(headers_to_install
 
   include/simgrid/actor.h
+  include/simgrid/engine.h
   include/simgrid/chrono.hpp
   include/simgrid/plugins/dvfs.h
   include/simgrid/plugins/energy.h