Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / smpi / plugins / ampi / instr_ampi.cpp
1 /* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/smpi/plugins/ampi/instr_ampi.hpp"
7 #include "smpi/smpi.h"
8 #include "src/instr/instr_private.hpp"
9 #include <src/instr/instr_smpi.hpp>
10 #include <src/smpi/include/smpi_actor.hpp>
11
12 static std::map<std::string, std::string, std::less<>> ampi_colors = {{"migrate", "0.2 0.5 0.2"},
13                                                                       {"iteration", "0.5 0.5 0.5"}};
14
15 void TRACE_Iteration_in(int rank, simgrid::instr::TIData* extra)
16 {
17   if (not TRACE_smpi_is_enabled()) {
18     delete extra;
19     return;
20   }
21   smpi_container(rank)->get_state("MPI_STATE")->add_entity_value("iteration", ampi_colors["iteration"]);
22   smpi_container(rank)->get_state("MPI_STATE")->push_event("iteration", extra);
23 }
24
25 void TRACE_Iteration_out(int rank, simgrid::instr::TIData* extra)
26 {
27   if (not TRACE_smpi_is_enabled()) return;
28
29   smpi_container(rank)->get_state("MPI_STATE")->pop_event(extra);
30 }
31
32 void TRACE_migration_call(int rank, simgrid::instr::TIData* extra)
33 {
34   if (not TRACE_smpi_is_enabled()) return;
35
36   const std::string operation = "migrate";
37   if(smpi_process()->replaying()) {//When replaying, we register an event.
38     smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value(operation);
39
40     auto* type = static_cast<simgrid::instr::EventType*>(smpi_container(rank)->type_->by_name(operation));
41     new simgrid::instr::NewEvent(smpi_process()->simulated_elapsed(), smpi_container(rank), type,
42                                  type->get_entity_value(operation));
43   } else {
44     // FIXME From rktesser: Ugly workaround!
45     // TI tracing uses states as events, and does not support printing events.
46     // So, we need a different code than for replay in order to be able to
47     // generate ti_traces for the migration calls.
48     if (!TRACE_smpi_is_enabled()) {
49       delete extra;
50       return;
51     }
52     smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value(operation, ampi_colors[operation.c_str()]);
53     smpi_container(rank)->get_state("MIGRATE_STATE")->push_event(operation, extra);
54     smpi_container(rank)->get_state("MIGRATE_STATE")->pop_event();
55   }
56 }