Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make an interesting error message when mixing link_energy and NS3
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 30 Jan 2018 21:12:33 +0000 (22:12 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 30 Jan 2018 21:12:33 +0000 (22:12 +0100)
include/simgrid/plugins/energy.h
src/surf/network_ns3.cpp
src/surf/plugins/link_energy.cpp

index a5663c0..285345b 100644 (file)
@@ -21,6 +21,8 @@ XBT_PUBLIC(double) sg_host_get_current_consumption(sg_host_t host);
 XBT_PUBLIC(void) sg_link_energy_plugin_init();
 XBT_PUBLIC(double) sg_link_get_consumed_energy(sg_link_t link);
 
+XBT_PUBLIC(int) sg_link_energy_is_inited();
+
 #define MSG_host_energy_plugin_init() sg_host_energy_plugin_init()
 #define MSG_host_get_consumed_energy(host) sg_host_get_consumed_energy(host)
 #define MSG_host_get_wattmin_at(host,pstate) sg_host_get_wattmin_at(host,pstate)
index 806c707..ea97b5f 100644 (file)
@@ -19,6 +19,7 @@
 #include "src/instr/instr_private.hpp" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
 #include "src/kernel/routing/NetPoint.hpp"
 
+#include "simgrid/plugins/energy.h"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/NetZone.hpp"
 
@@ -143,6 +144,9 @@ namespace simgrid {
 namespace surf {
 
 NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
+  xbt_assert(not sg_link_energy_is_inited(),
+             "LinkEnergy plugin and NS3 network models are not compatible. Are you looking for Ecofen, maybe?");
+
   NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create<NetPointNs3>();
 
   ns3_initialize(ns3_tcp_model.get().c_str());
index 499fe6c..b81cd6f 100644 (file)
@@ -177,6 +177,10 @@ static void onSimulationEnd()
 }
 /* **************************** Public interface *************************** */
 SG_BEGIN_DECL()
+int sg_link_energy_is_inited()
+{
+  return LinkEnergy::EXTENSION_ID.valid();
+}
 /** \ingroup SURF_plugin_energy
  * \brief Enable energy plugin
  * \details Enable energy plugin to get joules consumption of each cpu. You should call this function before