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/include/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
30 std::vector<simgrid::instr::PajeEvent*> buffer;
31 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
33 void dump_comment (const char *comment)
35 if (not strlen(comment))
37 fprintf (tracing_file, "# %s\n", comment);
40 void dump_comment_file (const char *filename)
42 if (not strlen(filename))
44 FILE *file = fopen (filename, "r");
46 THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
48 while (not feof(file)) {
51 if (feof(file)) break;
52 fprintf (tracing_file, "# ");
54 fprintf (tracing_file, "%c", c);
56 if (feof(file)) break;
58 fprintf (tracing_file, "\n");
63 double TRACE_last_timestamp_to_dump = 0;
64 //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
65 void TRACE_paje_dump_buffer (int force)
67 if (not TRACE_is_enabled())
69 XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
71 for (auto const& event : buffer) {
77 std::vector<simgrid::instr::PajeEvent*>::iterator i = buffer.begin();
78 for (auto const& event : buffer) {
79 double head_timestamp = event->timestamp;
80 if (head_timestamp > TRACE_last_timestamp_to_dump)
86 buffer.erase(buffer.begin(), i);
88 XBT_DEBUG("%s: ends", __FUNCTION__);
91 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
92 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf)
95 XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
96 for (auto const& event : *buf) {
98 XBT_DEBUG("%p %s", event, stream.str().c_str());
105 static void print_row() {
107 fprintf(tracing_file, "%s", stream.str().c_str());
108 XBT_DEBUG("Dump %s", stream.str().c_str());
113 static void print_timestamp(simgrid::instr::PajeEvent* event)
116 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
117 if (event->timestamp < 1e-12)
120 stream << event->timestamp;
123 /* internal do the instrumentation module */
124 static void insert_into_buffer(simgrid::instr::PajeEvent* tbi)
126 if (TRACE_buffer() == 0){
131 buffer_debug(&buffer);
133 XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)",
134 __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size());
135 std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
136 for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
137 simgrid::instr::PajeEvent* e1 = *i;
138 XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1,
139 (int)e1->event_type, e1->timestamp);
140 if (e1->timestamp <= tbi->timestamp)
143 if (i == buffer.rend())
144 XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
145 else if (i == buffer.rbegin())
146 XBT_DEBUG("%s: inserted at end", __FUNCTION__);
148 XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__,
149 std::distance(buffer.rbegin(),i));
150 buffer.insert(i.base(), tbi);
152 buffer_debug(&buffer);
155 simgrid::instr::PajeEvent::~PajeEvent()
157 XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__,
158 this, (int)event_type, timestamp);
161 void TRACE_paje_start() {
162 char *filename = TRACE_get_filename();
163 tracing_file = fopen(filename, "w");
164 if (tracing_file == nullptr){
165 THROWF (system_error, 1, "Tracefile %s could not be opened for writing.", filename);
168 XBT_DEBUG("Filename %s is open for writing", filename);
170 /* output generator version */
171 fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n",
172 SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
173 fprintf (tracing_file, "#[");
176 xbt_dynar_foreach (xbt_cmdline, cpt, str){
177 fprintf(tracing_file, "%s ",str);
179 fprintf (tracing_file, "]\n");
181 /* output one line comment */
182 dump_comment (TRACE_get_comment());
184 /* output comment file */
185 dump_comment_file (TRACE_get_comment_file());
188 TRACE_header(TRACE_basic(),TRACE_display_sizes());
191 void TRACE_paje_end() {
192 fclose(tracing_file);
193 char *filename = TRACE_get_filename();
194 XBT_DEBUG("Filename %s is closed", filename);
197 void DefineContainerEvent(simgrid::instr::Type* type)
199 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType);
201 if (instr_fmt_type == instr_fmt_paje) {
202 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType,
203 TRACE_precision(), 0.);
204 stream << std::fixed << std::setprecision(TRACE_precision());
205 stream << simgrid::instr::PAJE_DefineContainerType;
206 stream << " " << type->id << " " << type->father->id << " " << type->name;
208 } else if (instr_fmt_type == instr_fmt_TI) {
216 void LogVariableTypeDefinition(simgrid::instr::Type* type)
219 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType);
222 if (instr_fmt_type == instr_fmt_paje) {
223 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType,
224 TRACE_precision(), 0.);
225 stream << std::fixed << std::setprecision(TRACE_precision());
226 stream << simgrid::instr::PAJE_DefineVariableType;
227 stream << " " << type->id << " " << type->father->id << " " << type->name;
229 stream << " \"" << type->color << "\"";
231 } else if (instr_fmt_type == instr_fmt_TI) {
238 void LogStateTypeDefinition(simgrid::instr::Type* type)
241 if (instr_fmt_type == instr_fmt_paje) {
242 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, TRACE_precision(),
244 stream << std::fixed << std::setprecision(TRACE_precision());
245 stream << simgrid::instr::PAJE_DefineStateType;
246 stream << " " << type->id << " " << type->father->id << " " << type->name;
248 } else if (instr_fmt_type == instr_fmt_TI) {
255 void LogDefineEventType(simgrid::instr::Type* type)
258 if (instr_fmt_type == instr_fmt_paje) {
259 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType,
260 TRACE_precision(), 0.);
261 stream << std::fixed << std::setprecision(TRACE_precision());
262 stream << simgrid::instr::PAJE_DefineEventType;
263 stream << " " << type->id << " " << type->father->id << " " << type->name;
265 } else if (instr_fmt_type == instr_fmt_TI) {
272 void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest)
274 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType);
276 if (instr_fmt_type == instr_fmt_paje) {
277 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(),
279 stream << std::fixed << std::setprecision(TRACE_precision());
280 stream << simgrid::instr::PAJE_DefineLinkType;
281 stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name;
283 } else if (instr_fmt_type == instr_fmt_TI) {
290 void LogEntityValue(simgrid::instr::Value* val)
292 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
294 if (instr_fmt_type == instr_fmt_paje) {
295 stream << std::fixed << std::setprecision(TRACE_precision());
296 stream << simgrid::instr::PAJE_DefineEntityValue;
297 stream << " " << val->id << " " << val->father->id << " " << val->name;
299 stream << " \"" << val->color << "\"";
301 } else if (instr_fmt_type == instr_fmt_TI) {
309 void LogContainerCreation (container_t container)
311 double timestamp = SIMIX_get_clock();
313 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp);
315 if (instr_fmt_type == instr_fmt_paje) {
316 stream << std::fixed << std::setprecision(TRACE_precision());
317 stream << simgrid::instr::PAJE_CreateContainer;
319 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
320 if (timestamp < 1e-12)
324 stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \""
325 << container->name << "\"";
328 } else if (instr_fmt_type == instr_fmt_TI) {
329 // if we are in the mode with only one file
330 static FILE* ti_unique_file = nullptr;
332 if (tracing_files == nullptr) {
333 tracing_files = xbt_dict_new_homogeneous(nullptr);
334 // generate unique run id with time
335 prefix = xbt_os_time();
338 if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
339 char* folder_name = bprintf("%s_files", TRACE_get_filename());
340 char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name);
344 mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO);
346 ti_unique_file = fopen(filename, "w");
347 xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno));
348 fprintf(tracing_file, "%s\n", filename);
350 xbt_free(folder_name);
354 xbt_dict_set(tracing_files, container->name, (void*)ti_unique_file, nullptr);
360 void LogContainerDestruction(container_t container)
362 double timestamp = SIMIX_get_clock();
364 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp);
366 if (instr_fmt_type == instr_fmt_paje) {
367 stream << std::fixed << std::setprecision(TRACE_precision());
368 stream << simgrid::instr::PAJE_DestroyContainer;
370 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
371 if (timestamp < 1e-12)
375 stream << " " << container->type->id << " " << container->id;
377 } else if (instr_fmt_type == instr_fmt_TI) {
378 if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) {
379 FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name);
382 xbt_dict_remove(tracing_files, container->name);
388 simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value)
390 this->event_type = PAJE_SetVariable;
391 this->timestamp = timestamp;
393 this->container = container;
396 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
398 insert_into_buffer (this);
401 void simgrid::instr::SetVariableEvent::print()
403 if (instr_fmt_type == instr_fmt_paje) {
404 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
405 stream << std::fixed << std::setprecision(TRACE_precision());
406 stream << (int)this->event_type;
407 print_timestamp(this);
408 stream << " " << type->id << " " << container->id << " " << value;
410 } else if (instr_fmt_type == instr_fmt_TI) {
417 simgrid::instr::AddVariableEvent::AddVariableEvent(double timestamp, container_t container, simgrid::instr::Type* type,
420 this->event_type = PAJE_AddVariable;
421 this->timestamp = timestamp;
423 this->container = container;
426 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
428 insert_into_buffer (this);
431 void simgrid::instr::AddVariableEvent::print()
433 if (instr_fmt_type == instr_fmt_paje) {
434 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
435 stream << std::fixed << std::setprecision(TRACE_precision());
436 stream << (int)this->event_type;
437 print_timestamp(this);
438 stream << " " << type->id << " " << container->id << " " << value;
440 } else if (instr_fmt_type == instr_fmt_TI) {
447 simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value)
449 this->event_type = PAJE_SubVariable;
450 this->timestamp = timestamp;
452 this->container = container;
455 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
457 insert_into_buffer (this);
460 void simgrid::instr::SubVariableEvent::print()
462 if (instr_fmt_type == instr_fmt_paje) {
463 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
464 stream << std::fixed << std::setprecision(TRACE_precision());
465 stream << (int)this->event_type;
466 print_timestamp(this);
467 stream << " " << type->id << " " << container->id << " " << value;
469 } else if (instr_fmt_type == instr_fmt_TI) {
476 simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* val)
478 this->event_type = PAJE_SetState;
479 this->timestamp = timestamp;
481 this->container = container;
485 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
486 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
487 filename = loc->filename;
488 linenumber = loc->linenumber;
492 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
494 insert_into_buffer (this);
497 void simgrid::instr::SetStateEvent::print()
499 if (instr_fmt_type == instr_fmt_paje) {
500 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
501 stream << std::fixed << std::setprecision(TRACE_precision());
502 stream << (int)this->event_type;
503 print_timestamp(this);
504 stream << " " << type->id << " " << container->id;
505 stream << " " << val->id;
507 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
508 stream << " \"" << filename << "\" " << linenumber;
512 } else if (instr_fmt_type == instr_fmt_TI) {
519 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val,
522 this->event_type = PAJE_PushState;
523 this->timestamp = timestamp;
525 this->container = container;
527 this->extra_ = extra;
530 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
531 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
532 filename = loc->filename;
533 linenumber = loc->linenumber;
537 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
539 insert_into_buffer (this);
542 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val)
543 : PushStateEvent(timestamp, container, type, val, nullptr)
545 void simgrid::instr::PushStateEvent::print()
547 if (instr_fmt_type == instr_fmt_paje) {
548 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
549 stream << std::fixed << std::setprecision(TRACE_precision());
550 stream << (int)this->event_type;
551 print_timestamp(this);
552 stream << " " << type->id << " " << container->id;
553 stream << " " << val->id;
555 if (TRACE_display_sizes()) {
557 if (extra_ != nullptr) {
558 stream << static_cast<instr_extra_data>(extra_)->send_size;
564 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
565 stream << " \"" << filename << "\" " << linenumber;
570 if (extra_ != nullptr) {
571 if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
572 xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
573 if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
574 xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
577 } else if (instr_fmt_type == instr_fmt_TI) {
578 if (extra_ == nullptr)
580 instr_extra_data extra = (instr_extra_data)extra_;
582 char* process_id = nullptr;
583 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
584 if (strstr(container->name, "rank-") == nullptr)
585 process_id = xbt_strdup(container->name);
587 process_id = xbt_strdup(container->name + 5);
589 FILE* trace_file = (FILE*)xbt_dict_get(tracing_files, container->name);
591 switch (extra->type) {
593 fprintf(trace_file, "%s init\n", process_id);
595 case TRACING_FINALIZE:
596 fprintf(trace_file, "%s finalize\n", process_id);
599 fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
602 fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
605 fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
608 fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
611 fprintf(trace_file, "%s test\n", process_id);
614 fprintf(trace_file, "%s wait\n", process_id);
616 case TRACING_WAITALL:
617 fprintf(trace_file, "%s waitAll\n", process_id);
619 case TRACING_BARRIER:
620 fprintf(trace_file, "%s barrier\n", process_id);
622 case TRACING_BCAST: // rank bcast size (root) (datatype)
623 fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
624 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
625 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
626 fprintf(trace_file, "\n");
628 case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
629 fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
630 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
631 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
632 fprintf(trace_file, "\n");
634 case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
635 fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size,
638 case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
639 fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size,
640 extra->datatype1, extra->datatype2);
642 case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
643 fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
644 for (int i = 0; i < extra->num_processes; i++)
645 fprintf(trace_file, "%d ", extra->sendcounts[i]);
646 fprintf(trace_file, "%d ", extra->recv_size);
647 for (int i = 0; i < extra->num_processes; i++)
648 fprintf(trace_file, "%d ", extra->recvcounts[i]);
649 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
651 case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
652 fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
653 extra->datatype1, extra->datatype2);
655 case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
656 fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
657 for (int i = 0; i < extra->num_processes; i++)
658 fprintf(trace_file, "%d ", extra->recvcounts[i]);
659 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
661 case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
662 fprintf(trace_file, "%s reduceScatter ", process_id);
663 for (int i = 0; i < extra->num_processes; i++)
664 fprintf(trace_file, "%d ", extra->recvcounts[i]);
665 fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
667 case TRACING_COMPUTING:
668 fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
670 case TRACING_SLEEPING:
671 fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
673 case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
674 fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
675 for (int i = 0; i < extra->num_processes; i++)
676 fprintf(trace_file, "%d ", extra->recvcounts[i]);
677 fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
679 case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype)
680 fprintf(trace_file, "%s allGather %d %d %s %s", process_id, extra->send_size, extra->recv_size, extra->datatype1, extra->datatype2);
682 case TRACING_WAITANY:
683 case TRACING_SENDRECV:
684 case TRACING_SCATTER:
685 case TRACING_SCATTERV:
688 case TRACING_COMM_SIZE:
689 case TRACING_COMM_SPLIT:
690 case TRACING_COMM_DUP:
694 XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", val->name);
698 if (extra->recvcounts != nullptr)
699 xbt_free(extra->recvcounts);
700 if (extra->sendcounts != nullptr)
701 xbt_free(extra->sendcounts);
702 xbt_free(process_id);
710 simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type)
712 this->event_type = PAJE_PopState;
713 this->timestamp = timestamp;
715 this->container = container;
717 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
719 insert_into_buffer (this);
722 void simgrid::instr::PopStateEvent::print()
724 if (instr_fmt_type == instr_fmt_paje) {
725 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
726 stream << std::fixed << std::setprecision(TRACE_precision());
727 stream << (int)this->event_type;
728 print_timestamp(this);
729 stream << " " << type->id << " " << container->id;
731 } else if (instr_fmt_type == instr_fmt_TI) {
738 simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type)
740 this->event_type = PAJE_ResetState;
741 this->timestamp = timestamp;
743 this->container = container;
745 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
747 insert_into_buffer (this);
751 void simgrid::instr::ResetStateEvent::print()
753 if (instr_fmt_type == instr_fmt_paje) {
754 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
755 stream << std::fixed << std::setprecision(TRACE_precision());
756 stream << (int)this->event_type;
757 print_timestamp(this);
758 stream << " " << type->id << " " << container->id;
760 } else if (instr_fmt_type == instr_fmt_TI) {
767 simgrid::instr::StartLinkEvent::~StartLinkEvent()
772 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
773 container_t sourceContainer, const char* value, const char* key)
774 : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
777 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
778 container_t sourceContainer, const char* value, const char* key,
781 event_type = PAJE_StartLink;
782 this->timestamp = timestamp;
784 this->container = container;
785 this->sourceContainer = sourceContainer;
786 this->value = xbt_strdup(value);
787 this->key = xbt_strdup(key);
790 XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__,
791 (int)event_type, this->timestamp, this->value);
793 insert_into_buffer (this);
796 void simgrid::instr::StartLinkEvent::print()
798 if (instr_fmt_type == instr_fmt_paje) {
799 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
800 stream << std::fixed << std::setprecision(TRACE_precision());
801 stream << (int)this->event_type;
802 print_timestamp(this);
803 stream << " " << type->id << " " << container->id << " " << value;
804 stream << " " << sourceContainer->id << " " << key;
806 if (TRACE_display_sizes()) {
807 stream << " " << size;
810 } else if (instr_fmt_type == instr_fmt_TI) {
817 simgrid::instr::EndLinkEvent::EndLinkEvent(double timestamp, container_t container, Type* type,
818 container_t destContainer, const char* value, const char* key)
820 this->event_type = PAJE_EndLink;
821 this->timestamp = timestamp;
823 this->container = container;
824 this->destContainer = destContainer;
825 this->value = xbt_strdup(value);
826 this->key = xbt_strdup(key);
828 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
830 insert_into_buffer (this);
833 simgrid::instr::EndLinkEvent::~EndLinkEvent()
838 void simgrid::instr::EndLinkEvent::print()
840 if (instr_fmt_type == instr_fmt_paje) {
841 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
842 stream << std::fixed << std::setprecision(TRACE_precision());
843 stream << (int)this->event_type;
844 print_timestamp(this);
845 stream << " " << type->id << " " << container->id << " " << value;
846 stream << " " << destContainer->id << " " << key;
848 } else if (instr_fmt_type == instr_fmt_TI) {
855 simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val)
857 this->event_type = PAJE_NewEvent;
858 this->timestamp = timestamp;
860 this->container = container;
863 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
865 insert_into_buffer (this);
868 void simgrid::instr::NewEvent::print()
870 if (instr_fmt_type == instr_fmt_paje) {
871 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
872 stream << std::fixed << std::setprecision(TRACE_precision());
873 stream << (int)this->event_type;
874 print_timestamp(this);
875 stream << " " << type->id << " " << container->id << " " << val->id;
877 } else if (instr_fmt_type == instr_fmt_TI) {
885 void TRACE_TI_start()
887 char *filename = TRACE_get_filename();
888 tracing_file = fopen(filename, "w");
889 if (tracing_file == nullptr)
890 THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
892 XBT_DEBUG("Filename %s is open for writing", filename);
894 /* output one line comment */
895 dump_comment(TRACE_get_comment());
897 /* output comment file */
898 dump_comment_file(TRACE_get_comment_file());
903 xbt_dict_free(&tracing_files);
904 fclose(tracing_file);
905 char *filename = TRACE_get_filename();
906 XBT_DEBUG("Filename %s is closed", filename);