1 /* Copyright (c) 2010-2017. 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 "simgrid/sg_config.h"
8 #include "src/instr/instr_private.hpp"
9 #include "src/instr/instr_smpi.hpp"
10 #include "src/smpi/include/private.hpp"
12 #include "xbt/virtu.h" /* sg_cmdline */
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 std::map<container_t, FILE*> tracing_files; // 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 void simgrid::instr::PajeEvent::insertIntoBuffer()
126 if (not TRACE_buffer()) {
131 buffer_debug(&buffer);
133 XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, static_cast<int>(eventType_),
134 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, static_cast<int>(e1->eventType_), e1->timestamp_);
139 if (e1->timestamp_ <= timestamp_)
142 if (i == buffer.rend())
143 XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
144 else if (i == buffer.rbegin())
145 XBT_DEBUG("%s: inserted at end", __FUNCTION__);
147 XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__, std::distance(buffer.rbegin(), i));
148 buffer.insert(i.base(), this);
150 buffer_debug(&buffer);
153 simgrid::instr::PajeEvent::~PajeEvent()
155 XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)eventType_, timestamp_);
158 void TRACE_paje_start() {
159 char *filename = TRACE_get_filename();
160 tracing_file = fopen(filename, "w");
161 if (tracing_file == nullptr){
162 THROWF (system_error, 1, "Tracefile %s could not be opened for writing.", filename);
165 XBT_DEBUG("Filename %s is open for writing", filename);
167 /* output generator version */
168 fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n",
169 SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
170 fprintf (tracing_file, "#[");
173 xbt_dynar_foreach (xbt_cmdline, cpt, str){
174 fprintf(tracing_file, "%s ",str);
176 fprintf (tracing_file, "]\n");
178 /* output one line comment */
179 dump_comment (TRACE_get_comment());
181 /* output comment file */
182 dump_comment_file (TRACE_get_comment_file());
185 TRACE_header(TRACE_basic(),TRACE_display_sizes());
188 void TRACE_paje_end() {
189 fclose(tracing_file);
190 char *filename = TRACE_get_filename();
191 XBT_DEBUG("Filename %s is closed", filename);
194 void LogContainerTypeDefinition(simgrid::instr::Type* type)
196 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType);
198 if (instr_fmt_type == instr_fmt_paje) {
199 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType,
200 TRACE_precision(), 0.);
201 stream << std::fixed << std::setprecision(TRACE_precision());
202 stream << simgrid::instr::PAJE_DefineContainerType;
203 stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
205 } else if (instr_fmt_type == instr_fmt_TI) {
212 void LogVariableTypeDefinition(simgrid::instr::Type* type)
214 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType);
217 if (instr_fmt_type == instr_fmt_paje) {
218 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType,
219 TRACE_precision(), 0.);
220 stream << std::fixed << std::setprecision(TRACE_precision());
221 stream << simgrid::instr::PAJE_DefineVariableType;
222 stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
223 if (type->isColored())
224 stream << " \"" << type->color_ << "\"";
226 } else if (instr_fmt_type == instr_fmt_TI) {
233 void LogStateTypeDefinition(simgrid::instr::Type* type)
236 if (instr_fmt_type == instr_fmt_paje) {
237 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, TRACE_precision(),
239 stream << std::fixed << std::setprecision(TRACE_precision());
240 stream << simgrid::instr::PAJE_DefineStateType;
241 stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
243 } else if (instr_fmt_type == instr_fmt_TI) {
250 void LogDefineEventType(simgrid::instr::Type* type)
253 if (instr_fmt_type == instr_fmt_paje) {
254 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType,
255 TRACE_precision(), 0.);
256 stream << std::fixed << std::setprecision(TRACE_precision());
257 stream << simgrid::instr::PAJE_DefineEventType;
258 stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
260 } else if (instr_fmt_type == instr_fmt_TI) {
267 void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest)
269 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType);
271 if (instr_fmt_type == instr_fmt_paje) {
272 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(),
274 stream << std::fixed << std::setprecision(TRACE_precision());
275 stream << simgrid::instr::PAJE_DefineLinkType;
276 stream << " " << type->id_ << " " << type->father_->id_ << " " << source->id_ << " " << dest->id_ << " "
279 } else if (instr_fmt_type == instr_fmt_TI) {
286 void simgrid::instr::Value::print()
288 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
290 if (instr_fmt_type == instr_fmt_paje) {
291 stream << std::fixed << std::setprecision(TRACE_precision());
292 stream << simgrid::instr::PAJE_DefineEntityValue;
293 stream << " " << id_ << " " << father_->id_ << " " << name_;
295 stream << " \"" << color_ << "\"";
297 } else if (instr_fmt_type == instr_fmt_TI) {
304 void LogContainerCreation (container_t container)
306 double timestamp = SIMIX_get_clock();
308 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp);
310 if (instr_fmt_type == instr_fmt_paje) {
311 stream << std::fixed << std::setprecision(TRACE_precision());
312 stream << simgrid::instr::PAJE_CreateContainer;
314 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
315 if (timestamp < 1e-12)
319 stream << " " << container->id_ << " " << container->type_->id_ << " " << container->father_->id_ << " \""
320 << container->name_ << "\"";
323 } else if (instr_fmt_type == instr_fmt_TI) {
324 // if we are in the mode with only one file
325 static FILE* ti_unique_file = nullptr;
327 if (tracing_files.empty()) {
328 // generate unique run id with time
329 prefix = xbt_os_time();
332 if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
333 char* folder_name = bprintf("%s_files", TRACE_get_filename());
334 char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name_.c_str());
338 mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO);
340 ti_unique_file = fopen(filename, "w");
341 xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno));
342 fprintf(tracing_file, "%s\n", filename);
344 xbt_free(folder_name);
348 tracing_files.insert({container, ti_unique_file});
354 void LogContainerDestruction(container_t container)
356 double timestamp = SIMIX_get_clock();
358 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp);
360 if (instr_fmt_type == instr_fmt_paje) {
361 stream << std::fixed << std::setprecision(TRACE_precision());
362 stream << simgrid::instr::PAJE_DestroyContainer;
364 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
365 if (timestamp < 1e-12)
369 stream << " " << container->type_->id_ << " " << container->id_;
371 } else if (instr_fmt_type == instr_fmt_TI) {
372 if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || tracing_files.size() == 1) {
373 FILE* f = tracing_files.at(container);
376 tracing_files.erase(container);
382 simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value)
383 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetVariable), value(value)
385 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
389 void simgrid::instr::SetVariableEvent::print()
391 if (instr_fmt_type == instr_fmt_paje) {
392 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
393 stream << std::fixed << std::setprecision(TRACE_precision());
394 stream << (int)this->eventType_;
395 print_timestamp(this);
396 stream << " " << type->id_ << " " << container->id_ << " " << value;
398 } else if (instr_fmt_type == instr_fmt_TI) {
405 simgrid::instr::AddVariableEvent::AddVariableEvent(double timestamp, container_t container, simgrid::instr::Type* type,
407 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_AddVariable), value(value)
409 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
413 void simgrid::instr::AddVariableEvent::print()
415 if (instr_fmt_type == instr_fmt_paje) {
416 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
417 stream << std::fixed << std::setprecision(TRACE_precision());
418 stream << (int)this->eventType_;
419 print_timestamp(this);
420 stream << " " << type->id_ << " " << container->id_ << " " << value;
422 } else if (instr_fmt_type == instr_fmt_TI) {
429 simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value)
430 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SubVariable), value(value)
432 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
436 void simgrid::instr::SubVariableEvent::print()
438 if (instr_fmt_type == instr_fmt_paje) {
439 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
440 stream << std::fixed << std::setprecision(TRACE_precision());
441 stream << (int)this->eventType_;
442 print_timestamp(this);
443 stream << " " << type->id_ << " " << container->id_ << " " << value;
445 } else if (instr_fmt_type == instr_fmt_TI) {
452 simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* value)
453 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetState), value(value)
456 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
457 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
458 filename = loc->filename;
459 linenumber = loc->linenumber;
463 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
467 void simgrid::instr::SetStateEvent::print()
469 if (instr_fmt_type == instr_fmt_paje) {
470 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
471 stream << std::fixed << std::setprecision(TRACE_precision());
472 stream << (int)this->eventType_;
473 print_timestamp(this);
474 stream << " " << type->id_ << " " << container->id_;
475 stream << " " << value->getId();
477 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
478 stream << " \"" << filename << "\" " << linenumber;
482 } else if (instr_fmt_type == instr_fmt_TI) {
489 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* value,
491 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PushState), value(value), extra_(extra)
494 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
495 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
496 filename = loc->filename;
497 linenumber = loc->linenumber;
501 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
506 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val)
507 : PushStateEvent(timestamp, container, type, val, nullptr)
509 void simgrid::instr::PushStateEvent::print()
511 if (instr_fmt_type == instr_fmt_paje) {
512 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
513 stream << std::fixed << std::setprecision(TRACE_precision());
514 stream << (int)this->eventType_;
515 print_timestamp(this);
516 stream << " " << type->id_ << " " << container->id_;
517 stream << " " << value->getId();
519 if (TRACE_display_sizes()) {
521 if (extra_ != nullptr) {
522 stream << static_cast<instr_extra_data>(extra_)->send_size;
528 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
529 stream << " \"" << filename << "\" " << linenumber;
534 if (extra_ != nullptr) {
535 if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
536 xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
537 if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
538 xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
541 } else if (instr_fmt_type == instr_fmt_TI) {
542 if (extra_ == nullptr)
544 instr_extra_data extra = (instr_extra_data)extra_;
546 char* process_id = nullptr;
547 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
548 if (strstr(container->name_.c_str(), "rank-") == nullptr)
549 process_id = xbt_strdup(container->name_.c_str());
551 process_id = xbt_strdup(container->name_.c_str() + 5);
553 FILE* trace_file = tracing_files.at(container);
555 switch (extra->type) {
557 fprintf(trace_file, "%s init\n", process_id);
559 case TRACING_FINALIZE:
560 fprintf(trace_file, "%s finalize\n", process_id);
563 fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
566 fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
569 fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
572 fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
575 fprintf(trace_file, "%s test\n", process_id);
578 fprintf(trace_file, "%s wait\n", process_id);
580 case TRACING_WAITALL:
581 fprintf(trace_file, "%s waitAll\n", process_id);
583 case TRACING_BARRIER:
584 fprintf(trace_file, "%s barrier\n", process_id);
586 case TRACING_BCAST: // rank bcast size (root) (datatype)
587 fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
588 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
589 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
590 fprintf(trace_file, "\n");
592 case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
593 fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
594 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
595 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
596 fprintf(trace_file, "\n");
598 case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
599 fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size,
602 case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
603 fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size,
604 extra->datatype1, extra->datatype2);
606 case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
607 fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
608 for (int i = 0; i < extra->num_processes; i++)
609 fprintf(trace_file, "%d ", extra->sendcounts[i]);
610 fprintf(trace_file, "%d ", extra->recv_size);
611 for (int i = 0; i < extra->num_processes; i++)
612 fprintf(trace_file, "%d ", extra->recvcounts[i]);
613 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
615 case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
616 fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
617 extra->datatype1, extra->datatype2);
619 case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
620 fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
621 for (int i = 0; i < extra->num_processes; i++)
622 fprintf(trace_file, "%d ", extra->recvcounts[i]);
623 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
625 case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
626 fprintf(trace_file, "%s reduceScatter ", process_id);
627 for (int i = 0; i < extra->num_processes; i++)
628 fprintf(trace_file, "%d ", extra->recvcounts[i]);
629 fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
631 case TRACING_COMPUTING:
632 fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
634 case TRACING_SLEEPING:
635 fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
637 case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
638 fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
639 for (int i = 0; i < extra->num_processes; i++)
640 fprintf(trace_file, "%d ", extra->recvcounts[i]);
641 fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
643 case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype)
644 fprintf(trace_file, "%s allGather %d %d %s %s", process_id, extra->send_size, extra->recv_size,
645 extra->datatype1, extra->datatype2);
647 case TRACING_WAITANY:
648 case TRACING_SENDRECV:
649 case TRACING_SCATTER:
650 case TRACING_SCATTERV:
653 case TRACING_COMM_SIZE:
654 case TRACING_COMM_SPLIT:
655 case TRACING_COMM_DUP:
659 XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname());
663 if (extra->recvcounts != nullptr)
664 xbt_free(extra->recvcounts);
665 if (extra->sendcounts != nullptr)
666 xbt_free(extra->sendcounts);
667 xbt_free(process_id);
675 simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type)
676 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PopState)
678 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
682 void simgrid::instr::PopStateEvent::print()
684 if (instr_fmt_type == instr_fmt_paje) {
685 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
686 stream << std::fixed << std::setprecision(TRACE_precision());
687 stream << (int)this->eventType_;
688 print_timestamp(this);
689 stream << " " << type->id_ << " " << container->id_;
691 } else if (instr_fmt_type == instr_fmt_TI) {
698 simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type)
699 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_ResetState)
701 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
706 void simgrid::instr::ResetStateEvent::print()
708 if (instr_fmt_type == instr_fmt_paje) {
709 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
710 stream << std::fixed << std::setprecision(TRACE_precision());
711 stream << (int)this->eventType_;
712 print_timestamp(this);
713 stream << " " << type->id_ << " " << container->id_;
715 } else if (instr_fmt_type == instr_fmt_TI) {
722 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
723 container_t sourceContainer, std::string value, std::string key)
724 : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
727 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
728 container_t sourceContainer, std::string value, std::string key,
730 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_StartLink)
731 , sourceContainer_(sourceContainer)
736 XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value_.c_str());
740 void simgrid::instr::StartLinkEvent::print()
742 if (instr_fmt_type == instr_fmt_paje) {
743 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
744 stream << std::fixed << std::setprecision(TRACE_precision());
745 stream << (int)this->eventType_;
746 print_timestamp(this);
747 stream << " " << type->id_ << " " << container->id_ << " " << value_;
748 stream << " " << sourceContainer_->id_ << " " << key_;
750 if (TRACE_display_sizes()) {
751 stream << " " << size_;
754 } else if (instr_fmt_type == instr_fmt_TI) {
761 simgrid::instr::EndLinkEvent::EndLinkEvent(double timestamp, container_t container, Type* type,
762 container_t destContainer, std::string value, std::string key)
763 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_EndLink)
764 , destContainer(destContainer)
768 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
772 void simgrid::instr::EndLinkEvent::print()
774 if (instr_fmt_type == instr_fmt_paje) {
775 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
776 stream << std::fixed << std::setprecision(TRACE_precision());
777 stream << (int)this->eventType_;
778 print_timestamp(this);
779 stream << " " << type->id_ << " " << container->id_ << " " << value;
780 stream << " " << destContainer->id_ << " " << key;
782 } else if (instr_fmt_type == instr_fmt_TI) {
789 simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val)
790 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent)
794 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
799 void simgrid::instr::NewEvent::print()
801 if (instr_fmt_type == instr_fmt_paje) {
802 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
803 stream << std::fixed << std::setprecision(TRACE_precision());
804 stream << (int)this->eventType_;
805 print_timestamp(this);
806 stream << " " << type->id_ << " " << container->id_ << " " << val->getId();
808 } else if (instr_fmt_type == instr_fmt_TI) {
815 void TRACE_TI_start()
817 char *filename = TRACE_get_filename();
818 tracing_file = fopen(filename, "w");
819 if (tracing_file == nullptr)
820 THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
822 XBT_DEBUG("Filename %s is open for writing", filename);
824 /* output one line comment */
825 dump_comment(TRACE_get_comment());
827 /* output comment file */
828 dump_comment_file(TRACE_get_comment_file());
833 fclose(tracing_file);
834 char *filename = TRACE_get_filename();
835 XBT_DEBUG("Filename %s is closed", filename);