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 */
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system");
17 static std::stringstream stream;
18 FILE *tracing_file = nullptr;
20 std::map<container_t, FILE*> tracing_files; // TI specific
22 std::vector<simgrid::instr::PajeEvent*> buffer;
23 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
25 void dump_comment(std::string comment)
29 fprintf(tracing_file, "# %s\n", comment.c_str());
32 void dump_comment_file(std::string filename)
36 std::ifstream* fs = new std::ifstream();
37 fs->open(filename.c_str(), std::ifstream::in);
40 THROWF(system_error, 1, "Comment file %s could not be opened for reading.", filename.c_str());
42 while (not fs->eof()) {
44 fprintf (tracing_file, "# ");
45 std::getline(*fs, line);
46 fprintf(tracing_file, "%s", line.c_str());
51 double TRACE_last_timestamp_to_dump = 0;
52 //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
53 void TRACE_paje_dump_buffer(bool force)
55 if (not TRACE_is_enabled())
57 XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
59 for (auto const& event : buffer) {
65 std::vector<simgrid::instr::PajeEvent*>::iterator i = buffer.begin();
66 for (auto const& event : buffer) {
67 double head_timestamp = event->timestamp_;
68 if (head_timestamp > TRACE_last_timestamp_to_dump)
74 buffer.erase(buffer.begin(), i);
76 XBT_DEBUG("%s: ends", __FUNCTION__);
79 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
80 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf)
83 XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
84 for (auto const& event : *buf) {
86 XBT_DEBUG("%p %s", event, stream.str().c_str());
93 static void print_row() {
95 fprintf(tracing_file, "%s", stream.str().c_str());
96 XBT_DEBUG("Dump %s", stream.str().c_str());
101 static void print_timestamp(simgrid::instr::PajeEvent* event)
104 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
105 if (event->timestamp_ < 1e-12)
108 stream << event->timestamp_;
111 /* internal do the instrumentation module */
112 void simgrid::instr::PajeEvent::insertIntoBuffer()
114 if (not TRACE_buffer()) {
119 buffer_debug(&buffer);
121 XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, static_cast<int>(eventType_),
122 timestamp_, buffer.size());
123 std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
124 for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
125 simgrid::instr::PajeEvent* e1 = *i;
126 XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1, static_cast<int>(e1->eventType_), e1->timestamp_);
127 if (e1->timestamp_ <= timestamp_)
130 if (i == buffer.rend())
131 XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
132 else if (i == buffer.rbegin())
133 XBT_DEBUG("%s: inserted at end", __FUNCTION__);
135 XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__, std::distance(buffer.rbegin(), i));
136 buffer.insert(i.base(), this);
138 buffer_debug(&buffer);
141 simgrid::instr::PajeEvent::~PajeEvent()
143 XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)eventType_, timestamp_);
146 void TRACE_paje_start() {
147 char *filename = TRACE_get_filename();
148 tracing_file = fopen(filename, "w");
149 if (tracing_file == nullptr){
150 THROWF (system_error, 1, "Tracefile %s could not be opened for writing.", filename);
153 XBT_DEBUG("Filename %s is open for writing", filename);
155 /* output generator version */
156 fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n",
157 SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
158 fprintf (tracing_file, "#[");
161 xbt_dynar_foreach (xbt_cmdline, cpt, str){
162 fprintf(tracing_file, "%s ",str);
164 fprintf (tracing_file, "]\n");
166 /* output one line comment */
167 dump_comment (TRACE_get_comment());
169 /* output comment file */
170 dump_comment_file (TRACE_get_comment_file());
173 TRACE_header(TRACE_basic(),TRACE_display_sizes());
176 void TRACE_paje_end() {
177 fclose(tracing_file);
178 char *filename = TRACE_get_filename();
179 XBT_DEBUG("Filename %s is closed", filename);
182 void simgrid::instr::Type::logContainerTypeDefinition()
184 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType);
186 if (instr_fmt_type == instr_fmt_paje) {
187 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType,
188 TRACE_precision(), 0.);
189 stream << std::fixed << std::setprecision(TRACE_precision());
190 stream << simgrid::instr::PAJE_DefineContainerType;
191 stream << " " << id_ << " " << father_->getId() << " " << name_;
193 } else if (instr_fmt_type == instr_fmt_TI) {
200 void simgrid::instr::Type::logVariableTypeDefinition()
202 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType);
205 if (instr_fmt_type == instr_fmt_paje) {
206 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType,
207 TRACE_precision(), 0.);
208 stream << std::fixed << std::setprecision(TRACE_precision());
209 stream << simgrid::instr::PAJE_DefineVariableType;
210 stream << " " << id_ << " " << father_->getId() << " " << name_;
212 stream << " \"" << color_ << "\"";
214 } else if (instr_fmt_type == instr_fmt_TI) {
221 void simgrid::instr::Type::logStateTypeDefinition()
224 if (instr_fmt_type == instr_fmt_paje) {
225 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType,
226 TRACE_precision(), 0.);
227 stream << std::fixed << std::setprecision(TRACE_precision());
228 stream << simgrid::instr::PAJE_DefineStateType;
229 stream << " " << id_ << " " << father_->getId() << " " << name_;
231 } else if (instr_fmt_type == instr_fmt_TI) {
238 void simgrid::instr::Type::logDefineEventType()
241 if (instr_fmt_type == instr_fmt_paje) {
242 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType,
243 TRACE_precision(), 0.);
244 stream << std::fixed << std::setprecision(TRACE_precision());
245 stream << simgrid::instr::PAJE_DefineEventType;
246 stream << " " << id_ << " " << father_->getId() << " " << name_;
248 } else if (instr_fmt_type == instr_fmt_TI) {
255 void simgrid::instr::Type::logLinkTypeDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest)
257 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType);
259 if (instr_fmt_type == instr_fmt_paje) {
260 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(),
262 stream << std::fixed << std::setprecision(TRACE_precision());
263 stream << simgrid::instr::PAJE_DefineLinkType;
264 stream << " " << id_ << " " << father_->getId() << " " << source->getId() << " " << dest->getId() << " " << name_;
266 } else if (instr_fmt_type == instr_fmt_TI) {
273 void simgrid::instr::Value::print()
275 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
277 if (instr_fmt_type == instr_fmt_paje) {
278 stream << std::fixed << std::setprecision(TRACE_precision());
279 stream << simgrid::instr::PAJE_DefineEntityValue;
280 stream << " " << id_ << " " << father_->getId() << " " << name_;
282 stream << " \"" << color_ << "\"";
284 } else if (instr_fmt_type == instr_fmt_TI) {
292 simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value)
293 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetVariable), value(value)
295 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
299 void simgrid::instr::SetVariableEvent::print()
301 if (instr_fmt_type == instr_fmt_paje) {
302 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
303 stream << std::fixed << std::setprecision(TRACE_precision());
304 stream << (int)this->eventType_;
305 print_timestamp(this);
306 stream << " " << type->getId() << " " << container->id_ << " " << value;
308 } else if (instr_fmt_type == instr_fmt_TI) {
315 simgrid::instr::AddVariableEvent::AddVariableEvent(double timestamp, container_t container, simgrid::instr::Type* type,
317 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_AddVariable), value(value)
319 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
323 void simgrid::instr::AddVariableEvent::print()
325 if (instr_fmt_type == instr_fmt_paje) {
326 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
327 stream << std::fixed << std::setprecision(TRACE_precision());
328 stream << (int)this->eventType_;
329 print_timestamp(this);
330 stream << " " << type->getId() << " " << container->id_ << " " << value;
332 } else if (instr_fmt_type == instr_fmt_TI) {
339 simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value)
340 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SubVariable), value(value)
342 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
346 void simgrid::instr::SubVariableEvent::print()
348 if (instr_fmt_type == instr_fmt_paje) {
349 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
350 stream << std::fixed << std::setprecision(TRACE_precision());
351 stream << (int)this->eventType_;
352 print_timestamp(this);
353 stream << " " << type->getId() << " " << container->id_ << " " << value;
355 } else if (instr_fmt_type == instr_fmt_TI) {
362 simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* value)
363 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetState), value(value)
366 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
367 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
368 filename = loc->filename;
369 linenumber = loc->linenumber;
373 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
377 void simgrid::instr::SetStateEvent::print()
379 if (instr_fmt_type == instr_fmt_paje) {
380 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
381 stream << std::fixed << std::setprecision(TRACE_precision());
382 stream << (int)this->eventType_;
383 print_timestamp(this);
384 stream << " " << type->getId() << " " << container->id_;
385 stream << " " << value->getId();
387 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
388 stream << " \"" << filename << "\" " << linenumber;
392 } else if (instr_fmt_type == instr_fmt_TI) {
399 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* value,
401 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PushState), value(value), extra_(extra)
404 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
405 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
406 filename = loc->filename;
407 linenumber = loc->linenumber;
411 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
416 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val)
417 : PushStateEvent(timestamp, container, type, val, nullptr)
419 void simgrid::instr::PushStateEvent::print()
421 if (instr_fmt_type == instr_fmt_paje) {
422 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
423 stream << std::fixed << std::setprecision(TRACE_precision());
424 stream << (int)this->eventType_;
425 print_timestamp(this);
426 stream << " " << type->getId() << " " << container->id_;
427 stream << " " << value->getId();
429 if (TRACE_display_sizes()) {
431 if (extra_ != nullptr) {
432 stream << static_cast<instr_extra_data>(extra_)->send_size;
438 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
439 stream << " \"" << filename << "\" " << linenumber;
444 if (extra_ != nullptr) {
445 if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
446 xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
447 if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
448 xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
451 } else if (instr_fmt_type == instr_fmt_TI) {
452 if (extra_ == nullptr)
454 instr_extra_data extra = (instr_extra_data)extra_;
456 char* process_id = nullptr;
457 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
458 if (strstr(container->name_.c_str(), "rank-") == nullptr)
459 process_id = xbt_strdup(container->name_.c_str());
461 process_id = xbt_strdup(container->name_.c_str() + 5);
463 FILE* trace_file = tracing_files.at(container);
465 switch (extra->type) {
467 fprintf(trace_file, "%s init\n", process_id);
469 case TRACING_FINALIZE:
470 fprintf(trace_file, "%s finalize\n", process_id);
473 fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
476 fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
479 fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
482 fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
485 fprintf(trace_file, "%s test\n", process_id);
488 fprintf(trace_file, "%s wait\n", process_id);
490 case TRACING_WAITALL:
491 fprintf(trace_file, "%s waitAll\n", process_id);
493 case TRACING_BARRIER:
494 fprintf(trace_file, "%s barrier\n", process_id);
496 case TRACING_BCAST: // rank bcast size (root) (datatype)
497 fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
498 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
499 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
500 fprintf(trace_file, "\n");
502 case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
503 fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
504 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
505 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
506 fprintf(trace_file, "\n");
508 case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
509 fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size,
512 case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
513 fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size,
514 extra->datatype1, extra->datatype2);
516 case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
517 fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
518 for (int i = 0; i < extra->num_processes; i++)
519 fprintf(trace_file, "%d ", extra->sendcounts[i]);
520 fprintf(trace_file, "%d ", extra->recv_size);
521 for (int i = 0; i < extra->num_processes; i++)
522 fprintf(trace_file, "%d ", extra->recvcounts[i]);
523 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
525 case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
526 fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
527 extra->datatype1, extra->datatype2);
529 case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
530 fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
531 for (int i = 0; i < extra->num_processes; i++)
532 fprintf(trace_file, "%d ", extra->recvcounts[i]);
533 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
535 case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
536 fprintf(trace_file, "%s reduceScatter ", process_id);
537 for (int i = 0; i < extra->num_processes; i++)
538 fprintf(trace_file, "%d ", extra->recvcounts[i]);
539 fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
541 case TRACING_COMPUTING:
542 fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
544 case TRACING_SLEEPING:
545 fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
547 case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
548 fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
549 for (int i = 0; i < extra->num_processes; i++)
550 fprintf(trace_file, "%d ", extra->recvcounts[i]);
551 fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
553 case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype)
554 fprintf(trace_file, "%s allGather %d %d %s %s", process_id, extra->send_size, extra->recv_size,
555 extra->datatype1, extra->datatype2);
557 case TRACING_WAITANY:
558 case TRACING_SENDRECV:
559 case TRACING_SCATTER:
560 case TRACING_SCATTERV:
563 case TRACING_COMM_SIZE:
564 case TRACING_COMM_SPLIT:
565 case TRACING_COMM_DUP:
569 XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname());
573 if (extra->recvcounts != nullptr)
574 xbt_free(extra->recvcounts);
575 if (extra->sendcounts != nullptr)
576 xbt_free(extra->sendcounts);
577 xbt_free(process_id);
585 simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type)
586 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PopState)
588 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
592 void simgrid::instr::PopStateEvent::print()
594 if (instr_fmt_type == instr_fmt_paje) {
595 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
596 stream << std::fixed << std::setprecision(TRACE_precision());
597 stream << (int)this->eventType_;
598 print_timestamp(this);
599 stream << " " << type->getId() << " " << container->id_;
601 } else if (instr_fmt_type == instr_fmt_TI) {
608 simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type)
609 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_ResetState)
611 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
616 void simgrid::instr::ResetStateEvent::print()
618 if (instr_fmt_type == instr_fmt_paje) {
619 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
620 stream << std::fixed << std::setprecision(TRACE_precision());
621 stream << (int)this->eventType_;
622 print_timestamp(this);
623 stream << " " << type->getId() << " " << container->id_;
625 } else if (instr_fmt_type == instr_fmt_TI) {
632 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
633 container_t sourceContainer, std::string value, std::string key)
634 : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
637 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
638 container_t sourceContainer, std::string value, std::string key,
640 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_StartLink)
641 , sourceContainer_(sourceContainer)
646 XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value_.c_str());
650 void simgrid::instr::StartLinkEvent::print()
652 if (instr_fmt_type == instr_fmt_paje) {
653 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
654 stream << std::fixed << std::setprecision(TRACE_precision());
655 stream << (int)this->eventType_;
656 print_timestamp(this);
657 stream << " " << type->getId() << " " << container->id_ << " " << value_;
658 stream << " " << sourceContainer_->id_ << " " << key_;
660 if (TRACE_display_sizes()) {
661 stream << " " << size_;
664 } else if (instr_fmt_type == instr_fmt_TI) {
671 simgrid::instr::EndLinkEvent::EndLinkEvent(double timestamp, container_t container, Type* type,
672 container_t destContainer, std::string value, std::string key)
673 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_EndLink)
674 , destContainer(destContainer)
678 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
682 void simgrid::instr::EndLinkEvent::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->getId() << " " << container->id_ << " " << value;
690 stream << " " << destContainer->id_ << " " << key;
692 } else if (instr_fmt_type == instr_fmt_TI) {
699 simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val)
700 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent)
704 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
709 void simgrid::instr::NewEvent::print()
711 if (instr_fmt_type == instr_fmt_paje) {
712 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
713 stream << std::fixed << std::setprecision(TRACE_precision());
714 stream << (int)this->eventType_;
715 print_timestamp(this);
716 stream << " " << type->getId() << " " << container->id_ << " " << val->getId();
718 } else if (instr_fmt_type == instr_fmt_TI) {
725 void TRACE_TI_start()
727 char *filename = TRACE_get_filename();
728 tracing_file = fopen(filename, "w");
729 if (tracing_file == nullptr)
730 THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
732 XBT_DEBUG("Filename %s is open for writing", filename);
734 /* output one line comment */
735 dump_comment(TRACE_get_comment());
737 /* output comment file */
738 dump_comment_file(TRACE_get_comment_file());
743 fclose(tracing_file);
744 char *filename = TRACE_get_filename();
745 XBT_DEBUG("Filename %s is closed", filename);