Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modernize SIMIX_comm_set_copy_data_callback
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 16 Aug 2021 18:09:42 +0000 (20:09 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 16 Aug 2021 18:09:42 +0000 (20:09 +0200)
include/simgrid/s4u/Engine.hpp
include/simgrid/simix.h
src/s4u/s4u_Engine.cpp
src/smpi/internals/smpi_global.cpp

index 074a242..a494fa0 100644 (file)
@@ -189,6 +189,7 @@ public:
   static void set_config(const std::string& name, double value);
   static void set_config(const std::string& name, const std::string& value);
 
+  Engine* set_default_comm_data_copy_callback(void (*callback)(kernel::activity::CommImpl*, void*, size_t));
   /** Callback fired when the platform is created (ie, the xml file parsed),
    * right before the actual simulation starts. */
   static xbt::signal<void()> on_platform_created;
index 8009151..69488a2 100644 (file)
@@ -58,8 +58,9 @@ SG_END_DECL
 
 /****************************** Communication *********************************/
 #ifdef __cplusplus
-XBT_PUBLIC void SIMIX_comm_set_copy_data_callback(void (*callback)(simgrid::kernel::activity::CommImpl*, void*,
-                                                                   size_t));
+XBT_ATTRIB_DEPRECATED_v333("Please use Engine::set_default_comm_data_copy_callback()") XBT_PUBLIC
+    void SIMIX_comm_set_copy_data_callback(void (*callback)(simgrid::kernel::activity::CommImpl*, void*, size_t));
+
 XBT_PUBLIC void SIMIX_comm_copy_pointer_callback(simgrid::kernel::activity::CommImpl* comm, void* buff,
                                                  size_t buff_size);
 XBT_PUBLIC void SIMIX_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, void* buff,
index b2807da..7d2b5b4 100644 (file)
@@ -16,6 +16,7 @@
 #include "simgrid/simix.h"
 #include "src/instr/instr_private.hpp"
 #include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/activity/CommImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/network_interface.hpp"
 #include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
@@ -443,6 +444,11 @@ void Engine::set_config(const std::string& name, const std::string& value)
   config::set_value(name.c_str(), value);
 }
 
+Engine* Engine::set_default_comm_data_copy_callback(void (*callback)(kernel::activity::CommImpl*, void*, size_t))
+{
+  kernel::activity::CommImpl::set_copy_data_callback(callback);
+  return this;
+}
 } // namespace s4u
 } // namespace simgrid
 
index 1f5d790..ba896e8 100644 (file)
@@ -552,7 +552,7 @@ int smpi_main(const char* executable, int argc, char* argv[])
   sg_storage_file_system_init();
   // parse the platform file: get the host list
   engine->load_platform(argv[1]);
-  simgrid::kernel::activity::CommImpl::set_copy_data_callback(smpi_comm_copy_buffer_callback);
+  engine->set_default_comm_data_copy_callback(smpi_comm_copy_buffer_callback);
 
   if (smpi_cfg_privatization() == SmpiPrivStrategies::DLOPEN)
     smpi_init_privatization_dlopen(executable);