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 **/
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system");
20 static std::stringstream stream;
21 FILE *tracing_file = nullptr;
23 std::map<container_t, FILE*> tracing_files; // TI specific
25 std::vector<simgrid::instr::PajeEvent*> buffer;
26 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
28 void dump_comment (const char *comment)
30 if (not strlen(comment))
32 fprintf (tracing_file, "# %s\n", comment);
35 void dump_comment_file (const char *filename)
37 if (not strlen(filename))
39 FILE *file = fopen (filename, "r");
41 THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
43 while (not feof(file)) {
46 if (feof(file)) break;
47 fprintf (tracing_file, "# ");
49 fprintf (tracing_file, "%c", c);
51 if (feof(file)) break;
53 fprintf (tracing_file, "\n");
58 double TRACE_last_timestamp_to_dump = 0;
59 //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
60 void TRACE_paje_dump_buffer (int force)
62 if (not TRACE_is_enabled())
64 XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
66 for (auto const& event : buffer) {
72 std::vector<simgrid::instr::PajeEvent*>::iterator i = buffer.begin();
73 for (auto const& event : buffer) {
74 double head_timestamp = event->timestamp_;
75 if (head_timestamp > TRACE_last_timestamp_to_dump)
81 buffer.erase(buffer.begin(), i);
83 XBT_DEBUG("%s: ends", __FUNCTION__);
86 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf);
87 void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf)
90 XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
91 for (auto const& event : *buf) {
93 XBT_DEBUG("%p %s", event, stream.str().c_str());
100 static void print_row() {
102 fprintf(tracing_file, "%s", stream.str().c_str());
103 XBT_DEBUG("Dump %s", stream.str().c_str());
108 static void print_timestamp(simgrid::instr::PajeEvent* event)
111 /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
112 if (event->timestamp_ < 1e-12)
115 stream << event->timestamp_;
118 /* internal do the instrumentation module */
119 void simgrid::instr::PajeEvent::insertIntoBuffer()
121 if (not TRACE_buffer()) {
126 buffer_debug(&buffer);
128 XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, static_cast<int>(eventType_),
129 timestamp_, buffer.size());
130 std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
131 for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
132 simgrid::instr::PajeEvent* e1 = *i;
133 XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1, static_cast<int>(e1->eventType_), e1->timestamp_);
134 if (e1->timestamp_ <= timestamp_)
137 if (i == buffer.rend())
138 XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
139 else if (i == buffer.rbegin())
140 XBT_DEBUG("%s: inserted at end", __FUNCTION__);
142 XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__, std::distance(buffer.rbegin(), i));
143 buffer.insert(i.base(), this);
145 buffer_debug(&buffer);
148 simgrid::instr::PajeEvent::~PajeEvent()
150 XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)eventType_, timestamp_);
153 void TRACE_paje_start() {
154 char *filename = TRACE_get_filename();
155 tracing_file = fopen(filename, "w");
156 if (tracing_file == nullptr){
157 THROWF (system_error, 1, "Tracefile %s could not be opened for writing.", filename);
160 XBT_DEBUG("Filename %s is open for writing", filename);
162 /* output generator version */
163 fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n",
164 SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
165 fprintf (tracing_file, "#[");
168 xbt_dynar_foreach (xbt_cmdline, cpt, str){
169 fprintf(tracing_file, "%s ",str);
171 fprintf (tracing_file, "]\n");
173 /* output one line comment */
174 dump_comment (TRACE_get_comment());
176 /* output comment file */
177 dump_comment_file (TRACE_get_comment_file());
180 TRACE_header(TRACE_basic(),TRACE_display_sizes());
183 void TRACE_paje_end() {
184 fclose(tracing_file);
185 char *filename = TRACE_get_filename();
186 XBT_DEBUG("Filename %s is closed", filename);
189 void LogContainerTypeDefinition(simgrid::instr::Type* type)
191 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType);
193 if (instr_fmt_type == instr_fmt_paje) {
194 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType,
195 TRACE_precision(), 0.);
196 stream << std::fixed << std::setprecision(TRACE_precision());
197 stream << simgrid::instr::PAJE_DefineContainerType;
198 stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
200 } else if (instr_fmt_type == instr_fmt_TI) {
207 void LogVariableTypeDefinition(simgrid::instr::Type* type)
209 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType);
212 if (instr_fmt_type == instr_fmt_paje) {
213 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType,
214 TRACE_precision(), 0.);
215 stream << std::fixed << std::setprecision(TRACE_precision());
216 stream << simgrid::instr::PAJE_DefineVariableType;
217 stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
218 if (type->isColored())
219 stream << " \"" << type->color_ << "\"";
221 } else if (instr_fmt_type == instr_fmt_TI) {
228 void LogStateTypeDefinition(simgrid::instr::Type* type)
231 if (instr_fmt_type == instr_fmt_paje) {
232 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, TRACE_precision(),
234 stream << std::fixed << std::setprecision(TRACE_precision());
235 stream << simgrid::instr::PAJE_DefineStateType;
236 stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
238 } else if (instr_fmt_type == instr_fmt_TI) {
245 void LogDefineEventType(simgrid::instr::Type* type)
248 if (instr_fmt_type == instr_fmt_paje) {
249 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType,
250 TRACE_precision(), 0.);
251 stream << std::fixed << std::setprecision(TRACE_precision());
252 stream << simgrid::instr::PAJE_DefineEventType;
253 stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
255 } else if (instr_fmt_type == instr_fmt_TI) {
262 void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest)
264 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType);
266 if (instr_fmt_type == instr_fmt_paje) {
267 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(),
269 stream << std::fixed << std::setprecision(TRACE_precision());
270 stream << simgrid::instr::PAJE_DefineLinkType;
271 stream << " " << type->getId() << " " << type->father_->getId() << " " << source->getId() << " " << dest->getId()
272 << " " << type->getName();
274 } else if (instr_fmt_type == instr_fmt_TI) {
281 void simgrid::instr::Value::print()
283 XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
285 if (instr_fmt_type == instr_fmt_paje) {
286 stream << std::fixed << std::setprecision(TRACE_precision());
287 stream << simgrid::instr::PAJE_DefineEntityValue;
288 stream << " " << id_ << " " << father_->getId() << " " << name_;
290 stream << " \"" << color_ << "\"";
292 } else if (instr_fmt_type == instr_fmt_TI) {
300 simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value)
301 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetVariable), value(value)
303 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
307 void simgrid::instr::SetVariableEvent::print()
309 if (instr_fmt_type == instr_fmt_paje) {
310 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
311 stream << std::fixed << std::setprecision(TRACE_precision());
312 stream << (int)this->eventType_;
313 print_timestamp(this);
314 stream << " " << type->getId() << " " << container->id_ << " " << value;
316 } else if (instr_fmt_type == instr_fmt_TI) {
323 simgrid::instr::AddVariableEvent::AddVariableEvent(double timestamp, container_t container, simgrid::instr::Type* type,
325 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_AddVariable), value(value)
327 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
331 void simgrid::instr::AddVariableEvent::print()
333 if (instr_fmt_type == instr_fmt_paje) {
334 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
335 stream << std::fixed << std::setprecision(TRACE_precision());
336 stream << (int)this->eventType_;
337 print_timestamp(this);
338 stream << " " << type->getId() << " " << container->id_ << " " << value;
340 } else if (instr_fmt_type == instr_fmt_TI) {
347 simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value)
348 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SubVariable), value(value)
350 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
354 void simgrid::instr::SubVariableEvent::print()
356 if (instr_fmt_type == instr_fmt_paje) {
357 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
358 stream << std::fixed << std::setprecision(TRACE_precision());
359 stream << (int)this->eventType_;
360 print_timestamp(this);
361 stream << " " << type->getId() << " " << container->id_ << " " << value;
363 } else if (instr_fmt_type == instr_fmt_TI) {
370 simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* value)
371 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetState), value(value)
374 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
375 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
376 filename = loc->filename;
377 linenumber = loc->linenumber;
381 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
385 void simgrid::instr::SetStateEvent::print()
387 if (instr_fmt_type == instr_fmt_paje) {
388 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
389 stream << std::fixed << std::setprecision(TRACE_precision());
390 stream << (int)this->eventType_;
391 print_timestamp(this);
392 stream << " " << type->getId() << " " << container->id_;
393 stream << " " << value->getId();
395 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
396 stream << " \"" << filename << "\" " << linenumber;
400 } else if (instr_fmt_type == instr_fmt_TI) {
407 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* value,
409 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PushState), value(value), extra_(extra)
412 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
413 smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
414 filename = loc->filename;
415 linenumber = loc->linenumber;
419 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
424 simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val)
425 : PushStateEvent(timestamp, container, type, val, nullptr)
427 void simgrid::instr::PushStateEvent::print()
429 if (instr_fmt_type == instr_fmt_paje) {
430 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
431 stream << std::fixed << std::setprecision(TRACE_precision());
432 stream << (int)this->eventType_;
433 print_timestamp(this);
434 stream << " " << type->getId() << " " << container->id_;
435 stream << " " << value->getId();
437 if (TRACE_display_sizes()) {
439 if (extra_ != nullptr) {
440 stream << static_cast<instr_extra_data>(extra_)->send_size;
446 if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
447 stream << " \"" << filename << "\" " << linenumber;
452 if (extra_ != nullptr) {
453 if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
454 xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
455 if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
456 xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
459 } else if (instr_fmt_type == instr_fmt_TI) {
460 if (extra_ == nullptr)
462 instr_extra_data extra = (instr_extra_data)extra_;
464 char* process_id = nullptr;
465 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
466 if (strstr(container->name_.c_str(), "rank-") == nullptr)
467 process_id = xbt_strdup(container->name_.c_str());
469 process_id = xbt_strdup(container->name_.c_str() + 5);
471 FILE* trace_file = tracing_files.at(container);
473 switch (extra->type) {
475 fprintf(trace_file, "%s init\n", process_id);
477 case TRACING_FINALIZE:
478 fprintf(trace_file, "%s finalize\n", process_id);
481 fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
484 fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
487 fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
490 fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
493 fprintf(trace_file, "%s test\n", process_id);
496 fprintf(trace_file, "%s wait\n", process_id);
498 case TRACING_WAITALL:
499 fprintf(trace_file, "%s waitAll\n", process_id);
501 case TRACING_BARRIER:
502 fprintf(trace_file, "%s barrier\n", process_id);
504 case TRACING_BCAST: // rank bcast size (root) (datatype)
505 fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
506 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
507 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
508 fprintf(trace_file, "\n");
510 case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
511 fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
512 if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
513 fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
514 fprintf(trace_file, "\n");
516 case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
517 fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size,
520 case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
521 fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size,
522 extra->datatype1, extra->datatype2);
524 case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
525 fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
526 for (int i = 0; i < extra->num_processes; i++)
527 fprintf(trace_file, "%d ", extra->sendcounts[i]);
528 fprintf(trace_file, "%d ", extra->recv_size);
529 for (int i = 0; i < extra->num_processes; i++)
530 fprintf(trace_file, "%d ", extra->recvcounts[i]);
531 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
533 case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
534 fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
535 extra->datatype1, extra->datatype2);
537 case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
538 fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
539 for (int i = 0; i < extra->num_processes; i++)
540 fprintf(trace_file, "%d ", extra->recvcounts[i]);
541 fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
543 case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
544 fprintf(trace_file, "%s reduceScatter ", process_id);
545 for (int i = 0; i < extra->num_processes; i++)
546 fprintf(trace_file, "%d ", extra->recvcounts[i]);
547 fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
549 case TRACING_COMPUTING:
550 fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
552 case TRACING_SLEEPING:
553 fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
555 case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
556 fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
557 for (int i = 0; i < extra->num_processes; i++)
558 fprintf(trace_file, "%d ", extra->recvcounts[i]);
559 fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
561 case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype)
562 fprintf(trace_file, "%s allGather %d %d %s %s", process_id, extra->send_size, extra->recv_size,
563 extra->datatype1, extra->datatype2);
565 case TRACING_WAITANY:
566 case TRACING_SENDRECV:
567 case TRACING_SCATTER:
568 case TRACING_SCATTERV:
571 case TRACING_COMM_SIZE:
572 case TRACING_COMM_SPLIT:
573 case TRACING_COMM_DUP:
577 XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname());
581 if (extra->recvcounts != nullptr)
582 xbt_free(extra->recvcounts);
583 if (extra->sendcounts != nullptr)
584 xbt_free(extra->sendcounts);
585 xbt_free(process_id);
593 simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type)
594 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PopState)
596 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
600 void simgrid::instr::PopStateEvent::print()
602 if (instr_fmt_type == instr_fmt_paje) {
603 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
604 stream << std::fixed << std::setprecision(TRACE_precision());
605 stream << (int)this->eventType_;
606 print_timestamp(this);
607 stream << " " << type->getId() << " " << container->id_;
609 } else if (instr_fmt_type == instr_fmt_TI) {
616 simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type)
617 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_ResetState)
619 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
624 void simgrid::instr::ResetStateEvent::print()
626 if (instr_fmt_type == instr_fmt_paje) {
627 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
628 stream << std::fixed << std::setprecision(TRACE_precision());
629 stream << (int)this->eventType_;
630 print_timestamp(this);
631 stream << " " << type->getId() << " " << container->id_;
633 } else if (instr_fmt_type == instr_fmt_TI) {
640 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
641 container_t sourceContainer, std::string value, std::string key)
642 : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
645 simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
646 container_t sourceContainer, std::string value, std::string key,
648 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_StartLink)
649 , sourceContainer_(sourceContainer)
654 XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value_.c_str());
658 void simgrid::instr::StartLinkEvent::print()
660 if (instr_fmt_type == instr_fmt_paje) {
661 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
662 stream << std::fixed << std::setprecision(TRACE_precision());
663 stream << (int)this->eventType_;
664 print_timestamp(this);
665 stream << " " << type->getId() << " " << container->id_ << " " << value_;
666 stream << " " << sourceContainer_->id_ << " " << key_;
668 if (TRACE_display_sizes()) {
669 stream << " " << size_;
672 } else if (instr_fmt_type == instr_fmt_TI) {
679 simgrid::instr::EndLinkEvent::EndLinkEvent(double timestamp, container_t container, Type* type,
680 container_t destContainer, std::string value, std::string key)
681 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_EndLink)
682 , destContainer(destContainer)
686 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
690 void simgrid::instr::EndLinkEvent::print()
692 if (instr_fmt_type == instr_fmt_paje) {
693 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
694 stream << std::fixed << std::setprecision(TRACE_precision());
695 stream << (int)this->eventType_;
696 print_timestamp(this);
697 stream << " " << type->getId() << " " << container->id_ << " " << value;
698 stream << " " << destContainer->id_ << " " << key;
700 } else if (instr_fmt_type == instr_fmt_TI) {
707 simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val)
708 : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent)
712 XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
717 void simgrid::instr::NewEvent::print()
719 if (instr_fmt_type == instr_fmt_paje) {
720 XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
721 stream << std::fixed << std::setprecision(TRACE_precision());
722 stream << (int)this->eventType_;
723 print_timestamp(this);
724 stream << " " << type->getId() << " " << container->id_ << " " << val->getId();
726 } else if (instr_fmt_type == instr_fmt_TI) {
733 void TRACE_TI_start()
735 char *filename = TRACE_get_filename();
736 tracing_file = fopen(filename, "w");
737 if (tracing_file == nullptr)
738 THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
740 XBT_DEBUG("Filename %s is open for writing", filename);
742 /* output one line comment */
743 dump_comment(TRACE_get_comment());
745 /* output comment file */
746 dump_comment_file(TRACE_get_comment_file());
751 fclose(tracing_file);
752 char *filename = TRACE_get_filename();
753 XBT_DEBUG("Filename %s is closed", filename);