Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into vmtrace
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 17 Jan 2013 13:03:10 +0000 (14:03 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 17 Jan 2013 13:03:10 +0000 (14:03 +0100)
Conflicts:
buildtools/Cmake/DefinePackages.cmake
include/surf/simgrid_dtd.h
include/xbt/graphxml.h
src/instr/instr_config.c
src/instr/instr_private.h
src/simdag/dax_dtd.c
src/simdag/dax_dtd.h
src/surf/simgrid_dtd.c
src/xbt/graphxml.c

16 files changed:
buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/DefinePackages.cmake
examples/msg/cloud/masterslave_virtual_machines.c
include/instr/instr.h
include/msg/datatypes.h
include/msg/msg.h
src/instr/instr_config.c
src/instr/instr_interface.c
src/instr/instr_paje_containers.c
src/instr/instr_private.h
src/msg/instr_msg_vm.c [new file with mode: 0644]
src/msg/msg_private.h
src/msg/msg_vm.c
src/surf/instr_routing.c
src/surf/surf_action.c
src/xbt/heap.c

index 2cb506e..abcd9c9 100644 (file)
@@ -156,10 +156,10 @@ else()
 endif()
 
 # Our usage of mmap is Linux-specific (flag MAP_ANONYMOUS), but kFreeBSD uses a GNU libc
-IF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND NOT "${CMAKE_SYSTEM}" MATCHES "GNU")
+IF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND NOT "${CMAKE_SYSTEM}" MATCHES "GNU" AND NOT  "${CMAKE_SYSTEM}" MATCHES "Darwin")
   SET(HAVE_MMAP 0)
   message(STATUS "Warning: MMAP is thought as non functional on this architecture (${CMAKE_SYSTEM})")
-ENDIF()
+ENDIF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND NOT "${CMAKE_SYSTEM}" MATCHES "GNU" AND NOT  "${CMAKE_SYSTEM}" MATCHES "Darwin")
 
 if(WIN32) #THOSE FILES ARE FUNCTIONS ARE NOT DETECTED BUT THEY SHOULD...
   set(HAVE_UCONTEXT_H 1)
index cf125c0..56fd828 100644 (file)
@@ -241,6 +241,7 @@ set(SIMGRID_SRC
 set(MSG_SRC
   src/msg/instr_msg_process.c
   src/msg/instr_msg_task.c
+  src/msg/instr_msg_vm.c
   src/msg/msg_actions.c
   src/msg/msg_deployment.c
   src/msg/msg_environment.c
index bfbc81f..8f2780e 100644 (file)
@@ -63,7 +63,11 @@ int master(int argc, char *argv[]) {
     argv[0] = xbt_strdup(slavename);
     argv[1] = bprintf("%d",i);
     argv[2] = NULL;
-    msg_vm_t vm = MSG_vm_start(slaves[i],2);
+
+    char vmName[64];
+    snprintf(vmName, 64, "vm_%d", i);
+
+    msg_vm_t vm = MSG_vm_start(slaves[i],vmName,2);
     MSG_vm_bind(vm, MSG_process_create_with_arguments(slavename,slave_fun,NULL,slaves[i],2,argv));
   }
 
index 08bcd93..3ff225e 100644 (file)
@@ -42,6 +42,18 @@ XBT_PUBLIC(int) TRACE_platform_graph_export_graphviz (const char *filename);
 /*
  * User-variables related functions
  */
+/* for VM variables */
+XBT_PUBLIC(void) TRACE_vm_variable_declare (const char *variable);
+XBT_PUBLIC(void) TRACE_vm_variable_declare_with_color (const char *variable, const char *color);
+XBT_PUBLIC(void) TRACE_vm_variable_set (const char *vm, const char *variable, double value);
+XBT_PUBLIC(void) TRACE_vm_variable_add (const char *vm, const char *variable, double value);
+XBT_PUBLIC(void) TRACE_vm_variable_sub (const char *vm, const char *variable, double value);
+XBT_PUBLIC(void) TRACE_vm_variable_set_with_time (double time, const char *vm, const char *variable, double value);
+XBT_PUBLIC(void) TRACE_vm_variable_add_with_time (double time, const char *vm, const char *variable, double value);
+XBT_PUBLIC(void) TRACE_vm_variable_sub_with_time (double time, const char *vm, const char *variable, double value);
+XBT_PUBLIC(xbt_dynar_t) TRACE_get_vm_variables (void);
+
+
 /* for host variables */
 XBT_PUBLIC(void) TRACE_host_variable_declare (const char *variable);
 XBT_PUBLIC(void) TRACE_host_variable_declare_with_color (const char *variable, const char *color);
@@ -98,6 +110,16 @@ XBT_PUBLIC(void) TRACE_resume (void);
 
 #define TRACE_platform_graph_export_graphviz(filename)
 
+#define TRACE_vm_variable_declare(var)
+#define TRACE_vm_variable_declare_with_color(var,color)
+#define TRACE_vm_variable_set(vm,var,value)
+#define TRACE_vm_variable_add(vm,var,value)
+#define TRACE_vm_variable_sub(vm,var,value)
+#define TRACE_vm_variable_set_with_time(time,vm,var,value)
+#define TRACE_vm_variable_add_with_time(time,vm,var,value)
+#define TRACE_vm_variable_sub_with_time(time,vm,var,value)
+#define TRACE_get_vm_variables()
+
 #define TRACE_host_variable_declare(var)
 #define TRACE_host_variable_declare_with_color(var,color)
 #define TRACE_host_variable_set(host,var,value)
index 598ea84..cedd660 100644 (file)
@@ -72,6 +72,22 @@ typedef struct msg_task {
  */
 typedef struct msg_task *msg_task_t;
 
+/* ********************************  VM ************************************* */
+typedef struct msg_vm *msg_vm_t;
+
+typedef enum {
+  msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
+} e_msg_vm_state_t;
+
+typedef struct msg_vm {
+  const char *name;
+  s_xbt_swag_hookup_t all_vms_hookup;
+  s_xbt_swag_hookup_t host_vms_hookup;
+  xbt_dynar_t processes;
+  e_msg_vm_state_t state;
+  msg_host_t location;
+  int coreAmount;
+} s_msg_vm_t;
 
 /* ******************************** File ************************************ */
 typedef struct simdata_file *simdata_file_t;
index 5d993b0..afac0e9 100644 (file)
@@ -324,8 +324,6 @@ XBT_PUBLIC(msg_error_t) MSG_set_channel_number(int number);
 XBT_PUBLIC(int) MSG_get_channel_number(void);
 #endif
 
-#include "instr/instr.h"
-
 /** @brief Opaque type describing a Virtual Machine.
  *  @ingroup msg_VMs
  *
@@ -334,9 +332,8 @@ XBT_PUBLIC(int) MSG_get_channel_number(void);
  * Usual lack of guaranty of any kind applies here, and is even increased.
  *
  */
-typedef struct msg_vm *msg_vm_t;
 /* This function should not be called directly, but rather from MSG_vm_start_from_template that does not exist yet*/
-XBT_PUBLIC(msg_vm_t) MSG_vm_start(msg_host_t location, int coreAmount);
+XBT_PUBLIC(msg_vm_t) MSG_vm_start(msg_host_t location, const char *name, int coreAmount);
 
 XBT_PUBLIC(int) MSG_vm_is_suspended(msg_vm_t);
 XBT_PUBLIC(int) MSG_vm_is_running(msg_vm_t);
@@ -379,6 +376,8 @@ xbt_dynar_t<msg_vm_t> MSG_vm_get_list_from_host(msg_host_t)
 xbt_dynar_t<msg_vm_t> MSG_vm_get_list_from_hosts(msg_dynar_t<msg_host_t>)
 + des fonctions de filtrage sur les dynar
 */
+#include "instr/instr.h"
+
 
 
 /* ****************************************************************************************** */
index 3797373..3737cf7 100644 (file)
@@ -22,6 +22,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration");
 #define OPT_TRACING_CATEGORIZED   "tracing/categorized"
 #define OPT_TRACING_UNCATEGORIZED "tracing/uncategorized"
 #define OPT_TRACING_MSG_PROCESS   "tracing/msg/process"
+#define OPT_TRACING_MSG_VM        "tracing/msg/vm"
 #define OPT_TRACING_FILENAME      "tracing/filename"
 #define OPT_TRACING_BUFFER        "tracing/buffer"
 #define OPT_TRACING_ONELINK_ONLY  "tracing/onelink_only"
@@ -41,6 +42,7 @@ static int trace_smpi_computing;
 static int trace_categorized;
 static int trace_uncategorized;
 static int trace_msg_process_enabled;
+static int trace_msg_vm_enabled;
 static int trace_buffer;
 static int trace_onelink_only;
 static int trace_disable_destroy;
@@ -62,6 +64,7 @@ static void TRACE_getopts(void)
   trace_categorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_CATEGORIZED);
   trace_uncategorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_UNCATEGORIZED);
   trace_msg_process_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_PROCESS);
+  trace_msg_vm_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_VM);
   trace_buffer = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BUFFER);
   trace_onelink_only = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_ONELINK_ONLY);
   trace_disable_destroy = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY);
@@ -100,6 +103,7 @@ int TRACE_start()
     created_categories = xbt_dict_new_homogeneous(xbt_free);
     declared_marks = xbt_dict_new_homogeneous(xbt_free);
     user_host_variables = xbt_dict_new_homogeneous(xbt_free);
+    user_vm_variables = xbt_dict_new_homogeneous (xbt_free);
     user_link_variables = xbt_dict_new_homogeneous(xbt_free);
 
     if (TRACE_start_functions != NULL) {
@@ -153,6 +157,7 @@ int TRACE_end()
 
     xbt_dict_free(&user_link_variables);
     xbt_dict_free(&user_host_variables);
+    xbt_dict_free(&user_vm_variables);
     xbt_dict_free(&declared_marks);
     xbt_dict_free(&created_categories);
 
@@ -171,6 +176,7 @@ int TRACE_end()
 int TRACE_needs_platform (void)
 {
   return TRACE_msg_process_is_enabled() ||
+         TRACE_msg_vm_is_enabled() ||
          TRACE_categorized() ||
          TRACE_uncategorized() ||
          TRACE_platform () ||
@@ -229,6 +235,12 @@ int TRACE_msg_process_is_enabled(void)
   return trace_msg_process_enabled && TRACE_is_enabled();
 }
 
+int TRACE_msg_vm_is_enabled(void)
+{
+  return trace_msg_vm_enabled && TRACE_is_enabled();
+}
+
+
 int TRACE_buffer (void)
 {
   return trace_buffer && TRACE_is_enabled();
@@ -346,6 +358,13 @@ void TRACE_global_init(int *argc, char **argv)
                    xbt_cfgelm_int, &default_tracing_msg_process, 0, 1,
                    NULL, NULL);
 
+  /* msg process */
+  int default_tracing_msg_vm = 0;
+  xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_VM,
+                   "Tracing of MSG process behavior.",
+                   xbt_cfgelm_int, &default_tracing_msg_vm, 0, 1,
+                   NULL, NULL);
+
   /* tracing buffer */
   int default_buffer = 1;
   xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BUFFER,
index bd07bf9..3c06b95 100644 (file)
@@ -22,6 +22,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_api, instr, "API");
 xbt_dict_t created_categories = NULL;
 xbt_dict_t declared_marks = NULL;
 xbt_dict_t user_host_variables = NULL;
+xbt_dict_t user_vm_variables = NULL;
 xbt_dict_t user_link_variables = NULL;
 extern xbt_dict_t trivaNodeTypes;
 extern xbt_dict_t trivaEdgeTypes;
@@ -406,6 +407,166 @@ int TRACE_platform_graph_export_graphviz (const char *filename)
  * into functions so the user can track them using gdb.
  */
 
+/* for VM variables */
+/** \ingroup TRACE_user_variables
+ *  \brief Declare a new user variable associated to VMs.
+ *
+ *  Declare a user variable that will be associated to VMs.
+ *  A user vm variable can be used to trace user variables
+ *  such as the number of tasks in a VM, the number of
+ *  clients in an application (for VMs), and so on. The color
+ *  associated to this new variable will be random.
+ *
+ *  \param variable The name of the new variable to be declared.
+ *
+ *  \see TRACE_vm_variable_declare_with_color
+ */
+void TRACE_vm_variable_declare (const char *variable)
+{
+  instr_user_variable(0, NULL, variable, "MSG_VM", 0, INSTR_US_DECLARE, NULL, user_vm_variables);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Declare a new user variable associated to VMs with a color.
+ *
+ *  Same as #TRACE_vm_variable_declare, but associated a color
+ *  to the newly created user host variable. The color needs to be
+ *  a string with three numbers separated by spaces in the range [0,1].
+ *  A light-gray color can be specified using "0.7 0.7 0.7" as color.
+ *
+ *  \param variable The name of the new variable to be declared.
+ *  \param color The color for the new variable.
+ *
+ */
+void TRACE_vm_variable_declare_with_color (const char *variable, const char *color)
+{
+   instr_user_variable(0, NULL, variable, "MSG_VM", 0, INSTR_US_DECLARE, color, user_vm_variables);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Set the value of a variable of a host.
+ *
+ *  \param vm The name of the VM to be considered.
+ *  \param variable The name of the variable to be considered.
+ *  \param value The new value of the variable.
+ *
+ *  \see TRACE_vm_variable_declare, TRACE_vm_variable_add, TRACE_vm_variable_sub
+ */
+void TRACE_vm_variable_set (const char *vm, const char *variable, double value)
+{
+
+  TRACE_vm_variable_set_with_time (MSG_get_clock(), vm, variable, value);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Add a value to a variable of a VM.
+ *
+ *  \param vm The name of the VM to be considered.
+ *  \param variable The name of the variable to be considered.
+ *  \param value The value to be added to the variable.
+ *
+ *  \see TRACE_vm_variable_declare, TRACE_vm_variable_set, TRACE_vm_variable_sub
+ */
+void TRACE_vm_variable_add (const char *vm, const char *variable, double value)
+{
+  TRACE_vm_variable_add_with_time (MSG_get_clock(), vm, variable, value);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Subtract a value from a variable of a VM.
+ *
+ *  \param vm The name of the vm to be considered.
+ *  \param variable The name of the variable to be considered.
+ *  \param value The value to be subtracted from the variable.
+ *
+ *  \see TRACE_vm_variable_declare, TRACE_vm_variable_set, TRACE_vm_variable_add
+ */
+void TRACE_vm_variable_sub (const char *vm, const char *variable, double value)
+{
+  TRACE_vm_variable_sub_with_time (MSG_get_clock(), vm, variable, value);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Set the value of a variable of a VM at a given timestamp.
+ *
+ *  Same as #TRACE_vm_variable_set, but let user specify
+ *  the time used to trace it. Users can specify a time that
+ *  is not the simulated clock time as defined by the core
+ *  simulator. This allows a fine-grain control of time
+ *  definition, but should be used with caution since the trace
+ *  can be inconsistent if resource utilization traces are also traced.
+ *
+ *  \param time The timestamp to be used to tag this change of value.
+ *  \param vm The name of the VM to be considered.
+ *  \param variable The name of the variable to be considered.
+ *  \param value The new value of the variable.
+ *
+ *  \see TRACE_vm_variable_declare, TRACE_vm_variable_add_with_time, TRACE_vm_variable_sub_with_time
+ */
+void TRACE_vm_variable_set_with_time (double time, const char *vm, const char *variable, double value)
+{
+  instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_SET, NULL, user_vm_variables);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Add a value to a variable of a VM at a given timestamp.
+ *
+ *  Same as #TRACE_vm_variable_add, but let user specify
+ *  the time used to trace it. Users can specify a time that
+ *  is not the simulated clock time as defined by the core
+ *  simulator. This allows a fine-grain control of time
+ *  definition, but should be used with caution since the trace
+ *  can be inconsistent if resource utilization traces are also traced.
+ *
+ *  \param time The timestamp to be used to tag this change of value.
+ *  \param vm The name of the VM to be considered.
+ *  \param variable The name of the variable to be considered.
+ *  \param value The value to be added to the variable.
+ *
+ *  \see TRACE_vm_variable_declare, TRACE_vm_variable_set_with_time, TRACE_vm_variable_sub_with_time
+ */
+void TRACE_vm_variable_add_with_time (double time, const char *vm, const char *variable, double value)
+{
+  instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_ADD, NULL, user_vm_variables);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Subtract a value from a variable of a VM at a given timestamp.
+ *
+ *  Same as #TRACE_vm_variable_sub, but let user specify
+ *  the time used to trace it. Users can specify a time that
+ *  is not the simulated clock time as defined by the core
+ *  simulator. This allows a fine-grain control of time
+ *  definition, but should be used with caution since the trace
+ *  can be inconsistent if resource utilization traces are also traced.
+ *
+ *  \param time The timestamp to be used to tag this change of value.
+ *  \param vm The name of the VM to be considered.
+ *  \param variable The name of the variable to be considered.
+ *  \param value The value to be subtracted from the variable.
+ *
+ *  \see TRACE_vm_variable_declare, TRACE_vm_variable_set_with_time, TRACE_vm_variable_add_with_time
+ */
+void TRACE_vm_variable_sub_with_time (double time, const char *vm, const char *variable, double value)
+{
+  instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_SUB, NULL, user_vm_variables);
+}
+
+/** \ingroup TRACE_user_variables
+ *  \brief Get declared user vm variables
+ *
+ * This function should be used to get VM variables that were already
+ * declared with #TRACE_vm_variable_declare or with #TRACE_vm_variable_declare_with_color.
+ *
+ * \return A dynar with the declared host variables, must be freed with xbt_dynar_free.
+ */
+xbt_dynar_t TRACE_get_vm_variables (void)
+{
+  return instr_dict_to_dynar (user_vm_variables);
+}
+
+
+
 /* for host variables */
 /** \ingroup TRACE_user_variables
  *  \brief Declare a new user variable associated to hosts.
index 64590e9..6846474 100644 (file)
@@ -107,6 +107,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe
       case INSTR_ROUTER:      snprintf (typename, INSTR_DEFAULT_STR_SIZE, "ROUTER");      break;
       case INSTR_SMPI:        snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MPI");         break;
       case INSTR_MSG_PROCESS: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break;
+      case INSTR_MSG_VM: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_VM"); break;
       case INSTR_MSG_TASK:    snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK");    break;
       default: THROWF (tracing_error, 0, "new container kind is unknown."); break;
     }
index 9729978..ea02f0a 100644 (file)
@@ -78,6 +78,7 @@ typedef enum {
   INSTR_ROUTER,
   INSTR_AS,
   INSTR_SMPI,
+  INSTR_MSG_VM,
   INSTR_MSG_PROCESS,
   INSTR_MSG_TASK
 } e_container_types;
@@ -97,6 +98,7 @@ typedef struct s_container {
 extern xbt_dict_t created_categories;
 extern xbt_dict_t declared_marks;
 extern xbt_dict_t user_host_variables;
+extern xbt_dict_t user_vm_variables;
 extern xbt_dict_t user_link_variables;
 extern double TRACE_last_timestamp_to_dump;
 
@@ -141,6 +143,7 @@ int TRACE_smpi_is_computing(void);
 int TRACE_categorized (void);
 int TRACE_uncategorized (void);
 int TRACE_msg_process_is_enabled(void);
+int TRACE_msg_vm_is_enabled(void);
 int TRACE_buffer (void);
 int TRACE_onelink_only (void);
 int TRACE_disable_destroy (void);
diff --git a/src/msg/instr_msg_vm.c b/src/msg/instr_msg_vm.c
new file mode 100644 (file)
index 0000000..73581c5
--- /dev/null
@@ -0,0 +1,144 @@
+/* Copyright (c) 2012. 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 "msg_private.h"
+
+#ifdef HAVE_TRACING
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_vm, instr, "MSG VM");
+
+
+char *instr_vm_id (msg_vm_t vm, char *str, int len)
+{
+  return instr_vm_id_2 (vm->name, str, len);
+}
+
+char *instr_vm_id_2 (const char *vm_name, char *str, int len)
+{
+  snprintf (str, len, "%s", vm_name);
+  return str;
+}
+
+/*
+ * Instrumentation functions to trace MSG VMs (msg_vm_t)
+ */
+void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, msg_host_t new_host)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    static long long int counter = 0;
+    char key[INSTR_DEFAULT_STR_SIZE];
+    snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
+
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    //start link
+    container_t msg = PJ_container_get (instr_vm_id(vm, str, len));
+    type_t type = PJ_type_get ("MSG_VM_LINK", PJ_type_get_root());
+    new_pajeStartLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+
+    //destroy existing container of this vm
+    container_t existing_container = PJ_container_get(instr_vm_id(vm, str, len));
+    PJ_container_remove_from_parent (existing_container);
+    PJ_container_free(existing_container);
+
+    //create new container on the new_host location
+    msg = PJ_container_new(instr_vm_id(vm, str, len), INSTR_MSG_VM, PJ_container_get(SIMIX_host_get_name(new_host->smx_host)));
+
+    //end link
+    msg = PJ_container_get(instr_vm_id(vm, str, len));
+    type = PJ_type_get ("MSG_VM_LINK", PJ_type_get_root());
+    new_pajeEndLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+  }
+}
+
+void TRACE_msg_vm_create (const char *vm_name, msg_host_t host)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    container_t host_container = PJ_container_get (SIMIX_host_get_name(host->smx_host));
+    PJ_container_new(instr_vm_id_2(vm_name, str, len), INSTR_MSG_VM, host_container);
+  }
+}
+
+void TRACE_msg_vm_kill(msg_vm_t vm) {
+  if (TRACE_msg_vm_is_enabled()) {
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    //kill means that this vm no longer exists, let's destroy it
+    container_t process = PJ_container_get (instr_vm_id(vm, str, len));
+    PJ_container_remove_from_parent (process);
+    PJ_container_free (process);
+  }
+}
+
+void TRACE_msg_vm_suspend(msg_vm_t vm)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len));
+    type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type);
+    val_t value = PJ_value_get ("suspend", type);
+    new_pajePushState (MSG_get_clock(), vm_container, type, value);
+  }
+}
+
+void TRACE_msg_vm_resume(msg_vm_t vm)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len));
+    type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type);
+    new_pajePopState (MSG_get_clock(), vm_container, type);
+  }
+}
+
+void TRACE_msg_vm_sleep_in(msg_vm_t vm)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len));
+    type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type);
+    val_t value = PJ_value_get ("sleep", type);
+    new_pajePushState (MSG_get_clock(), vm_container, type, value);
+  }
+}
+
+void TRACE_msg_vm_sleep_out(msg_vm_t vm)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len));
+    type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type);
+    new_pajePopState (MSG_get_clock(), vm_container, type);
+  }
+}
+
+void TRACE_msg_vm_end(msg_vm_t vm)
+{
+  if (TRACE_msg_vm_is_enabled()) {
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    //that's the end, let's destroy it
+    container_t container = PJ_container_get (instr_vm_id(vm, str, len));
+    PJ_container_remove_from_parent (container);
+    PJ_container_free (container);
+  }
+}
+
+#endif /* HAVE_TRACING */
index 6899c15..7edcb02 100644 (file)
@@ -91,12 +91,13 @@ typedef struct msg_comm {
   msg_task_t *task_received;      /* where the task will be received (NULL for the sender) */
   msg_error_t status;           /* status of the communication once finished */
 } s_msg_comm_t;
-
+/*
 typedef enum {
   msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
 } e_msg_vm_state_t;
 
 typedef struct msg_vm {
+  const char *name;
   s_xbt_swag_hookup_t all_vms_hookup;
   s_xbt_swag_hookup_t host_vms_hookup;
   xbt_dynar_t processes;
@@ -104,7 +105,7 @@ typedef struct msg_vm {
   msg_host_t location;
   int coreAmount;
 } s_msg_vm_t;
-
+*/
 /************************** Global variables ********************************/
 typedef struct MSG_Global {
   xbt_fifo_t host;
@@ -180,5 +181,18 @@ void TRACE_msg_process_sleep_in(msg_process_t process);   //called from msg/gos.
 void TRACE_msg_process_sleep_out(msg_process_t process);
 void TRACE_msg_process_end(msg_process_t process);
 
+/* declaration of instrumentation functions from instr_msg_vm.c */
+char *instr_vm_id (msg_vm_t vm, char *str, int len);
+char *instr_vm_id_2 (const char *vm_name, char *str, int len);
+void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host,
+                                   msg_host_t new_host);
+void TRACE_msg_vm_create (const char *vm_name, msg_host_t host);
+void TRACE_msg_vm_kill(msg_vm_t process);
+void TRACE_msg_vm_suspend(msg_vm_t vm);
+void TRACE_msg_vm_resume(msg_vm_t vm);
+void TRACE_msg_vm_sleep_in(msg_vm_t vm);
+void TRACE_msg_vm_sleep_out(msg_vm_t vm);
+void TRACE_msg_vm_end(msg_vm_t vm);
+
 SG_END_DECL()
 #endif
index 4e06196..426bbb7 100644 (file)
@@ -17,18 +17,24 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_vm, msg,
  *  to add extra constraints on the execution, but the argument is ignored for now.
  */
 
-msg_vm_t MSG_vm_start(msg_host_t location, int coreAmount) {
+msg_vm_t MSG_vm_start(msg_host_t location, const char *name, int coreAmount) {
   msg_vm_t res = xbt_new0(s_msg_vm_t,1);
   res->all_vms_hookup.prev = NULL;
   res->host_vms_hookup.prev = NULL;
   res->state = msg_vm_state_running;
   res->location = location;
   res->coreAmount = coreAmount;
+  res->name = xbt_strdup(name);
   res->processes = xbt_dynar_new(sizeof(msg_process_t),NULL);
 
   xbt_swag_insert(res,msg_global->vms);
   xbt_swag_insert(res,location->vms);
 
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_create(name, location);
+  #endif
+
+
   return res;
 }
 /** @brief Returns a newly constructed dynar containing all existing VMs in the system.
@@ -107,6 +113,11 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t destination) {
   }
   xbt_swag_remove(vm,vm->location->vms);
   xbt_swag_insert_at_tail(vm,destination->vms);
+  
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_change_host(vm,vm->location,destination);
+  #endif
+
   vm->location = destination;
 }
 
@@ -124,6 +135,10 @@ void MSG_vm_suspend(msg_vm_t vm) {
     XBT_DEBUG("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
     MSG_process_suspend(process);
   }
+
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_suspend(vm);
+  #endif
 }
 
 /** @brief Immediately resumes the execution of all processes within the given VM.
@@ -140,6 +155,10 @@ void MSG_vm_resume(msg_vm_t vm) {
     XBT_DEBUG("resume process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
     MSG_process_resume(process);
   }
+
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_resume(vm);
+  #endif
 }
 
 /** @brief Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.
@@ -156,6 +175,11 @@ void MSG_vm_shutdown(msg_vm_t vm)
     process = xbt_dynar_get_as(vm->processes,0,msg_process_t);
     MSG_process_kill(process);
   }
+
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_kill(vm);
+  #endif
+
 }
 /**
  * \ingroup msg_VMs
@@ -191,6 +215,12 @@ void MSG_vm_destroy(msg_vm_t vm) {
     simdata_process_t simdata = simcall_process_get_data(process);
     simdata->vm = NULL;
   }
+
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_end(vm);
+  #endif
+
+
   xbt_dynar_free(&vm->processes);
   xbt_free(vm);
 }
index 0b4b84d..c5fc212 100644 (file)
@@ -165,10 +165,15 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
   container_t child1, child2;
   const char *child1_name, *child2_name;
   xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
-    if (graph_extraction_filter_out (child1, NULL)) continue;
+    //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
+    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
+
     xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
-      if (graph_extraction_filter_out (child2, child1)) continue;
-      XBT_DEBUG ("get_route from %s to %s", child1_name, child2_name);
+      //if child2 is not a link, a smpi node, a msg process, a msg vm or a msg task
+      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
+
+      //if child1 is not child2
+      if (strcmp (child1_name, child2_name) == 0) continue;
 
       //get the route
       sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
@@ -346,6 +351,22 @@ static void instr_routing_parse_start_host (sg_platf_host_cbarg_t host)
       PJ_type_link_new ("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
     }
   }
+
+  if (TRACE_msg_vm_is_enabled()) {
+    type_t msg_vm = PJ_type_get_or_null ("MSG_VM", new->type);
+    if (msg_vm == NULL){
+      msg_vm = PJ_type_container_new("MSG_VM", new->type);
+      type_t state = PJ_type_state_new ("MSG_VM_STATE", msg_vm);
+      PJ_value_new ("suspend", "1 0 1", state);
+      PJ_value_new ("sleep", "1 1 0", state);
+      PJ_value_new ("receive", "1 0 0", state);
+      PJ_value_new ("send", "0 0 1", state);
+      PJ_value_new ("task_execute", "0 1 1", state);
+      PJ_type_link_new ("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm);
+      PJ_type_link_new ("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm);
+    }
+  }
+
 }
 
 static void instr_routing_parse_start_router (sg_platf_router_cbarg_t router)
@@ -392,7 +413,12 @@ static void recursiveNewVariableType (const char *new_typename, const char *colo
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
     PJ_type_variable_new (tnstr, color, root);
   }
-  if (!strcmp (root->name, "LINK")){
+  if (!strcmp (root->name, "MSG_VM")){
+    char tnstr[INSTR_DEFAULT_STR_SIZE];
+    snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
+    PJ_type_variable_new (tnstr, color, root);
+  }
+ if (!strcmp (root->name, "LINK")){
     char tnstr[INSTR_DEFAULT_STR_SIZE];
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
     PJ_type_variable_new (tnstr, color, root);
@@ -526,12 +552,12 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
   container_t child1, child2;
   const char *child1_name, *child2_name;
   xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
-    //if child1 is not a link, a smpi node, a msg process or a msg task
-    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_TASK) continue;
+    //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
+    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
 
     xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
       //if child2 is not a link, a smpi node, a msg process or a msg task
-      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_TASK) continue;
+      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
 
       //if child1 is not child2
       if (strcmp (child1_name, child2_name) == 0) continue;
index e05e199..59e775f 100644 (file)
@@ -374,8 +374,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
   while ((xbt_heap_size(model->model_private->action_heap) > 0)
          && (double_equals(xbt_heap_maxkey(model->model_private->action_heap), now))) {
     action = xbt_heap_pop(model->model_private->action_heap);
-    XBT_DEBUG("Action %p: finish", action);
-    action->generic_action.finish = surf_get_clock();
+    XBT_DEBUG("Something happened to action %p", action);
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
       if(model == surf_cpu_model){
@@ -411,6 +410,9 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
 #endif
 
     if(model == surf_cpu_model){
+      action->generic_action.finish = surf_get_clock();
+      XBT_DEBUG("Action %p finished", action);
+
       /* set the remains to 0 due to precision problems when updating the remaining amount */
       action->generic_action.remains = 0;
       surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
@@ -419,6 +421,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
     else{
       // if I am wearing a latency hat
       if (action->hat == LATENCY) {
+        XBT_DEBUG("Latency paid for action %p. Activating", action);
         lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
             ((surf_action_network_CM02_t)(action))->weight);
         surf_action_lmm_heap_remove(model->model_private->action_heap,action);
@@ -429,7 +432,9 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
           action->hat == NORMAL) {
         // no need to communicate anymore
         // assume that flows that reached max_duration have remaining of 0
-        action->generic_action.remains = 0;
+       action->generic_action.finish = surf_get_clock();
+       XBT_DEBUG("Action %p finished", action);
+       action->generic_action.remains = 0;
         ((surf_action_t)action)->finish = surf_get_clock();
         model->action_state_set((surf_action_t) action,
                                              SURF_ACTION_DONE);
index e124aab..c795b76 100644 (file)
@@ -11,6 +11,7 @@
 #include "heap_private.h"
 
 #include <stdio.h>
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_heap, xbt, "Heap");
 
 static void xbt_heap_max_heapify(xbt_heap_t H);
 static void xbt_heap_increase_key(xbt_heap_t H, int i);
@@ -103,6 +104,7 @@ void xbt_heap_push(xbt_heap_t H, void *content, double key)
   item->key = key;
   item->content = content;
   xbt_heap_increase_key(H, count - 1);
+  XBT_DEBUG("Heap has now %d elements and max elem is %g",xbt_heap_size(H),xbt_heap_maxkey(H));
   return;
 }
 
@@ -121,6 +123,8 @@ void *xbt_heap_pop(xbt_heap_t H)
   int size = H->size;
   void *max;
 
+  XBT_DEBUG("Heap has %d elements before extraction and max elem was %g",xbt_heap_size(H),xbt_heap_maxkey(H));
+
   if (H->count == 0)
     return NULL;
 
@@ -152,6 +156,8 @@ void *xbt_heap_pop(xbt_heap_t H)
  */
 void *xbt_heap_remove(xbt_heap_t H, int i)
 {
+  XBT_DEBUG("Heap has %d elements: extracting element %d",xbt_heap_size(H),i);
+
   if ((i < 0) || (i > H->count - 1))
     return NULL;
   /* put element i at head */