1 /* Copyright (c) 2010-2016. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "src/instr/instr_private.h"
8 #include "src/instr/instr_smpi.h"
9 #include "src/smpi/private.hpp"
11 #include "xbt/virtu.h" /* sg_cmdline */
12 #include "simgrid/sg_config.h"
16 #include <iomanip> /** std::setprecision **/
19 #include <direct.h> // _mkdir
22 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system");
24 static std::stringstream stream;
25 FILE *tracing_file = nullptr;
27 static xbt_dict_t tracing_files = nullptr; // TI specific
28 static double prefix=0.0; // TI specific
31 void print_NULL(PajeEvent* event){}
33 /* The active set of functions for the selected trace format
34 * By default, they all do nothing, hence the print_NULL to avoid segfaults */
36 std::vector<PajeEvent*> buffer;
37 void buffer_debug(std::vector<PajeEvent*> *buf);
39 void dump_comment (const char *comment)
41 if (not strlen(comment))
43 fprintf (tracing_file, "# %s\n", comment);
46 void dump_comment_file (const char *filename)
48 if (not strlen(filename))
50 FILE *file = fopen (filename, "r");
52 THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
54 while (not feof(file)) {
57 if (feof(file)) break;
58 fprintf (tracing_file, "# ");
60 fprintf (tracing_file, "%c", c);
62 if (feof(file)) break;
64 fprintf (tracing_file, "\n");
69 double TRACE_last_timestamp_to_dump = 0;
70 //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
71 void TRACE_paje_dump_buffer (int force)
73 if (not TRACE_is_enabled())
75 XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
77 for (auto event : buffer){
83 std::vector<PajeEvent*>::iterator i = buffer.begin();
84 for (auto event :buffer){
85 double head_timestamp = event->timestamp;
86 if (head_timestamp > TRACE_last_timestamp_to_dump)
92 buffer.erase(buffer.begin(), i);
94 XBT_DEBUG("%s: ends", __FUNCTION__);
97 void buffer_debug(std::vector<PajeEvent*> *buf);
98 void buffer_debug(std::vector<PajeEvent*> *buf) {
100 XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
101 for (auto event :*buf){
103 XBT_DEBUG("%p %s", event, stream.str().c_str());
110 static void print_row() {
112 fprintf(tracing_file, "%s", stream.str().c_str());
113 XBT_DEBUG("Dump %s", stream.str().c_str());
118 static void print_timestamp(PajeEvent* event) {
120 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
121 if (event->timestamp < 1e-12)
124 stream << event->timestamp;
127 /* internal do the instrumentation module */
128 static void insert_into_buffer (PajeEvent* tbi)
130 if (TRACE_buffer() == 0){
135 buffer_debug(&buffer);
137 XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)",
138 __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size());
139 std::vector<PajeEvent*>::reverse_iterator i;
140 for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
142 XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1,
143 (int)e1->event_type, e1->timestamp);
144 if (e1->timestamp <= tbi->timestamp)
147 if (i == buffer.rend())
148 XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
149 else if (i == buffer.rbegin())
150 XBT_DEBUG("%s: inserted at end", __FUNCTION__);
152 XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__,
153 std::distance(buffer.rbegin(),i));
154 buffer.insert(i.base(), tbi);
156 buffer_debug(&buffer);
159 PajeEvent:: ~PajeEvent()
161 XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__,
162 this, (int)event_type, timestamp);
163 // xbt_backtrace_display_current();
165 /* switch (event->event_type){
167 xbt_free (((startLink_t)(event->data))->value);
168 xbt_free (((startLink_t)(event->data))->key);
171 xbt_free (((endLink_t)(event->data))->value);
172 xbt_free (((endLink_t)(event->data))->key);
179 void TRACE_paje_start() {
180 char *filename = TRACE_get_filename();
181 tracing_file = fopen(filename, "w");
182 if (tracing_file == nullptr){
183 THROWF (system_error, 1, "Tracefile %s could not be opened for writing.", filename);
186 XBT_DEBUG("Filename %s is open for writing", filename);
188 /* output generator version */
189 fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n",
190 SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
191 fprintf (tracing_file, "#[");
194 xbt_dynar_foreach (xbt_cmdline, cpt, str){
195 fprintf(tracing_file, "%s ",str);
197 fprintf (tracing_file, "]\n");
199 /* output one line comment */
200 dump_comment (TRACE_get_comment());
202 /* output comment file */
203 dump_comment_file (TRACE_get_comment_file());
206 TRACE_header(TRACE_basic(),TRACE_display_sizes());
209 void TRACE_paje_end() {
210 fclose(tracing_file);
211 char *filename = TRACE_get_filename();
212 XBT_DEBUG("Filename %s is closed", filename);
215 void DefineContainerEvent(type_t type)
217 e_event_type event_type = PAJE_DefineContainerType;
218 double timestamp = 0;
219 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
221 if (instr_fmt_type == instr_fmt_paje) {
222 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
223 stream << std::fixed << std::setprecision(TRACE_precision());
224 stream << (int)event_type;
225 stream << " " << type->id
226 << " " << type->father->id
227 << " " << type->name;
229 } else if (instr_fmt_type == instr_fmt_TI) {
239 DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type)
241 this->event_type = PAJE_DefineVariableType;
245 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
252 void DefineVariableTypeEvent::print() {
253 if (instr_fmt_type == instr_fmt_paje) {
254 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
255 stream << std::fixed << std::setprecision(TRACE_precision());
256 stream << (int)this->event_type;
257 stream << " " << type->id << " " << type->father->id << " " << type->name;
259 stream << " \"" << type->color << "\"";
261 } else if (instr_fmt_type == instr_fmt_TI) {
268 DefineStateTypeEvent::DefineStateTypeEvent(type_t type)
270 this->event_type = PAJE_DefineStateType;
274 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
282 DefineEventTypeEvent::DefineEventTypeEvent(type_t type)
284 this->event_type = PAJE_DefineEventType;
288 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
295 void DefineStateTypeEvent::print() {
296 if (instr_fmt_type == instr_fmt_paje) {
297 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
298 stream << std::fixed << std::setprecision(TRACE_precision());
299 stream << (int)this->event_type;
300 stream << " " << type->id << " " << type->father->id << " " << type->name;
302 } else if (instr_fmt_type == instr_fmt_TI) {
309 void DefineEventTypeEvent::print() {
310 if (instr_fmt_type == instr_fmt_paje) {
311 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
312 stream << std::fixed << std::setprecision(TRACE_precision());
313 stream << (int)this->event_type;
314 stream << " " << type->id << " " << type->father->id << " " << type->name;
316 } else if (instr_fmt_type == instr_fmt_TI) {
323 DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest)
325 this->event_type = PAJE_DefineLinkType;
328 this->source = source;
331 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
338 void DefineLinkTypeEvent::print() {
339 if (instr_fmt_type == instr_fmt_paje) {
340 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
341 stream << std::fixed << std::setprecision(TRACE_precision());
342 stream << (int)this->event_type;
343 stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name;
345 } else if (instr_fmt_type == instr_fmt_TI) {
352 DefineEntityValueEvent::DefineEntityValueEvent (val_t value)
354 this->event_type = PAJE_DefineEntityValue;
358 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
366 void DefineEntityValueEvent::print() {
367 if (instr_fmt_type == instr_fmt_paje) {
368 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
369 stream << std::fixed << std::setprecision(TRACE_precision());
370 stream << (int)this->event_type;
371 stream << " " << value->id << " " << value->father->id << " " << value->name;
373 stream << " \"" << value->color << "\"";
375 } else if (instr_fmt_type == instr_fmt_TI) {
382 CreateContainerEvent::CreateContainerEvent (container_t container)
384 this->event_type = PAJE_CreateContainer;
385 this->timestamp = SIMIX_get_clock();
386 this->container = container;
388 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
394 void CreateContainerEvent::print() {
395 if (instr_fmt_type == instr_fmt_paje) {
396 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
397 stream << std::fixed << std::setprecision(TRACE_precision());
398 stream << (int)this->event_type;
399 print_timestamp(this);
400 stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \""
401 << container->name << "\"";
404 } else if (instr_fmt_type == instr_fmt_TI) {
405 // if we are in the mode with only one file
406 static FILE* ti_unique_file = nullptr;
408 if (tracing_files == nullptr) {
409 tracing_files = xbt_dict_new_homogeneous(nullptr);
410 // generate unique run id with time
411 prefix = xbt_os_time();
414 if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
415 char* folder_name = bprintf("%s_files", TRACE_get_filename());
416 char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name);
420 mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO);
422 ti_unique_file = fopen(filename, "w");
423 xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno));
424 fprintf(tracing_file, "%s\n", filename);
426 xbt_free(folder_name);
430 xbt_dict_set(tracing_files, container->name, (void*)ti_unique_file, nullptr);
436 DestroyContainerEvent::DestroyContainerEvent (container_t container)
438 this->event_type = PAJE_DestroyContainer;
439 this->timestamp = SIMIX_get_clock();
440 this->container = container;
442 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
448 void DestroyContainerEvent::print() {
449 if (instr_fmt_type == instr_fmt_paje) {
450 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
451 stream << std::fixed << std::setprecision(TRACE_precision());
452 stream << (int)this->event_type;
453 print_timestamp(this);
454 stream << " " << container->type->id << " " << container->id;
457 } else if (instr_fmt_type == instr_fmt_TI) {
458 if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) {
459 FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name);
462 xbt_dict_remove(tracing_files, container->name);
468 SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value)
470 this->event_type = PAJE_SetVariable;
471 this->timestamp = timestamp;
473 this->container = container;
476 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
478 insert_into_buffer (this);
481 void SetVariableEvent::print() {
482 if (instr_fmt_type == instr_fmt_paje) {
483 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
484 stream << std::fixed << std::setprecision(TRACE_precision());
485 stream << (int)this->event_type;
486 print_timestamp(this);
487 stream << " " << type->id << " " << container->id << " " << value;
489 } else if (instr_fmt_type == instr_fmt_TI) {
496 AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value)
498 this->event_type = PAJE_AddVariable;
499 this->timestamp = timestamp;
501 this->container = container;
504 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
506 insert_into_buffer (this);
509 void AddVariableEvent::print() {
510 if (instr_fmt_type == instr_fmt_paje) {
511 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
512 stream << std::fixed << std::setprecision(TRACE_precision());
513 stream << (int)this->event_type;
514 print_timestamp(this);
515 stream << " " << type->id << " " << container->id << " " << value;
517 } else if (instr_fmt_type == instr_fmt_TI) {
524 SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value)
526 this->event_type = PAJE_SubVariable;
527 this->timestamp = timestamp;
529 this->container = container;
532 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
534 insert_into_buffer (this);
537 void SubVariableEvent::print() {
538 if (instr_fmt_type == instr_fmt_paje) {
539 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
540 stream << std::fixed << std::setprecision(TRACE_precision());
541 stream << (int)this->event_type;
542 print_timestamp(this);
543 stream << " " << type->id << " " << container->id << " " << value;
545 } else if (instr_fmt_type == instr_fmt_TI) {
552 SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t type, val_t value)
554 this->event_type = PAJE_SetState;
555 this->timestamp = timestamp;
557 this->container = container;
561 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
562 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
563 filename = loc->filename;
564 linenumber = loc->linenumber;
568 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
570 insert_into_buffer (this);
573 void SetStateEvent::print() {
574 if (instr_fmt_type == instr_fmt_paje) {
575 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
576 stream << std::fixed << std::setprecision(TRACE_precision());
577 stream << (int)this->event_type;
578 print_timestamp(this);
579 stream << " " << type->id << " " << container->id;
580 stream << " " << value->id;
582 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
583 stream << " \"" << filename << "\" " << linenumber;
587 } else if (instr_fmt_type == instr_fmt_TI) {
594 PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value, void* extra)
596 this->event_type = PAJE_PushState;
597 this->timestamp = timestamp;
599 this->container = container;
601 this->extra_ = extra;
604 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
605 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
606 filename = loc->filename;
607 linenumber = loc->linenumber;
611 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
613 insert_into_buffer (this);
616 PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value)
617 : PushStateEvent(timestamp, container, type, value, nullptr)
619 void PushStateEvent::print() {
620 if (instr_fmt_type == instr_fmt_paje) {
621 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
622 stream << std::fixed << std::setprecision(TRACE_precision());
623 stream << (int)this->event_type;
624 print_timestamp(this);
625 stream << " " << type->id << " " << container->id;
626 stream << " " << value->id;
628 if (TRACE_display_sizes()) {
630 if (extra_ != nullptr) {
631 stream << static_cast<instr_extra_data>(extra_)->send_size;
637 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
638 stream << " \"" << filename << "\" " << linenumber;
643 if (extra_ != nullptr) {
644 if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
645 xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
646 if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
647 xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
650 } else if (instr_fmt_type == instr_fmt_TI) {
651 if (extra_ == nullptr)
653 instr_extra_data extra = (instr_extra_data)extra_;
655 char* process_id = nullptr;
656 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
657 if (strstr(container->name, "rank-") == nullptr)
658 process_id = xbt_strdup(container->name);
660 process_id = xbt_strdup(container->name + 5);
662 FILE* trace_file = (FILE*)xbt_dict_get(tracing_files, container->name);
664 switch (extra->type) {
666 fprintf(trace_file, "%s init\n", process_id);
668 case TRACING_FINALIZE:
669 fprintf(trace_file, "%s finalize\n", process_id);
672 fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
675 fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
678 fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
681 fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
684 fprintf(trace_file, "%s test\n", process_id);
687 fprintf(trace_file, "%s wait\n", process_id);
689 case TRACING_WAITALL:
690 fprintf(trace_file, "%s waitAll\n", process_id);
692 case TRACING_BARRIER:
693 fprintf(trace_file, "%s barrier\n", process_id);
695 case TRACING_BCAST: // rank bcast size (root) (datatype)
696 fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
697 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
698 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
699 fprintf(trace_file, "\n");
701 case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
702 fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
703 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
704 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
705 fprintf(trace_file, "\n");
707 case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
708 fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size,
711 case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
712 fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size,
713 extra->datatype1, extra->datatype2);
715 case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
716 fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
717 for (int i = 0; i < extra->num_processes; i++)
718 fprintf(trace_file, "%d ", extra->sendcounts[i]);
719 fprintf(trace_file, "%d ", extra->recv_size);
720 for (int i = 0; i < extra->num_processes; i++)
721 fprintf(trace_file, "%d ", extra->recvcounts[i]);
722 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
724 case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
725 fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
726 extra->datatype1, extra->datatype2);
728 case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
729 fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
730 for (int i = 0; i < extra->num_processes; i++)
731 fprintf(trace_file, "%d ", extra->recvcounts[i]);
732 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
734 case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
735 fprintf(trace_file, "%s reduceScatter ", process_id);
736 for (int i = 0; i < extra->num_processes; i++)
737 fprintf(trace_file, "%d ", extra->recvcounts[i]);
738 fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
740 case TRACING_COMPUTING:
741 fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
743 case TRACING_SLEEPING:
744 fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
746 case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
747 fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
748 for (int i = 0; i < extra->num_processes; i++)
749 fprintf(trace_file, "%d ", extra->recvcounts[i]);
750 fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
752 case TRACING_WAITANY:
753 case TRACING_SENDRECV:
754 case TRACING_SCATTER:
755 case TRACING_SCATTERV:
756 case TRACING_ALLGATHER:
759 case TRACING_COMM_SIZE:
760 case TRACING_COMM_SPLIT:
761 case TRACING_COMM_DUP:
765 XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->name);
769 if (extra->recvcounts != nullptr)
770 xbt_free(extra->recvcounts);
771 if (extra->sendcounts != nullptr)
772 xbt_free(extra->sendcounts);
773 xbt_free(process_id);
782 PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t type)
784 this->event_type = PAJE_PopState;
785 this->timestamp = timestamp;
787 this->container = container;
789 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
791 insert_into_buffer (this);
794 void PopStateEvent::print() {
795 if (instr_fmt_type == instr_fmt_paje) {
796 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
797 stream << std::fixed << std::setprecision(TRACE_precision());
798 stream << (int)this->event_type;
799 print_timestamp(this);
800 stream << " " << type->id << " " << container->id;
802 } else if (instr_fmt_type == instr_fmt_TI) {
809 ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_t type)
811 this->event_type = PAJE_ResetState;
812 this->timestamp = timestamp;
814 this->container = container;
816 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
818 insert_into_buffer (this);
822 void ResetStateEvent::print() {
823 if (instr_fmt_type == instr_fmt_paje) {
824 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
825 stream << std::fixed << std::setprecision(TRACE_precision());
826 stream << (int)this->event_type;
827 print_timestamp(this);
828 stream << " " << type->id << " " << container->id;
830 } else if (instr_fmt_type == instr_fmt_TI) {
837 StartLinkEvent::~StartLinkEvent()
842 StartLinkEvent::StartLinkEvent (double timestamp, container_t container,
843 type_t type, container_t sourceContainer, const char *value, const char *key)
844 : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
847 StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer,
848 const char *value, const char *key, int size)
850 event_type = PAJE_StartLink;
851 this->timestamp = timestamp;
853 this->container = container;
854 this->sourceContainer = sourceContainer;
855 this->value = xbt_strdup(value);
856 this->key = xbt_strdup(key);
859 XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__,
860 (int)event_type, this->timestamp, this->value);
862 insert_into_buffer (this);
865 void StartLinkEvent::print() {
866 if (instr_fmt_type == instr_fmt_paje) {
867 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
868 stream << std::fixed << std::setprecision(TRACE_precision());
869 stream << (int)this->event_type;
870 print_timestamp(this);
871 stream << " " << type->id << " " << container->id << " " << value;
872 stream << " " << sourceContainer->id << " " << key;
874 if (TRACE_display_sizes()) {
875 stream << " " << size;
878 } else if (instr_fmt_type == instr_fmt_TI) {
885 EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
886 const char *value, const char *key)
888 this->event_type = PAJE_EndLink;
889 this->timestamp = timestamp;
891 this->container = container;
892 this->destContainer = destContainer;
893 this->value = xbt_strdup(value);
894 this->key = xbt_strdup(key);
896 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
898 insert_into_buffer (this);
901 EndLinkEvent::~EndLinkEvent()
906 void EndLinkEvent::print() {
907 if (instr_fmt_type == instr_fmt_paje) {
908 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
909 stream << std::fixed << std::setprecision(TRACE_precision());
910 stream << (int)this->event_type;
911 print_timestamp(this);
912 stream << " " << type->id << " " << container->id << " " << value;
913 stream << " " << destContainer->id << " " << key;
915 } else if (instr_fmt_type == instr_fmt_TI) {
922 NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t value)
924 this->event_type = PAJE_NewEvent;
925 this->timestamp = timestamp;
927 this->container = container;
930 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
932 insert_into_buffer (this);
935 void NewEvent::print () {
936 if (instr_fmt_type == instr_fmt_paje) {
937 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
938 stream << std::fixed << std::setprecision(TRACE_precision());
939 stream << (int)this->event_type;
940 print_timestamp(this);
941 stream << " " << type->id << " " << container->id << " " << value->id;
943 } else if (instr_fmt_type == instr_fmt_TI) {
951 void TRACE_TI_start()
953 char *filename = TRACE_get_filename();
954 tracing_file = fopen(filename, "w");
955 if (tracing_file == nullptr)
956 THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
958 XBT_DEBUG("Filename %s is open for writing", filename);
960 /* output one line comment */
961 dump_comment(TRACE_get_comment());
963 /* output comment file */
964 dump_comment_file(TRACE_get_comment_file());
969 xbt_dict_free(&tracing_files);
970 fclose(tracing_file);
971 char *filename = TRACE_get_filename();
972 XBT_DEBUG("Filename %s is closed", filename);