Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / src / smpi / internals / instr_smpi.cpp
index 50112e0..4c27a61 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -136,7 +136,7 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send)
   return key;
 }
 
-void TRACE_smpi_setup_container(int rank, sg_host_t host)
+void TRACE_smpi_setup_container(int rank, const_sg_host_t host)
 {
   container_t father = simgrid::instr::Container::get_root();
   if (TRACE_smpi_is_grouped()) {
@@ -151,9 +151,12 @@ void TRACE_smpi_init(int rank)
   if (not TRACE_smpi_is_enabled())
     return;
 
+  auto self = simgrid::s4u::Actor::self();
+
   TRACE_smpi_setup_container(rank, sg_host_self());
+  simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); });
 #if HAVE_PAPI
-  container_t container   = smpi_container(rank);
+  const simgrid::instr::Container* container = smpi_container(rank);
   papi_counter_t counters = smpi_process()->papi_counters();
 
   for (auto const& it : counters) {
@@ -166,14 +169,6 @@ void TRACE_smpi_init(int rank)
 #endif
 }
 
-void TRACE_smpi_finalize(int rank)
-{
-  if (not TRACE_smpi_is_enabled())
-    return;
-
-  smpi_container(rank)->remove_from_parent();
-}
-
 void TRACE_smpi_computing_init(int rank)
 {
  //first use, initialize the color in the trace
@@ -257,7 +252,7 @@ void TRACE_smpi_recv(int src, int dst, int tag)
 }
 
 /**************** Functions to trace the migration of tasks. *****************/
-void TRACE_smpi_process_change_host(int rank, sg_host_t new_host)
+void TRACE_smpi_process_change_host(int rank, const_sg_host_t new_host)
 {
   if (not TRACE_smpi_is_enabled()) return;