From b5d3948bd70a3b6b76a416318458b29f809e5c9e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 15 Feb 2017 15:30:53 +0100 Subject: [PATCH] add NetworkAction::links(), similar to CpuAction::cpus() for Betsegaw --- src/surf/cpu_interface.cpp | 2 ++ src/surf/network_interface.cpp | 21 ++++++++++++++++++++- src/surf/network_interface.hpp | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 177c968650..8e9569f053 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -129,6 +129,7 @@ Cpu::Cpu(Model* model, simgrid::s4u::Host* host, lmm_constraint_t constraint, st Cpu::~Cpu() = default; +/** @brief The amount of flop per second that this CPU can compute at its current DVFS level */ double Cpu::getPstateSpeedCurrent() { return speed_.peak; @@ -231,6 +232,7 @@ void CpuAction::setState(Action::State state){ Action::setState(state); onStateChange(this, previous); } +/** @brief returns a list of all CPUs that this action is using */ std::list CpuAction::cpus() { std::list retlist; lmm_system_t sys = getModel()->getMaxminSystem(); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 0414e74bb5..7d97da1c88 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -186,11 +186,30 @@ namespace simgrid { * Action * **********/ - void NetworkAction::setState(Action::State state){ + void NetworkAction::setState(Action::State state) + { Action::setState(state); s4u::Link::onCommunicationStateChange(this); } + /** @brief returns a list of all Links that this action is using */ + std::list NetworkAction::links() + { + std::list retlist; + lmm_system_t sys = getModel()->getMaxminSystem(); + int llen = lmm_get_number_of_cnst_from_var(sys, getVariable()); + + for (int i = 0; i < llen; i++) { + /* Beware of composite actions: ptasks put links and cpus together */ + // extra pb: we cannot dynamic_cast from void*... + Resource* resource = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(sys, getVariable(), i))); + LinkImpl* link = dynamic_cast(resource); + if (link != nullptr) + retlist.push_back(link); + } + + return retlist; + } } } diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index e0462e6dfd..25ec028356 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -10,6 +10,7 @@ #include "src/surf/PropertyHolder.hpp" #include "src/surf/surf_interface.hpp" #include "xbt/base.h" +#include #include /*********** @@ -206,6 +207,7 @@ namespace simgrid { : simgrid::surf::Action(model, cost, failed, var) {}; void setState(simgrid::surf::Action::State state) override; + std::list links(); double latency_; double latCurrent_; -- 2.20.1