From 6a3caa9dd3776eebe0cb5f892aa3ffca879a0846 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 30 Jan 2018 22:12:33 +0100 Subject: [PATCH] make an interesting error message when mixing link_energy and NS3 --- include/simgrid/plugins/energy.h | 2 ++ src/surf/network_ns3.cpp | 4 ++++ src/surf/plugins/link_energy.cpp | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/simgrid/plugins/energy.h b/include/simgrid/plugins/energy.h index a5663c04bb..285345b12b 100644 --- a/include/simgrid/plugins/energy.h +++ b/include/simgrid/plugins/energy.h @@ -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) diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 806c707e3b..ea97b5f2b7 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -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(); ns3_initialize(ns3_tcp_model.get().c_str()); diff --git a/src/surf/plugins/link_energy.cpp b/src/surf/plugins/link_energy.cpp index 499fe6ce0f..b81cd6fe9e 100644 --- a/src/surf/plugins/link_energy.cpp +++ b/src/surf/plugins/link_energy.cpp @@ -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 -- 2.20.1