From 0c2a4890b8024abfe6d12928faad593f1e6eddbf Mon Sep 17 00:00:00 2001 From: schnorr Date: Thu, 7 Jun 2012 17:30:21 +0200 Subject: [PATCH] [trace] paje file format has evolved with a new event PajeResetState, follow it --- include/instr/instr.h | 1 + src/instr/instr_interface.c | 23 +++++++++++++++--- src/instr/instr_paje_trace.c | 47 ++++++++++++++++++++++++++++++++++++ src/instr/instr_private.h | 1 + 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/include/instr/instr.h b/include/instr/instr.h index ccd354e94e..cefa4356de 100644 --- a/include/instr/instr.h +++ b/include/instr/instr.h @@ -74,6 +74,7 @@ XBT_PUBLIC(void) TRACE_host_state_declare_value (const char *state, const char * XBT_PUBLIC(void) TRACE_host_set_state (const char *host, const char *state, const char *value); XBT_PUBLIC(void) TRACE_host_push_state (const char *host, const char *state, const char *value); XBT_PUBLIC(void) TRACE_host_pop_state (const char *host, const char *state); +XBT_PUBLIC(void) TRACE_host_reset_state (const char *host, const char *state); /* for creating graph configuration files for Triva by hand */ XBT_PUBLIC(xbt_dynar_t) TRACE_get_node_types (void); diff --git a/src/instr/instr_interface.c b/src/instr/instr_interface.c index 26daa66622..de4e65f69a 100644 --- a/src/instr/instr_interface.c +++ b/src/instr/instr_interface.c @@ -829,7 +829,7 @@ void TRACE_host_state_declare_value (const char *state, const char *value, const * \param state The name of the state previously declared. * \param value The new value of the state. * - * \see TRACE_host_state_declare, TRACE_host_push_state, TRACE_host_pop_state + * \see TRACE_host_state_declare, TRACE_host_push_state, TRACE_host_pop_state, TRACE_host_reset_state */ void TRACE_host_set_state (const char *host, const char *state, const char *value) { @@ -852,7 +852,7 @@ void TRACE_host_set_state (const char *host, const char *state, const char *valu * \param state The name of the state previously declared. * \param value The value to be pushed. * - * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_pop_state + * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_pop_state, TRACE_host_reset_state */ void TRACE_host_push_state (const char *host, const char *state, const char *value) { @@ -874,7 +874,7 @@ void TRACE_host_push_state (const char *host, const char *state, const char *val * \param host The name of the host to be considered. * \param state The name of the state to be popped. * - * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_push_state + * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_push_state, TRACE_host_reset_state */ void TRACE_host_pop_state (const char *host, const char *state) { @@ -883,6 +883,23 @@ void TRACE_host_pop_state (const char *host, const char *state) new_pajePopState(MSG_get_clock(), container, type); } +/** \ingroup TRACE_user_variables + * \brief Reset the state of a given host. + * + * Clear all previous values of a user state. + * + * \param host The name of the host to be considered. + * \param state The name of the state to be cleared. + * + * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_push_state, TRACE_host_pop_state + */ +void TRACE_host_reset_state (const char *host, const char *state) +{ + container_t container = PJ_container_get(host); + type_t type = PJ_type_get (state, container->type); + new_pajeResetState(MSG_get_clock(), container, type); +} + /** \ingroup TRACE_API * \brief Get Paje container types that can be mapped to the nodes of a graph. * diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.c index 916e18a8c2..df1b98f411 100644 --- a/src/instr/instr_paje_trace.c +++ b/src/instr/instr_paje_trace.c @@ -25,6 +25,7 @@ typedef enum { PAJE_SetState, PAJE_PushState, PAJE_PopState, + PAJE_ResetState, PAJE_StartLink, PAJE_EndLink, PAJE_NewEvent @@ -122,6 +123,12 @@ typedef struct s_popState { type_t type; }s_popState_t; +typedef struct s_resetState *resetState_t; +typedef struct s_resetState { + container_t container; + type_t type; +}s_resetState_t; + typedef struct s_startLink *startLink_t; typedef struct s_startLink { container_t container; @@ -291,6 +298,11 @@ void TRACE_paje_create_header(void) %% Type string \n\ %% Container string \n\ %%EndEventDef\n\ +%%EventDef PajeResetState %d \n\ +%% Time date \n\ +%% Type string \n\ +%% Container string \n\ +%%EndEventDef\n\ %%EventDef PajeStartLink %d \n\ %% Time date \n\ %% Type string \n\ @@ -327,6 +339,7 @@ void TRACE_paje_create_header(void) PAJE_SetState, PAJE_PushState, PAJE_PopState, + PAJE_ResetState, PAJE_StartLink, PAJE_EndLink, PAJE_NewEvent); @@ -572,6 +585,23 @@ static void print_pajePopState(paje_event_t event) } } +static void print_pajeResetState(paje_event_t event) +{ + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + if (event->timestamp == 0){ + fprintf(tracing_file, "%d 0 %s %s\n", + (int)event->event_type, + ((resetState_t)event->data)->type->id, + ((resetState_t)event->data)->container->id); + }else{ + fprintf(tracing_file, "%d %lf %s %s\n", + (int)event->event_type, + event->timestamp, + ((resetState_t)event->data)->type->id, + ((resetState_t)event->data)->container->id); + } +} + static void print_pajeStartLink(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); @@ -898,6 +928,23 @@ void new_pajePopState (double timestamp, container_t container, type_t type) insert_into_buffer (event); } + +void new_pajeResetState (double timestamp, container_t container, type_t type) +{ + paje_event_t event = xbt_new0(s_paje_event_t, 1); + event->event_type = PAJE_ResetState; + event->timestamp = timestamp; + event->print = print_pajeResetState; + event->free = free_paje_event; + event->data = xbt_new0(s_resetState_t, 1); + ((resetState_t)(event->data))->type = type; + ((resetState_t)(event->data))->container = container; + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + + insert_into_buffer (event); +} + void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key) { paje_event_t event = xbt_new0(s_paje_event_t, 1); diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index c11427f96e..0bc4f9d2a8 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -98,6 +98,7 @@ void new_pajeSubVariable (double timestamp, container_t container, type_t type, void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value); void new_pajePushState (double timestamp, container_t container, type_t type, val_t value); void new_pajePopState (double timestamp, container_t container, type_t type); +void new_pajeResetState (double timestamp, container_t container, type_t type); void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key); void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, const char *value, const char *key); void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value); -- 2.20.1