+ simgrid::instr::Container::get_root()->get_link("MPI_LINK")->end_event(smpi_container(dst), "PTP", key);
+}
+
+/**************** Functions to trace the migration of tasks. *****************/
+void TRACE_smpi_send_process_data_in(int rank)
+{
+ if (!TRACE_smpi_is_enabled()) return;
+
+ smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value("migration", instr_find_color("migration"));
+ smpi_container(rank)->get_state("MIGRATE_STATE")->push_event("migration");
+}
+
+void TRACE_smpi_send_process_data_out(int rank)
+{
+ if (!TRACE_smpi_is_enabled()) return;
+
+ /* Clean the process state. */
+ smpi_container(rank)->get_state("MIGRATE_STATE")->pop_event();
+}
+
+void TRACE_smpi_process_change_host(int rank, sg_host_t new_host)
+{
+ if (!TRACE_smpi_is_enabled()) return;
+
+ /** The key is (most likely) used to match the events in the trace */
+ static long long int counter = 0;
+ std::string key = std::to_string(counter);
+ counter++;
+
+ // start link (= tell the trace that this rank moves from A to B)
+ container_t cont = smpi_container(rank);
+ simgrid::instr::Container::get_root()->get_link("MIGRATE_LINK")->start_event(cont, "M", key);
+
+ // Destroy container of this rank on this host
+ cont->remove_from_parent();
+
+ // Setup container on new host
+ TRACE_smpi_setup_container(rank, new_host);
+
+ // end link
+ cont = smpi_container(rank); // This points to the newly created container
+ simgrid::instr::Container::get_root()->get_link("MIGRATE_LINK")->end_event(cont, "M", key);