From 0b434542d7de83f5e040e7c03d5e98cd9c9f5d8a Mon Sep 17 00:00:00 2001 From: Takishipp Date: Fri, 21 Apr 2017 16:00:20 +0200 Subject: [PATCH] hierarchical OOP tree --- src/instr/instr_TI_trace.cpp | 23 +- src/instr/instr_interface.cpp | 17 +- src/instr/instr_paje_containers.cpp | 4 +- src/instr/instr_paje_trace.cpp | 280 +++++++------- src/instr/instr_paje_types.cpp | 16 +- src/instr/instr_paje_values.cpp | 2 +- src/instr/instr_private.h | 199 +++++----- src/instr/instr_resource_utilization.cpp | 8 +- src/instr/instr_trace.cpp | 443 +++++++++-------------- 9 files changed, 457 insertions(+), 535 deletions(-) diff --git a/src/instr/instr_TI_trace.cpp b/src/instr/instr_TI_trace.cpp index 161e5532e0..45e9e870c8 100644 --- a/src/instr/instr_TI_trace.cpp +++ b/src/instr/instr_TI_trace.cpp @@ -70,7 +70,8 @@ void print_TICreateContainer(paje_event_t event) if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) { char *folder_name = bprintf("%s_files", TRACE_get_filename()); - char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name); + char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, + static_cast(event)->container->name); #ifdef WIN32 _mkdir(folder_name); #else @@ -84,16 +85,16 @@ void print_TICreateContainer(paje_event_t event) xbt_free(filename); } - xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr); + xbt_dict_set(tracing_files, ((CreateContainerEvent*) event)->container->name, (void *) temp, nullptr); } void print_TIDestroyContainer(paje_event_t event) { if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) { - FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((destroyContainer_t) event->data)->container->name); + FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((DestroyContainerEvent *) event)->container->name); fclose(f); } - xbt_dict_remove(tracing_files, ((destroyContainer_t) event->data)->container->name); + xbt_dict_remove(tracing_files, ((DestroyContainerEvent*) event)->container->name); } void print_TIPushState(paje_event_t event) @@ -101,18 +102,18 @@ void print_TIPushState(paje_event_t event) int i; //char* function=nullptr; - if (((pushState_t) event->data)->extra == nullptr) + if (((PushStateEvent*) event->data)->extra == nullptr) return; - instr_extra_data extra = (instr_extra_data) (((pushState_t) event->data)->extra); + instr_extra_data extra = (instr_extra_data) (((PushStateEvent*) event->data)->extra); char *process_id = nullptr; //FIXME: dirty extract "rank-" from the name, as we want the bare process id here - if (strstr(((pushState_t) event->data)->container->name, "rank-") == nullptr) - process_id = xbt_strdup(((pushState_t) event->data)->container->name); + if (strstr(((PushStateEvent*) event->data)->container->name, "rank-") == nullptr) + process_id = xbt_strdup(((PushStateEvent*) event->data)->container->name); else - process_id = xbt_strdup(((pushState_t) event->data)->container->name + 5); + process_id = xbt_strdup(((PushStateEvent*) event->data)->container->name + 5); - FILE* trace_file = (FILE* )xbt_dict_get(tracing_files, ((pushState_t) event->data)->container->name); + FILE* trace_file = (FILE* )xbt_dict_get(tracing_files, ((PushStateEvent*) event)->container->name); switch (extra->type) { case TRACING_INIT: @@ -215,7 +216,7 @@ void print_TIPushState(paje_event_t event) case TRACING_ISSEND: default: XBT_WARN ("Call from %s impossible to translate into replay command : Not implemented (yet)", - ((pushState_t) event->data)->value->name); + ((PushStateEvent*) event->data)->value->name); break; } diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index d1881f7516..a3b3b87ac4 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -249,7 +249,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value) val_t value = PJ_value_get (mark_value, type); XBT_DEBUG("MARK %s %s", mark_type, mark_value); - new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value); + NewEvent (MSG_get_clock(), PJ_container_get_root(), type, value); } /** \ingroup TRACE_mark @@ -284,19 +284,18 @@ static void instr_user_variable(double time, const char *resource, const char *v }else{ if (created) { // declared, let's work char valuestr[100]; - s_subVariable n; snprintf(valuestr, 100, "%g", value); container_t container = PJ_container_get(resource); type_t type = PJ_type_get (variable, container->type); switch (what){ case INSTR_US_SET: - new_pajeSetVariable(time, container, type, value); + SetVariableEvent(time, container, type, value); break; case INSTR_US_ADD: - new_pajeAddVariable(time, container, type, value); + AddVariableEvent(time, container, type, value); break; case INSTR_US_SUB: - n.new_pajeSubVariable(time, container, type, value); + SubVariableEvent(time, container, type, value); break; default: THROW_IMPOSSIBLE; @@ -965,7 +964,7 @@ void TRACE_host_set_state (const char *host, const char *state, const char *valu container_t container = PJ_container_get(host); type_t type = PJ_type_get (state, container->type); val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ - new_pajeSetState(MSG_get_clock(), container, type, val); + SetStateEvent(MSG_get_clock(), container, type, val); } /** \ingroup TRACE_user_variables @@ -984,7 +983,7 @@ void TRACE_host_push_state (const char *host, const char *state, const char *val container_t container = PJ_container_get(host); type_t type = PJ_type_get (state, container->type); val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ - new_pajePushState(MSG_get_clock(), container, type, val); + PushStateEvent(MSG_get_clock(), container, type, val); } /** \ingroup TRACE_user_variables @@ -1001,7 +1000,7 @@ void TRACE_host_pop_state (const char *host, const char *state) { container_t container = PJ_container_get(host); type_t type = PJ_type_get (state, container->type); - new_pajePopState(MSG_get_clock(), container, type); + PopStateEvent(MSG_get_clock(), container, type); } /** \ingroup TRACE_user_variables @@ -1018,7 +1017,7 @@ 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); + ResetStateEvent(MSG_get_clock(), container, type); } /** \ingroup TRACE_API diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 87edfbe8e0..c0ad9ff80e 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -144,7 +144,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe newContainer->children = xbt_dict_new_homogeneous(nullptr); if (newContainer->father){ xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, nullptr); - new_pajeCreateContainer (newContainer); + new CreateContainerEvent(newContainer); } //register all kinds by name @@ -212,7 +212,7 @@ void PJ_container_free (container_t container) if (!TRACE_disable_destroy() && container != PJ_container_get_root()){ //do not trace the container destruction if user requests //or if the container is root - new_pajeDestroyContainer(container); + new DestroyContainerEvent(container); } //remove it from allContainers data structure diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 7573537fc2..ec32afcecc 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -22,7 +22,7 @@ static void print_paje_debug(std::string functionName, paje_event_t event) { event->timestamp); } -template static void init_stream(paje_event_t event) { +static void init_stream(paje_event_t event) { stream << std::fixed << std::setprecision(TRACE_precision()); stream << (int) event->event_type; } @@ -43,40 +43,9 @@ static void print_timestamp(paje_event_t event) { stream << event->timestamp; } -template static void print_default_pajeLink_row(paje_event_t& event) { - init_stream(event); - print_timestamp(event); - stream << " " << static_cast(event->data)->type->id - << " " << static_cast(event->data)->container->id - << " " << static_cast(event->data)->value; -} - -template static void print_default_pajeState_row(paje_event_t& event) { - init_stream(event); - print_timestamp(event); - stream << " " << static_cast(event->data)->type->id - << " " << static_cast(event->data)->container->id; -} - -template static void print_default_pajeType_row(paje_event_t& event) { - init_stream(event); - stream << " " << static_cast(event->data)->type->id - << " " << static_cast(event->data)->type->father->id - << " " << static_cast(event->data)->type->name; -} - -template static void print_default_pajeVariable_row(paje_event_t& event) { - init_stream(event); - print_timestamp(event); - stream << " " << static_cast(event->data)->type->id - << " " << static_cast(event->data)->container->id - << " " << static_cast(event->data)->value; - - print_row(); -} - void TRACE_paje_init() { - active_writer.print_DefineContainerType = &print_pajeDefineContainerType; + /* + //active_writer.print_DefineContainerType = &print_pajeDefineContainerType; active_writer.print_DefineVariableType = &print_pajeDefineVariableType; active_writer.print_DefineStateType = &print_pajeDefineStateType; active_writer.print_DefineEventType = &print_pajeDefineEventType; @@ -94,6 +63,7 @@ void TRACE_paje_init() { active_writer.print_StartLink = &print_pajeStartLink; active_writer.print_EndLink = &print_pajeEndLink; active_writer.print_NewEvent = &print_pajeNewEvent; +*/ } void TRACE_paje_start() { @@ -132,114 +102,146 @@ void TRACE_paje_end() { XBT_DEBUG("Filename %s is closed", filename); } -void print_pajeDefineContainerType(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeType_row(event); +void DefineContainerEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + stream << " " << type->id + << " " << type->father->id + << " " << type->name; print_row(); } -void print_pajeDefineVariableType(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeType_row(event); - if(static_cast(event->data)->type->color) - stream << " \"" << static_cast(event->data)->type->color << "\""; +void DefineVariableTypeEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + stream << " " << type->id + << " " << type->father->id + << " " << type->name; + if (type->color) + stream << " \"" << type->color << "\""; print_row(); } -void print_pajeDefineStateType(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeType_row(event); +void DefineStateTypeEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + stream << " " << type->id + << " " << type->father->id + << " " << type->name; print_row(); } -void print_pajeDefineEventType(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeType_row(event); +void DefineEventTypeEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + stream << " " << type->id + << " " << type->father->id + << " " << type->name; print_row(); } -void print_pajeDefineLinkType(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - init_stream(event); - stream << " " << static_cast(event->data)->type->id - << " " << static_cast(event->data)->type->father->id - << " " << static_cast(event->data)->source->id - << " " << static_cast(event->data)->dest->id - << " " << static_cast(event->data)->type->name; +void DefineLinkTypeEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream (this); + stream << " " << type->id + << " " << type->father->id + << " " << source->id + << " " << dest->id + << " " << type->name; print_row(); } -void print_pajeDefineEntityValue (paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - init_stream(event); - stream << " " << static_cast(event->data)->value->id - << " " << static_cast(event->data)->value->father->id - << " " << static_cast(event->data)->value->name; - if(static_cast(event->data)->value->color) - stream << " \"" << static_cast(event->data)->value->color << "\""; +void DefineEntityValueEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + stream << " " << value->id + << " " << value->father->id + << " " << value->name; + if(value->color) + stream << " \"" << value->color << "\""; print_row(); } -void print_pajeCreateContainer(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - init_stream(event); - print_timestamp(event); - stream << " " << static_cast(event->data)->container->id - << " " << static_cast(event->data)->container->type->id - << " " << static_cast(event->data)->container->father->id - << " \"" << static_cast(event->data)->container->name << "\""; +void CreateContainerEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << container->id + << " " << container->type->id + << " " << container->father->id + << " \"" << container->name << "\""; print_row(); } -void print_pajeDestroyContainer(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - init_stream(event); - print_timestamp(event); - stream << " " << static_cast(event->data)->container->type->id - << " " << static_cast(event->data)->container->id; +void DestroyContainerEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << container->type->id + << " " << container->id; print_row(); } -void print_pajeSetVariable(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeVariable_row(event); +void SetVariableEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id + << " " << value; + print_row(); } -void print_pajeAddVariable(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeVariable_row(event); +void AddVariableEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id + << " " << value; + print_row(); } -void print_pajeSubVariable(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeVariable_row(event); +void SubVariableEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id + << " " << value; + print_row(); } -void print_pajeSetState(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - - print_default_pajeState_row(event); - stream << " " << static_cast(event->data)->value->id; +void SetStateEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id; + stream << " " <id; #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - stream << " \"" << static_cast(event->data)->filename - << "\" " << static_cast(event->data)->linenumber; + stream << " \"" << filename + << "\" " << linenumber; } #endif print_row(); } -void print_pajePushState(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeState_row(event); - stream << " " << static_cast(event->data)->value->id; +void PushStateEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id; + stream << " " <id; if (TRACE_display_sizes()) { stream << " "; - if (static_cast(event->data)->extra != nullptr) { - stream << static_cast(static_cast(event->data)->extra)->send_size; + if (extra != nullptr) { + stream << static_cast(extra)->send_size; } else { stream << 0; @@ -247,59 +249,73 @@ void print_pajePushState(paje_event_t event) { } #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - stream << " \"" << static_cast(event->data)->filename - << "\" " << static_cast(event->data)->linenumber; + stream << " \"" << filename + << "\" " << linenumber; } #endif print_row(); - if (static_cast(event->data)->extra != nullptr) { - if (static_cast(static_cast(event->data)->extra)->sendcounts != nullptr) - xbt_free(static_cast(static_cast(event->data)->extra)->sendcounts); - if (static_cast(static_cast(event->data)->extra)->recvcounts != nullptr) - xbt_free(static_cast(static_cast(event->data)->extra)->recvcounts); - xbt_free(static_cast(event->data)->extra); + if (extra != nullptr) { + if (static_cast(extra)->sendcounts != nullptr) + xbt_free(static_cast(extra)->sendcounts); + if (static_cast(extra)->recvcounts != nullptr) + xbt_free(static_cast(extra)->recvcounts); + xbt_free(extra); } } -void print_pajePopState(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeState_row(event); +void PopStateEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id; print_row(); } -void print_pajeResetState(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeState_row(event); +void ResetStateEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id; print_row(); } -void print_pajeStartLink(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeLink_row(event); - stream << " " << static_cast(event->data)->sourceContainer->id - << " " << static_cast(event->data)->key; +void StartLinkEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " <id + << " " <id + << " " <id + << " " << key; if (TRACE_display_sizes()) { - stream << " " << static_cast(event->data)->size; + stream << " " << size; } print_row(); } -void print_pajeEndLink(paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - print_default_pajeLink_row(event); - stream << " " << static_cast(event->data)->destContainer->id - << " " << static_cast(event->data)->key; +void EndLinkEvent::print() { + print_paje_debug(__FUNCTION__, this); + init_stream(this); + print_timestamp(this); + stream << " " <id + << " " <id + << " " <id + << " " << key; print_row(); } -void print_pajeNewEvent (paje_event_t event) { - print_paje_debug(__FUNCTION__, event); - init_stream(event); - print_timestamp(event); - stream << " " << static_cast(event->data)->type->id - << " " << static_cast(event->data)->container->id - << " " << static_cast(event->data)->value->id; +void NewEvent::print () { + print_paje_debug(__FUNCTION__, this); + init_stream (this); + print_timestamp(this); + stream << " " << type->id + << " " << container->id + << " " << value->id; print_row(); } diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 0135b7e309..12f6266d60 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -116,7 +116,7 @@ type_t PJ_type_get_or_null (const char *name, type_t father) } type_t PJ_type_container_new (const char *name, type_t father) -{ s_defineContainerType EltContainer; +{ if (name == nullptr){ THROWF (tracing_error, 0, "can't create a container type with a nullptr name"); } @@ -130,20 +130,20 @@ type_t PJ_type_container_new (const char *name, type_t father) if(father){ XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - EltContainer.Event(ret); + new DefineContainerEvent(ret); } return ret; } type_t PJ_type_event_new (const char *name, type_t father) -{ +{ if (name == nullptr){ THROWF (tracing_error, 0, "can't create an event type with a nullptr name"); } type_t ret = newType (name, name, nullptr, TYPE_EVENT, father); XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - new_pajeDefineEventType(ret); + new DefineEventTypeEvent(ret); return ret; } @@ -162,7 +162,7 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father) ret = newType (name, name, color, TYPE_VARIABLE, father); } XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - new_pajeDefineVariableType (ret); + new DefineVariableTypeEvent (ret); return ret; } @@ -179,7 +179,7 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t ret = newType (name, key, nullptr, TYPE_LINK, father); XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id, source->name, source->id, dest->name, dest->id); - new_pajeDefineLinkType(ret, source, dest); + DefineLinkTypeEvent(ret, source, dest); return ret; } @@ -193,6 +193,6 @@ type_t PJ_type_state_new (const char *name, type_t father) ret = newType (name, name, nullptr, TYPE_STATE, father); XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - new_pajeDefineStateType(ret); + new DefineStateTypeEvent(ret); return ret; -} +} \ No newline at end of file diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index 7d69e51f7b..d07eb6f12d 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -27,7 +27,7 @@ val_t PJ_value_new (const char *name, const char *color, type_t father) xbt_dict_set (father->values, name, ret, nullptr); XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name); - new_pajeDefineEntityValue(ret); + new DefineEntityValueEvent(ret); return ret; } diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 0ef19cb179..573f3f4c29 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -121,111 +121,126 @@ class paje_event { public: double timestamp; e_event_type event_type; - void (*print) (paje_event_t event); - void (*free) (paje_event_t event); + virtual void print(); void *data; - void Event(type_t type); + ~paje_event(); }; typedef paje_event s_paje_event_t; +class DefineContainerEvent : public paje_event +{ + public: + type_t type; + void print() override; + DefineContainerEvent(type_t); +}; //-------------------------------------------------- -class s_defineContainerType; -typedef s_defineContainerType *defineContainerType_t; -class s_defineContainerType: public paje_event + +//-------------------------------------------------- + +class DefineVariableTypeEvent : public paje_event { public: type_t type; + DefineVariableTypeEvent(type_t type); + void print() override; }; -typedef s_defineContainerType s_defineContainerType_t; //-------------------------------------------------- -typedef struct s_defineVariableType *defineVariableType_t; -typedef struct s_defineVariableType { +class DefineStateTypeEvent : public paje_event { type_t type; -}s_defineVariableType_t; - -typedef struct s_defineStateType *defineStateType_t; -typedef struct s_defineStateType { - type_t type; -}s_defineStateType_t; + public: + DefineStateTypeEvent(type_t type); + void print();// override; +}; -typedef struct s_defineEventType *defineEventType_t; -typedef struct s_defineEventType { +class DefineEventTypeEvent : public paje_event { type_t type; -}s_defineEventType_t; + public: + DefineEventTypeEvent(type_t type); + void print() override; +}; -typedef struct s_defineLinkType *defineLinkType_t; -typedef struct s_defineLinkType { +class DefineLinkTypeEvent : public paje_event { type_t type; type_t source; type_t dest; -}s_defineLinkType_t; + public: + DefineLinkTypeEvent(type_t type, type_t source, type_t dest); + void print() override; +}; -typedef struct s_defineEntityValue *defineEntityValue_t; -typedef struct s_defineEntityValue { +class DefineEntityValueEvent : public paje_event { val_t value; -}s_defineEntityValue_t; + public: + DefineEntityValueEvent (val_t type); + void print() override; +}; -typedef struct s_createContainer *createContainer_t; -typedef struct s_createContainer { +class CreateContainerEvent : public paje_event { + public: container_t container; -}s_createContainer_t; + explicit CreateContainerEvent (container_t container); + void print() override; +}; -typedef struct s_destroyContainer *destroyContainer_t; -typedef struct s_destroyContainer { +class DestroyContainerEvent : public paje_event { + public: container_t container; -}s_destroyContainer_t; + DestroyContainerEvent (container_t container); + void print() override; +}; + -typedef struct s_setVariable *setVariable_t; -typedef struct s_setVariable { +class SetVariableEvent : public paje_event { container_t container; type_t type; double value; -}s_setVariable_t; + public: + SetVariableEvent (double timestamp, container_t container, type_t type, double value); + void print() override; +}; -typedef struct s_addVariable *addVariable_t; -typedef struct s_addVariable { + +class AddVariableEvent:public paje_event { container_t container; type_t type; double value; -}s_addVariable_t; + public: + AddVariableEvent (double timestamp, container_t container, type_t type, double value); + void print() override; +}; //-------------------------------------------------- -class s_subVariable; -typedef s_subVariable *subVariable_t; -class s_subVariable { +class SubVariableEvent : public paje_event { public: container_t container; type_t type; - double value; - //methods - XBT_PUBLIC(void) new_pajeSubVariable (double timestamp, container_t container, type_t type, double value); + double value; + public: + SubVariableEvent(double timestamp, container_t container, type_t type, double value); + void print() override; }; -typedef s_subVariable s_subVariable_t; //-------------------------------------------------- -class s_setState; - -typedef s_setState *setState_t; -class s_setState { +class SetStateEvent : public paje_event { public: container_t container; type_t type; val_t value; const char* filename; int linenumber; + public: + SetStateEvent (double timestamp, container_t container, type_t type, val_t value); + void print() override; }; -typedef s_setState s_setState_t; -class s_pushState; - -typedef s_pushState *pushState_t; -class s_pushState { +class PushStateEvent : public paje_event { public: container_t container; type_t type; @@ -234,54 +249,69 @@ class s_pushState { const char* filename; int linenumber; void* extra; + public: + PushStateEvent (double timestamp, container_t container, type_t type, val_t value); + PushStateEvent (double timestamp, container_t container, type_t type, val_t value, + void* extra); + void print() override; }; -typedef s_pushState s_pushState_t; - -typedef struct s_popState *popState_t; -typedef struct s_popState { +class PopStateEvent : public paje_event { container_t container; type_t type; xbt_dynar_t extra; -}s_popState_t; + public: + PopStateEvent (double timestamp, container_t container, type_t type); + void print() override; +}; -typedef struct s_resetState *resetState_t; -typedef struct s_resetState { +class ResetStateEvent : public paje_event { container_t container; type_t type; -}s_resetState_t; + public: + ResetStateEvent (double timestamp, container_t container, type_t type); + void print() override; +}; -typedef struct s_startLink *startLink_t; -typedef struct s_startLink { +class StartLinkEvent : public paje_event { + public: container_t container; type_t type; container_t sourceContainer; char *value; char *key; int size; -}s_startLink_t; + public: + StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer, + const char *value, const char *key); + StartLinkEvent (double timestamp, container_t container, type_t type, + container_t sourceContainer, const char *value, const char *key, int size); + void print() override; +}; -typedef struct s_endLink *endLink_t; -typedef struct s_endLink { +class EndLinkEvent : public paje_event { container_t container; type_t type; container_t destContainer; char *value; char *key; -}s_endLink_t; - -class s_newEvent; + public: + EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer, + const char *value, const char *key); + void print() override; +}; -typedef s_newEvent *newEvent_t; -class s_newEvent { +class NewEvent : public paje_event { public: container_t container; type_t type; val_t value; + public: + NewEvent (double timestamp, container_t container, type_t type, val_t value); + void print() override; }; -typedef s_newEvent s_newEvent_t; extern XBT_PRIVATE xbt_dict_t created_categories; extern XBT_PRIVATE xbt_dict_t declared_marks; @@ -299,33 +329,6 @@ XBT_PRIVATE void TRACE_paje_start(); XBT_PRIVATE void TRACE_paje_end(); XBT_PRIVATE void TRACE_paje_dump_buffer (int force); -XBT_PUBLIC(void) new_pajeDefineVariableType(type_t type); -XBT_PUBLIC(void) new_pajeDefineStateType(type_t type); -XBT_PUBLIC(void) new_pajeDefineEventType(type_t type); -XBT_PUBLIC(void) new_pajeDefineLinkType(type_t type, type_t source, type_t dest); -XBT_PUBLIC(void) new_pajeDefineEntityValue (val_t type); - -// Container -XBT_PUBLIC(void) new_pajeCreateContainer (container_t container); -XBT_PUBLIC(void) new_pajeDestroyContainer (container_t container); - -XBT_PUBLIC(void) new_pajeSetVariable (double timestamp, container_t container, type_t type, double value); -XBT_PUBLIC(void) new_pajeAddVariable (double timestamp, container_t container, type_t type, double value); - - -XBT_PUBLIC(void) new_pajeSetState (double timestamp, container_t container, type_t type, val_t value); -XBT_PUBLIC(void) new_pajePushState (double timestamp, container_t container, type_t type, val_t value); -XBT_PUBLIC(void) new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value, - void* extra); -XBT_PUBLIC(void) new_pajePopState (double timestamp, container_t container, type_t type); -XBT_PUBLIC(void) new_pajeResetState (double timestamp, container_t container, type_t type); -XBT_PUBLIC(void) new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, - const char *value, const char *key); -XBT_PUBLIC(void) new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, - container_t sourceContainer, const char *value, const char *key, int size); -XBT_PUBLIC(void) new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, - const char *value, const char *key); -XBT_PUBLIC(void) new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value); /* from instr_config.c */ XBT_PRIVATE bool TRACE_needs_platform (); diff --git a/src/instr/instr_resource_utilization.cpp b/src/instr/instr_resource_utilization.cpp index bebb4cd14a..e8d848902a 100644 --- a/src/instr/instr_resource_utilization.cpp +++ b/src/instr/instr_resource_utilization.cpp @@ -29,17 +29,17 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari if (!xbt_dict_get_or_null(platform_variables, key)) { container_t container = PJ_container_get (resource); type_t type = PJ_type_get (variable, container->type); - new_pajeSetVariable (now, container, type, 0); + SetVariableEvent (now, container, type, 0); xbt_dict_set(platform_variables, key, (char*)"", nullptr); } xbt_free(key); } static void instr_event (double now, double delta, type_t variable, container_t resource, double value) -{ s_subVariable n; +{ __TRACE_surf_check_variable_set_to_zero(now, variable->name, resource->name); - new_pajeAddVariable(now, resource, variable, value); - n.new_pajeSubVariable(now + delta, resource, variable, value); + AddVariableEvent(now, resource, variable, value); + SubVariableEvent(now + delta, resource, variable, value); } /* TRACE_surf_link_set_utilization: entry point from SimGrid */ diff --git a/src/instr/instr_trace.cpp b/src/instr/instr_trace.cpp index 24493a0ed2..79fc08d910 100644 --- a/src/instr/instr_trace.cpp +++ b/src/instr/instr_trace.cpp @@ -8,6 +8,7 @@ #include "src/instr/instr_smpi.h" #include "src/smpi/private.hpp" #include "xbt/virtu.h" /* sg_cmdline */ +#include "typeinfo" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_trace, instr, "tracing event system"); @@ -60,8 +61,8 @@ void TRACE_paje_dump_buffer (int force) XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump); if (force){ for (auto event :buffer){ - event->print (event); - event->free (event); + event->print(); + delete event; } buffer.clear(); }else{ @@ -70,8 +71,8 @@ void TRACE_paje_dump_buffer (int force) double head_timestamp = event->timestamp; if (head_timestamp > TRACE_last_timestamp_to_dump) break; - event->print (event); - event->free (event); + event->print(); + delete event; ++i; } buffer.erase(buffer.begin(), i); @@ -83,8 +84,8 @@ void TRACE_paje_dump_buffer (int force) static void insert_into_buffer (paje_event_t tbi) { if (TRACE_buffer() == 0){ - tbi->print (tbi); - tbi->free (tbi); + tbi->print (); + delete tbi; return; } @@ -104,10 +105,11 @@ static void insert_into_buffer (paje_event_t tbi) std::distance(buffer.rend(),i)); } -static void free_paje_event (paje_event_t event) +paje_event:: ~paje_event() { - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - switch (event->event_type){ + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, timestamp); + + /* switch (event->event_type){ case PAJE_StartLink: xbt_free (((startLink_t)(event->data))->value); xbt_free (((startLink_t)(event->data))->key); @@ -118,372 +120,273 @@ static void free_paje_event (paje_event_t event) break; default: break; - } - xbt_free (event->data); - xbt_free (event); + }*/ } -void paje_event::Event(type_t type) -{ - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineContainerType; - event->timestamp = 0; - event->print = active_writer.print_DefineContainerType; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineContainerType_t, 1); - ((defineContainerType_t)(event->data))->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); +//-------------------------------------------------------- + +DefineContainerEvent::DefineContainerEvent(type_t type) +{ + event_type = PAJE_DefineContainerType; + timestamp = 0; + this->type = type; + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - event->print (event); - event->free (event); + print (); } -//-------------------------------------------------------- -/* -void s_defineContainerType::new_pajeDefineContainerType(type_t type) + +DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineContainerType; - event->timestamp = 0; - event->print = active_writer.print_DefineContainerType; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineContainerType_t, 1); - ((defineContainerType_t)(event->data))->type = type; + this->event_type = PAJE_DefineVariableType; + this->timestamp = 0; + this->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - event->print (event); - event->free (event); + print (); } -*/ - -void new_pajeDefineVariableType(type_t type) +// TODO convertir tt les constructeurs proprement. +DefineStateTypeEvent::DefineStateTypeEvent(type_t type) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineVariableType; - event->timestamp = 0; - event->print = active_writer.print_DefineVariableType; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineVariableType_t, 1); - ((defineVariableType_t)(event->data))->type = type; + this->event_type = PAJE_DefineStateType; + this->timestamp = 0; + this->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - event->print (event); - event->free (event); + print(); } -void new_pajeDefineStateType(type_t type) +DefineEventTypeEvent::DefineEventTypeEvent(type_t type) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineStateType; - event->timestamp = 0; - event->print = active_writer.print_DefineStateType; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineStateType_t, 1); - ((defineStateType_t)(event->data))->type = type; + this->event_type = PAJE_DefineEventType; + this->timestamp = 0; + this->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - event->print (event); - event->free (event); + print(); } -void new_pajeDefineEventType(type_t type) +DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineEventType; - event->timestamp = 0; - event->print = active_writer.print_DefineEventType; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineEventType_t, 1); - ((defineEventType_t)(event->data))->type = type; + this->event_type = PAJE_DefineLinkType; + this->timestamp = 0; + this->type = type; + this->source = source; + this->dest = dest; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - event->print (event); - event->free (event); + print(); } -void new_pajeDefineLinkType(type_t type, type_t source, type_t dest) +DefineEntityValueEvent::DefineEntityValueEvent (val_t value) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineLinkType; - event->timestamp = 0; - event->print = active_writer.print_DefineLinkType; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineLinkType_t, 1); - ((defineLinkType_t)(event->data))->type = type; - ((defineLinkType_t)(event->data))->source = source; - ((defineLinkType_t)(event->data))->dest = dest; - - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); + this->event_type = PAJE_DefineEntityValue; + this->timestamp = 0; + this->value = value; + + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - event->print (event); - event->free (event); + print(); } -void new_pajeDefineEntityValue (val_t value) +CreateContainerEvent::CreateContainerEvent (container_t container) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DefineEntityValue; - event->timestamp = 0; - event->print = active_writer.print_DefineEntityValue; - event->free = &free_paje_event; - event->data = xbt_new0(s_defineEntityValue_t, 1); - ((defineEntityValue_t)(event->data))->value = value; + this->event_type = PAJE_CreateContainer; + this->timestamp = SIMIX_get_clock(); + this->container = container; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); //print it - event->print (event); - event->free (event); + print(); } -void new_pajeCreateContainer (container_t container) +DestroyContainerEvent::DestroyContainerEvent (container_t container) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_CreateContainer; - event->timestamp = SIMIX_get_clock(); - event->print = active_writer.print_CreateContainer; - event->free = &free_paje_event; - event->data = xbt_new0(s_createContainer_t, 1); - ((createContainer_t)(event->data))->container = container; + this->event_type = PAJE_DestroyContainer; + this->timestamp = SIMIX_get_clock(); + this->container = container; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); //print it - event->print (event); - event->free (event); + print(); } -void new_pajeDestroyContainer (container_t container) +SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_DestroyContainer; - event->timestamp = SIMIX_get_clock(); - event->print = active_writer.print_DestroyContainer; - event->free = &free_paje_event; - event->data = xbt_new0(s_destroyContainer_t, 1); - ((destroyContainer_t)(event->data))->container = container; + this->event_type = PAJE_SetVariable; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->value = value; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); - //print it - event->print (event); - event->free (event); + insert_into_buffer (this); } -void new_pajeSetVariable (double timestamp, container_t container, type_t type, double value) + +AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_SetVariable; - event->timestamp = timestamp; - event->print = active_writer.print_SetVariable; - event->free = &free_paje_event; - event->data = xbt_new0(s_setVariable_t, 1); - ((setVariable_t)(event->data))->type = type; - ((setVariable_t)(event->data))->container = container; - ((setVariable_t)(event->data))->value = value; - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); -} + this->event_type = PAJE_AddVariable; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->value = value; + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); -void new_pajeAddVariable (double timestamp, container_t container, type_t type, double value) -{ - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_AddVariable; - event->timestamp = timestamp; - event->print = active_writer.print_AddVariable; - event->free = &free_paje_event; - event->data = xbt_new0(s_addVariable_t, 1); - ((addVariable_t)(event->data))->type = type; - ((addVariable_t)(event->data))->container = container; - ((addVariable_t)(event->data))->value = value; - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); + insert_into_buffer (this); } -void s_subVariable_t::new_pajeSubVariable (double timestamp, container_t container, type_t type, double value) +SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_SubVariable; - event->timestamp = timestamp; - event->print = active_writer.print_SubVariable; - event->free = &free_paje_event; - event->data = xbt_new0(s_subVariable_t, 1); - ((subVariable_t)(event->data))->type = type; - ((subVariable_t)(event->data))->container = container; - ((subVariable_t)(event->data))->value = value; - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); + this->event_type = PAJE_SubVariable; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->value = value; + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + + insert_into_buffer (this); } -void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value) +SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t type, val_t value) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_SetState; - event->timestamp = timestamp; - event->print = active_writer.print_SetState; - event->free = &free_paje_event; - event->data = xbt_new0(s_setState_t, 1); - ((setState_t)(event->data))->type = type; - ((setState_t)(event->data))->container = container; - ((setState_t)(event->data))->value = value; + this->event_type = PAJE_SetState; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->value = value; #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { smpi_trace_call_location_t* loc = smpi_trace_get_call_location(); - ((setState_t)(event->data))->filename = loc->filename; - ((setState_t)(event->data))->linenumber = loc->linenumber; + filename = loc->filename; + linenumber = loc->linenumber; } #endif - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); - insert_into_buffer (event); + insert_into_buffer (this); } -void new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value, void* extra) +PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value, void* extra) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_PushState; - event->timestamp = timestamp; - event->print = active_writer.print_PushState; - event->free = &free_paje_event; - event->data = xbt_new0(s_pushState_t, 1); - ((pushState_t)(event->data))->type = type; - ((pushState_t)(event->data))->container = container; - ((pushState_t)(event->data))->value = value; - ((pushState_t)(event->data))->extra = extra; + this->event_type = PAJE_PushState; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->value = value; + this->extra = extra; #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { smpi_trace_call_location_t* loc = smpi_trace_get_call_location(); - ((pushState_t)(event->data))->filename = loc->filename; - ((pushState_t)(event->data))->linenumber = loc->linenumber; + filename = loc->filename; + linenumber = loc->linenumber; } #endif - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); - insert_into_buffer (event); + insert_into_buffer (this); } -void new_pajePushState (double timestamp, container_t container, type_t type, val_t value) +PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value) { - new_pajePushStateWithExtra(timestamp, container, type, value, nullptr); + new PushStateEvent(timestamp, container, type, value, nullptr); } -void new_pajePopState (double timestamp, container_t container, type_t type) +PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t type) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_PopState; - event->timestamp = timestamp; - event->print = active_writer.print_PopState; - event->free = &free_paje_event; - event->data = xbt_new0(s_popState_t, 1); - ((popState_t)(event->data))->type = type; - ((popState_t)(event->data))->container = container; - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); + this->event_type = PAJE_PopState; + this->timestamp = timestamp; + this->type = type; + this->container = container; + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + + insert_into_buffer (this); } -void new_pajeResetState (double timestamp, container_t container, type_t type) +ResetStateEvent::ResetStateEvent (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 = active_writer.print_ResetState; - 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); + this->event_type = PAJE_ResetState; + this->timestamp = timestamp; + this->type = type; + this->container = container; + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + + insert_into_buffer (this); } -void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, +StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key) { - new_pajeStartLinkWithSize(timestamp, container, type, sourceContainer, value, key, -1); + new StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1); } -void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer, +StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key, int size) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_StartLink; - event->timestamp = timestamp; - event->print = active_writer.print_StartLink; - event->free = &free_paje_event; - event->data = xbt_new0(s_startLink_t, 1); - ((startLink_t)(event->data))->type = type; - ((startLink_t)(event->data))->container = container; - ((startLink_t)(event->data))->sourceContainer = sourceContainer; - ((startLink_t)(event->data))->value = xbt_strdup(value); - ((startLink_t)(event->data))->key = xbt_strdup(key); - ((startLink_t)(event->data))->size = size; - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); + event_type = PAJE_StartLink; + timestamp = timestamp; + this->type = type; + this->container = container; + this->sourceContainer = sourceContainer; + value = xbt_strdup(value); + key = xbt_strdup(key); + this->size = size; + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + + insert_into_buffer (this); } -void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, +EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer, const char *value, const char *key) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_EndLink; - event->timestamp = timestamp; - event->print = active_writer.print_EndLink; - event->free = &free_paje_event; - event->data = xbt_new0(s_endLink_t, 1); - ((endLink_t)(event->data))->type = type; - ((endLink_t)(event->data))->container = container; - ((endLink_t)(event->data))->destContainer = destContainer; - ((endLink_t)(event->data))->value = xbt_strdup(value); - ((endLink_t)(event->data))->key = xbt_strdup(key); - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); + this->event_type = PAJE_EndLink; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->destContainer = destContainer; + this->value = xbt_strdup(value); + this->key = xbt_strdup(key); + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + + insert_into_buffer (this); } -void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value) +NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t value) { - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_NewEvent; - event->timestamp = timestamp; - event->print = active_writer.print_NewEvent; - event->free = &free_paje_event; - event->data = xbt_new0(s_newEvent_t, 1); - ((newEvent_t)(event->data))->type = type; - ((newEvent_t)(event->data))->container = container; - ((newEvent_t)(event->data))->value = value; - - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); + this->event_type = PAJE_NewEvent; + this->timestamp = timestamp; + this->type = type; + this->container = container; + this->value = value; + + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + + insert_into_buffer (this); } -- 2.20.1