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 */
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system");
16 static std::stringstream stream;
17 FILE *tracing_file = nullptr;
19 std::map<container_t, FILE*> tracing_files; // TI specific
21 std::vector<simgrid::instr::PajeEvent*> buffer;
22 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
24 void dump_comment (const char *comment)
26 if (not strlen(comment))
28 fprintf (tracing_file, "# %s\n", comment);
31 void dump_comment_file (const char *filename)
33 if (not strlen(filename))
35 FILE *file = fopen (filename, "r");
37 THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
39 while (not feof(file)) {
42 if (feof(file)) break;
43 fprintf (tracing_file, "# ");
45 fprintf (tracing_file, "%c", c);
47 if (feof(file)) break;
49 fprintf (tracing_file, "\n");
54 double TRACE_last_timestamp_to_dump = 0;
55 //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
56 void TRACE_paje_dump_buffer(bool force)
58 if (not TRACE_is_enabled())
60 XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
62 for (auto const& event : buffer) {
68 std::vector<simgrid::instr::PajeEvent*>::iterator i = buffer.begin();
69 for (auto const& event : buffer) {
70 double head_timestamp = event->timestamp_;
71 if (head_timestamp > TRACE_last_timestamp_to_dump)
77 buffer.erase(buffer.begin(), i);
79 XBT_DEBUG("%s: ends", __FUNCTION__);
82 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
83 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf)
86 XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
87 for (auto const& event : *buf) {
89 XBT_DEBUG("%p %s", event, stream.str().c_str());
96 static void print_row() {
98 fprintf(tracing_file, "%s", stream.str().c_str());
99 XBT_DEBUG("Dump %s", stream.str().c_str());
104 static void print_timestamp(simgrid::instr::PajeEvent* event)
107 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
108 if (event->timestamp_ < 1e-12)
111 stream << event->timestamp_;
114 /* internal do the instrumentation module */
115 void simgrid::instr::PajeEvent::insertIntoBuffer()
117 if (not TRACE_buffer()) {
122 buffer_debug(&buffer);
124 XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, static_cast<int>(eventType_),
125 timestamp_, buffer.size());
126 std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
127 for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
128 simgrid::instr::PajeEvent* e1 = *i;
129 XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1, static_cast<int>(e1->eventType_), e1->timestamp_);
130 if (e1->timestamp_ <= timestamp_)
133 if (i == buffer.rend())
134 XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
135 else if (i == buffer.rbegin())
136 XBT_DEBUG("%s: inserted at end", __FUNCTION__);
138 XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__, std::distance(buffer.rbegin(), i));
139 buffer.insert(i.base(), this);
141 buffer_debug(&buffer);
144 simgrid::instr::PajeEvent::~PajeEvent()
146 XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)eventType_, timestamp_);
149 void TRACE_paje_start() {
150 char *filename = TRACE_get_filename();
151 tracing_file = fopen(filename, "w");
152 if (tracing_file == nullptr){
153 THROWF (system_error, 1, "Tracefile %s could not be opened for writing.", filename);
156 XBT_DEBUG("Filename %s is open for writing", filename);
158 /* output generator version */
159 fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n",
160 SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
161 fprintf (tracing_file, "#[");
164 xbt_dynar_foreach (xbt_cmdline, cpt, str){
165 fprintf(tracing_file, "%s ",str);
167 fprintf (tracing_file, "]\n");
169 /* output one line comment */
170 dump_comment (TRACE_get_comment());
172 /* output comment file */
173 dump_comment_file (TRACE_get_comment_file());
176 TRACE_header(TRACE_basic(),TRACE_display_sizes());
179 void TRACE_paje_end() {
180 fclose(tracing_file);
181 char *filename = TRACE_get_filename();
182 XBT_DEBUG("Filename %s is closed", filename);
185 void simgrid::instr::Type::logContainerTypeDefinition()
187 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType);
189 if (instr_fmt_type == instr_fmt_paje) {
190 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType,
191 TRACE_precision(), 0.);
192 stream << std::fixed << std::setprecision(TRACE_precision());
193 stream << simgrid::instr::PAJE_DefineContainerType;
194 stream << " " << id_ << " " << father_->getId() << " " << name_;
196 } else if (instr_fmt_type == instr_fmt_TI) {
203 void simgrid::instr::Type::logVariableTypeDefinition()
205 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType);
208 if (instr_fmt_type == instr_fmt_paje) {
209 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType,
210 TRACE_precision(), 0.);
211 stream << std::fixed << std::setprecision(TRACE_precision());
212 stream << simgrid::instr::PAJE_DefineVariableType;
213 stream << " " << id_ << " " << father_->getId() << " " << name_;
215 stream << " \"" << color_ << "\"";
217 } else if (instr_fmt_type == instr_fmt_TI) {
224 void simgrid::instr::Type::logStateTypeDefinition()
227 if (instr_fmt_type == instr_fmt_paje) {
228 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType,
229 TRACE_precision(), 0.);
230 stream << std::fixed << std::setprecision(TRACE_precision());
231 stream << simgrid::instr::PAJE_DefineStateType;
232 stream << " " << id_ << " " << father_->getId() << " " << name_;
234 } else if (instr_fmt_type == instr_fmt_TI) {
241 void simgrid::instr::Type::logDefineEventType()
244 if (instr_fmt_type == instr_fmt_paje) {
245 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType,
246 TRACE_precision(), 0.);
247 stream << std::fixed << std::setprecision(TRACE_precision());
248 stream << simgrid::instr::PAJE_DefineEventType;
249 stream << " " << id_ << " " << father_->getId() << " " << name_;
251 } else if (instr_fmt_type == instr_fmt_TI) {
258 void simgrid::instr::Type::logLinkTypeDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest)
260 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType);
262 if (instr_fmt_type == instr_fmt_paje) {
263 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(),
265 stream << std::fixed << std::setprecision(TRACE_precision());
266 stream << simgrid::instr::PAJE_DefineLinkType;
267 stream << " " << id_ << " " << father_->getId() << " " << source->getId() << " " << dest->getId() << " " << name_;
269 } else if (instr_fmt_type == instr_fmt_TI) {
276 void simgrid::instr::Value::print()
278 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
280 if (instr_fmt_type == instr_fmt_paje) {
281 stream << std::fixed << std::setprecision(TRACE_precision());
282 stream << simgrid::instr::PAJE_DefineEntityValue;
283 stream << " " << id_ << " " << father_->getId() << " " << name_;
285 stream << " \"" << color_ << "\"";
287 } else if (instr_fmt_type == instr_fmt_TI) {
295 simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value)
296 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetVariable), value(value)
298 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
302 void simgrid::instr::SetVariableEvent::print()
304 if (instr_fmt_type == instr_fmt_paje) {
305 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
306 stream << std::fixed << std::setprecision(TRACE_precision());
307 stream << (int)this->eventType_;
308 print_timestamp(this);
309 stream << " " << type->getId() << " " << container->id_ << " " << value;
311 } else if (instr_fmt_type == instr_fmt_TI) {
318 simgrid::instr::AddVariableEvent::AddVariableEvent(double timestamp, container_t container, simgrid::instr::Type* type,
320 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_AddVariable), value(value)
322 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
326 void simgrid::instr::AddVariableEvent::print()
328 if (instr_fmt_type == instr_fmt_paje) {
329 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
330 stream << std::fixed << std::setprecision(TRACE_precision());
331 stream << (int)this->eventType_;
332 print_timestamp(this);
333 stream << " " << type->getId() << " " << container->id_ << " " << value;
335 } else if (instr_fmt_type == instr_fmt_TI) {
342 simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value)
343 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SubVariable), value(value)
345 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
349 void simgrid::instr::SubVariableEvent::print()
351 if (instr_fmt_type == instr_fmt_paje) {
352 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
353 stream << std::fixed << std::setprecision(TRACE_precision());
354 stream << (int)this->eventType_;
355 print_timestamp(this);
356 stream << " " << type->getId() << " " << container->id_ << " " << value;
358 } else if (instr_fmt_type == instr_fmt_TI) {
365 simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* value)
366 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetState), value(value)
369 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
370 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
371 filename = loc->filename;
372 linenumber = loc->linenumber;
376 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
380 void simgrid::instr::SetStateEvent::print()
382 if (instr_fmt_type == instr_fmt_paje) {
383 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
384 stream << std::fixed << std::setprecision(TRACE_precision());
385 stream << (int)this->eventType_;
386 print_timestamp(this);
387 stream << " " << type->getId() << " " << container->id_;
388 stream << " " << value->getId();
390 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
391 stream << " \"" << filename << "\" " << linenumber;
395 } else if (instr_fmt_type == instr_fmt_TI) {
402 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* value,
404 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PushState), value(value), extra_(extra)
407 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
408 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
409 filename = loc->filename;
410 linenumber = loc->linenumber;
414 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
419 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val)
420 : PushStateEvent(timestamp, container, type, val, nullptr)
422 void simgrid::instr::PushStateEvent::print()
424 if (instr_fmt_type == instr_fmt_paje) {
425 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
426 stream << std::fixed << std::setprecision(TRACE_precision());
427 stream << (int)this->eventType_;
428 print_timestamp(this);
429 stream << " " << type->getId() << " " << container->id_;
430 stream << " " << value->getId();
432 if (TRACE_display_sizes()) {
434 if (extra_ != nullptr) {
435 stream << static_cast<instr_extra_data>(extra_)->send_size;
441 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
442 stream << " \"" << filename << "\" " << linenumber;
447 if (extra_ != nullptr) {
448 if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
449 xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
450 if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
451 xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
454 } else if (instr_fmt_type == instr_fmt_TI) {
455 if (extra_ == nullptr)
457 instr_extra_data extra = (instr_extra_data)extra_;
459 char* process_id = nullptr;
460 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
461 if (strstr(container->name_.c_str(), "rank-") == nullptr)
462 process_id = xbt_strdup(container->name_.c_str());
464 process_id = xbt_strdup(container->name_.c_str() + 5);
466 FILE* trace_file = tracing_files.at(container);
468 switch (extra->type) {
470 fprintf(trace_file, "%s init\n", process_id);
472 case TRACING_FINALIZE:
473 fprintf(trace_file, "%s finalize\n", process_id);
476 fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
479 fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
482 fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
485 fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
488 fprintf(trace_file, "%s test\n", process_id);
491 fprintf(trace_file, "%s wait\n", process_id);
493 case TRACING_WAITALL:
494 fprintf(trace_file, "%s waitAll\n", process_id);
496 case TRACING_BARRIER:
497 fprintf(trace_file, "%s barrier\n", process_id);
499 case TRACING_BCAST: // rank bcast size (root) (datatype)
500 fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
501 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
502 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
503 fprintf(trace_file, "\n");
505 case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
506 fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
507 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
508 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
509 fprintf(trace_file, "\n");
511 case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
512 fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size,
515 case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
516 fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size,
517 extra->datatype1, extra->datatype2);
519 case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
520 fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
521 for (int i = 0; i < extra->num_processes; i++)
522 fprintf(trace_file, "%d ", extra->sendcounts[i]);
523 fprintf(trace_file, "%d ", extra->recv_size);
524 for (int i = 0; i < extra->num_processes; i++)
525 fprintf(trace_file, "%d ", extra->recvcounts[i]);
526 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
528 case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
529 fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
530 extra->datatype1, extra->datatype2);
532 case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
533 fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
534 for (int i = 0; i < extra->num_processes; i++)
535 fprintf(trace_file, "%d ", extra->recvcounts[i]);
536 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
538 case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
539 fprintf(trace_file, "%s reduceScatter ", process_id);
540 for (int i = 0; i < extra->num_processes; i++)
541 fprintf(trace_file, "%d ", extra->recvcounts[i]);
542 fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
544 case TRACING_COMPUTING:
545 fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
547 case TRACING_SLEEPING:
548 fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
550 case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
551 fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
552 for (int i = 0; i < extra->num_processes; i++)
553 fprintf(trace_file, "%d ", extra->recvcounts[i]);
554 fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
556 case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype)
557 fprintf(trace_file, "%s allGather %d %d %s %s", process_id, extra->send_size, extra->recv_size,
558 extra->datatype1, extra->datatype2);
560 case TRACING_WAITANY:
561 case TRACING_SENDRECV:
562 case TRACING_SCATTER:
563 case TRACING_SCATTERV:
566 case TRACING_COMM_SIZE:
567 case TRACING_COMM_SPLIT:
568 case TRACING_COMM_DUP:
572 XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname());
576 if (extra->recvcounts != nullptr)
577 xbt_free(extra->recvcounts);
578 if (extra->sendcounts != nullptr)
579 xbt_free(extra->sendcounts);
580 xbt_free(process_id);
588 simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type)
589 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PopState)
591 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
595 void simgrid::instr::PopStateEvent::print()
597 if (instr_fmt_type == instr_fmt_paje) {
598 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
599 stream << std::fixed << std::setprecision(TRACE_precision());
600 stream << (int)this->eventType_;
601 print_timestamp(this);
602 stream << " " << type->getId() << " " << container->id_;
604 } else if (instr_fmt_type == instr_fmt_TI) {
611 simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type)
612 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_ResetState)
614 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
619 void simgrid::instr::ResetStateEvent::print()
621 if (instr_fmt_type == instr_fmt_paje) {
622 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
623 stream << std::fixed << std::setprecision(TRACE_precision());
624 stream << (int)this->eventType_;
625 print_timestamp(this);
626 stream << " " << type->getId() << " " << container->id_;
628 } else if (instr_fmt_type == instr_fmt_TI) {
635 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
636 container_t sourceContainer, std::string value, std::string key)
637 : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
640 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
641 container_t sourceContainer, std::string value, std::string key,
643 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_StartLink)
644 , sourceContainer_(sourceContainer)
649 XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value_.c_str());
653 void simgrid::instr::StartLinkEvent::print()
655 if (instr_fmt_type == instr_fmt_paje) {
656 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
657 stream << std::fixed << std::setprecision(TRACE_precision());
658 stream << (int)this->eventType_;
659 print_timestamp(this);
660 stream << " " << type->getId() << " " << container->id_ << " " << value_;
661 stream << " " << sourceContainer_->id_ << " " << key_;
663 if (TRACE_display_sizes()) {
664 stream << " " << size_;
667 } else if (instr_fmt_type == instr_fmt_TI) {
674 simgrid::instr::EndLinkEvent::EndLinkEvent(double timestamp, container_t container, Type* type,
675 container_t destContainer, std::string value, std::string key)
676 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_EndLink)
677 , destContainer(destContainer)
681 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
685 void simgrid::instr::EndLinkEvent::print()
687 if (instr_fmt_type == instr_fmt_paje) {
688 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
689 stream << std::fixed << std::setprecision(TRACE_precision());
690 stream << (int)this->eventType_;
691 print_timestamp(this);
692 stream << " " << type->getId() << " " << container->id_ << " " << value;
693 stream << " " << destContainer->id_ << " " << key;
695 } else if (instr_fmt_type == instr_fmt_TI) {
702 simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val)
703 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent)
707 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
712 void simgrid::instr::NewEvent::print()
714 if (instr_fmt_type == instr_fmt_paje) {
715 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
716 stream << std::fixed << std::setprecision(TRACE_precision());
717 stream << (int)this->eventType_;
718 print_timestamp(this);
719 stream << " " << type->getId() << " " << container->id_ << " " << val->getId();
721 } else if (instr_fmt_type == instr_fmt_TI) {
728 void TRACE_TI_start()
730 char *filename = TRACE_get_filename();
731 tracing_file = fopen(filename, "w");
732 if (tracing_file == nullptr)
733 THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
735 XBT_DEBUG("Filename %s is open for writing", filename);
737 /* output one line comment */
738 dump_comment(TRACE_get_comment());
740 /* output comment file */
741 dump_comment_file(TRACE_get_comment_file());
746 fclose(tracing_file);
747 char *filename = TRACE_get_filename();
748 XBT_DEBUG("Filename %s is closed", filename);