1 /* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
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. */
6 #include "src/smpi/plugins/ampi/instr_ampi.hpp"
8 #include "src/instr/instr_private.hpp"
9 #include <src/instr/instr_smpi.hpp>
10 #include <src/smpi/include/smpi_actor.hpp>
12 static std::map<std::string, std::string> ampi_colors = {{"migrate", "0.2 0.5 0.2"},
13 {"iteration", "0.5 0.5 0.5"}
16 void TRACE_Iteration_in(int rank, simgrid::instr::TIData* extra)
18 if (not TRACE_smpi_is_enabled()) {
22 smpi_container(rank)->get_state("MPI_STATE")->add_entity_value("iteration", ampi_colors["iteration"]);
23 smpi_container(rank)->get_state("MPI_STATE")->push_event("iteration", extra);
26 void TRACE_Iteration_out(int rank, simgrid::instr::TIData* extra)
28 if (not TRACE_smpi_is_enabled()) return;
30 smpi_container(rank)->get_state("MPI_STATE")->pop_event(extra);
33 void TRACE_migration_call(int rank, simgrid::instr::TIData* extra)
35 if (not TRACE_smpi_is_enabled()) return;
37 const std::string operation = "migrate";
38 if(smpi_process()->replaying()) {//When replaying, we register an event.
39 smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value(operation);
41 auto* type = static_cast<simgrid::instr::EventType*>(smpi_container(rank)->type_->by_name(operation));
42 new simgrid::instr::NewEvent(smpi_process()->simulated_elapsed(), smpi_container(rank), type,
43 type->get_entity_value(operation));
45 // FIXME From rktesser: Ugly workaround!
46 // TI tracing uses states as events, and does not support printing events.
47 // So, we need a different code than for replay in order to be able to
48 // generate ti_traces for the migration calls.
49 if (!TRACE_smpi_is_enabled()) {
53 smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value(operation, ampi_colors[operation.c_str()]);
54 smpi_container(rank)->get_state("MIGRATE_STATE")->push_event(operation, extra);
55 smpi_container(rank)->get_state("MIGRATE_STATE")->pop_event();