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)
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
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));
}
/*
* 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);
#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)
*/
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;
XBT_PUBLIC(int) MSG_get_channel_number(void);
#endif
-#include "instr/instr.h"
-
/** @brief Opaque type describing a Virtual Machine.
* @ingroup msg_VMs
*
* 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);
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"
+
/* ****************************************************************************************** */
#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"
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;
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);
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) {
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);
int TRACE_needs_platform (void)
{
return TRACE_msg_process_is_enabled() ||
+ TRACE_msg_vm_is_enabled() ||
TRACE_categorized() ||
TRACE_uncategorized() ||
TRACE_platform () ||
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();
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,
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;
* 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.
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;
}
INSTR_ROUTER,
INSTR_AS,
INSTR_SMPI,
+ INSTR_MSG_VM,
INSTR_MSG_PROCESS,
INSTR_MSG_TASK
} e_container_types;
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;
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);
--- /dev/null
+/* 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 */
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;
msg_host_t location;
int coreAmount;
} s_msg_vm_t;
-
+*/
/************************** Global variables ********************************/
typedef struct MSG_Global {
xbt_fifo_t host;
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
* 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.
}
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;
}
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.
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.
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
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);
}
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);
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)
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);
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;
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){
#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);
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);
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);
#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);
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;
}
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;
*/
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 */