A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7fc168c
)
Move hosts_ to private, and deal with consequences
author
Fabien Chaix
<chaix@ics.forth.gr>
Thu, 19 May 2022 07:12:45 +0000
(10:12 +0300)
committer
Fabien Chaix
<chaix@ics.forth.gr>
Thu, 19 May 2022 07:12:45 +0000
(10:12 +0300)
src/kernel/activity/ActivityImpl.cpp
patch
|
blob
|
history
src/kernel/activity/ActivityImpl.hpp
patch
|
blob
|
history
src/kernel/activity/CommImpl.cpp
patch
|
blob
|
history
src/kernel/activity/ExecImpl.cpp
patch
|
blob
|
history
src/kernel/activity/ExecImpl.hpp
patch
|
blob
|
history
diff --git
a/src/kernel/activity/ActivityImpl.cpp
b/src/kernel/activity/ActivityImpl.cpp
index
c75799a
..
86cd48a
100644
(file)
--- a/
src/kernel/activity/ActivityImpl.cpp
+++ b/
src/kernel/activity/ActivityImpl.cpp
@@
-59,7
+59,7
@@
const char* ActivityImpl::get_state_str() const
{
return to_c_str(state_);
}
{
return to_c_str(state_);
}
-
+
bool ActivityImpl::test(actor::ActorImpl* issuer)
{
if (state_ != State::WAITING && state_ != State::RUNNING) {
bool ActivityImpl::test(actor::ActorImpl* issuer)
{
if (state_ != State::WAITING && state_ != State::RUNNING) {
diff --git
a/src/kernel/activity/ActivityImpl.hpp
b/src/kernel/activity/ActivityImpl.hpp
index
a5feea5
..
ff05528
100644
(file)
--- a/
src/kernel/activity/ActivityImpl.hpp
+++ b/
src/kernel/activity/ActivityImpl.hpp
@@
-29,6
+29,7
@@
class XBT_PUBLIC ActivityImpl {
State state_ = State::WAITING; /* State of the activity */
double start_time_ = -1.0;
double finish_time_ = -1.0;
State state_ = State::WAITING; /* State of the activity */
double start_time_ = -1.0;
double finish_time_ = -1.0;
+ std::vector<s4u::Host*> hosts_;
public:
virtual ~ActivityImpl();
public:
virtual ~ActivityImpl();
@@
-38,10
+39,6
@@
public:
resource::Action* surf_action_ = nullptr;
protected:
resource::Action* surf_action_ = nullptr;
protected:
-
- std::vector<s4u::Host*> hosts_;
-
-
void inline set_name(std::string_view name)
{
// This is to keep name_ private while allowing ActivityImpl_T<??> to set it and then return a Ptr to qualified
void inline set_name(std::string_view name)
{
// This is to keep name_ private while allowing ActivityImpl_T<??> to set it and then return a Ptr to qualified
@@
-49,8
+46,12
@@
protected:
name_ = name;
}
void set_start_time(double start_time) { start_time_ = start_time; }
name_ = name;
}
void set_start_time(double start_time) { start_time_ = start_time; }
-
+ void clear_hosts() { hosts_.clear(); }
+ void add_host(s4u::Host* host) { hosts_.push_back(host); }
+ void set_hosts(const std::vector<s4u::Host*>& hosts) { hosts_=hosts; }
+
public:
public:
+
const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
@@
-85,7
+86,8
@@
public:
virtual void finish() = 0; // Unlock all simcalls blocked on that activity, either because it was marked as done by
// the model or because it terminated without waiting for the model
virtual void finish() = 0; // Unlock all simcalls blocked on that activity, either because it was marked as done by
// the model or because it terminated without waiting for the model
- virtual const std::vector<s4u::Host*>& get_hosts() const { return hosts_;} ;
+ s4u::Host* get_host() const { return hosts_.front(); }
+ const std::vector<s4u::Host*>& get_hosts() const { return hosts_;} ;
void register_simcall(actor::Simcall* simcall);
void unregister_simcall(actor::Simcall* simcall);
void register_simcall(actor::Simcall* simcall);
void unregister_simcall(actor::Simcall* simcall);
diff --git
a/src/kernel/activity/CommImpl.cpp
b/src/kernel/activity/CommImpl.cpp
index
87e8c5e
..
e027255
100644
(file)
--- a/
src/kernel/activity/CommImpl.cpp
+++ b/
src/kernel/activity/CommImpl.cpp
@@
-64,7
+64,7
@@
CommImpl& CommImpl::set_source(s4u::Host* from)
{
xbt_assert( from_ == nullptr );
from_ = from;
{
xbt_assert( from_ == nullptr );
from_ = from;
-
hosts_.push_back
(from);
+
add_host
(from);
return *this;
}
return *this;
}
@@
-72,7
+72,7
@@
CommImpl& CommImpl::set_destination(s4u::Host* to)
{
xbt_assert( to_ == nullptr );
to_ = to;
{
xbt_assert( to_ == nullptr );
to_ = to;
-
hosts_.push_back
(to_);
+
add_host
(to_);
return *this;
}
return *this;
}
diff --git
a/src/kernel/activity/ExecImpl.cpp
b/src/kernel/activity/ExecImpl.cpp
index
4b2ad5c
..
fdaf2dc
100644
(file)
--- a/
src/kernel/activity/ExecImpl.cpp
+++ b/
src/kernel/activity/ExecImpl.cpp
@@
-31,20
+31,21
@@
ExecImpl::ExecImpl()
ExecImpl& ExecImpl::set_host(s4u::Host* host)
{
ExecImpl& ExecImpl::set_host(s4u::Host* host)
{
- hosts_.assign(1, host);
+ clear_hosts();
+ add_host(host);
return *this;
}
ExecImpl& ExecImpl::set_hosts(const std::vector<s4u::Host*>& hosts)
{
return *this;
}
ExecImpl& ExecImpl::set_hosts(const std::vector<s4u::Host*>& hosts)
{
-
hosts_ = hosts
;
+
ActivityImpl::set_hosts(hosts)
;
return *this;
}
ExecImpl& ExecImpl::set_timeout(double timeout)
{
if (timeout >= 0 && not MC_is_active() && not MC_record_replay_is_active()) {
return *this;
}
ExecImpl& ExecImpl::set_timeout(double timeout)
{
if (timeout >= 0 && not MC_is_active() && not MC_record_replay_is_active()) {
- timeout_detector_.reset(
hosts_.fron
t()->get_cpu()->sleep(timeout));
+ timeout_detector_.reset(
get_hos
t()->get_cpu()->sleep(timeout));
timeout_detector_->set_activity(this);
}
return *this;
timeout_detector_->set_activity(this);
}
return *this;
@@
-79,19
+80,19
@@
ExecImpl* ExecImpl::start()
{
set_state(State::RUNNING);
if (not MC_is_active() && not MC_record_replay_is_active()) {
{
set_state(State::RUNNING);
if (not MC_is_active() && not MC_record_replay_is_active()) {
- if (
hosts_
.size() == 1) {
+ if (
get_hosts()
.size() == 1) {
if (thread_count_ == 1) {
if (thread_count_ == 1) {
- surf_action_ =
hosts_.fron
t()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
+ surf_action_ =
get_hos
t()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
surf_action_->set_sharing_penalty(sharing_penalty_);
} else {
surf_action_->set_sharing_penalty(sharing_penalty_);
} else {
- auto host_model =
hosts_.fron
t()->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->execute_thread(
hosts_.fron
t(), flops_amounts_.front(), thread_count_);
+ auto host_model =
get_hos
t()->get_netpoint()->get_englobing_zone()->get_host_model();
+ surf_action_ = host_model->execute_thread(
get_hos
t(), flops_amounts_.front(), thread_count_);
}
surf_action_->set_category(get_tracing_category());
} else {
// get the model from first host since we have only 1 by now
}
surf_action_->set_category(get_tracing_category());
} else {
// get the model from first host since we have only 1 by now
- auto host_model =
hosts_.fron
t()->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->execute_parallel(
hosts_
, flops_amounts_.data(), bytes_amounts_.data(), -1);
+ auto host_model =
get_hos
t()->get_netpoint()->get_englobing_zone()->get_host_model();
+ surf_action_ = host_model->execute_parallel(
get_hosts()
, flops_amounts_.data(), bytes_amounts_.data(), -1);
}
surf_action_->set_activity(this);
set_start_time(surf_action_->get_start_time());
}
surf_action_->set_activity(this);
set_start_time(surf_action_->get_start_time());
@@
-145,7
+146,8
@@
ExecImpl& ExecImpl::update_sharing_penalty(double sharing_penalty)
void ExecImpl::post()
{
xbt_assert(surf_action_ != nullptr);
void ExecImpl::post()
{
xbt_assert(surf_action_ != nullptr);
- if (std::any_of(hosts_.begin(), hosts_.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
+ auto hosts=get_hosts();
+ if (std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
/* If one of the hosts running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
set_state(State::FAILED);
/* If one of the hosts running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
set_state(State::FAILED);
@@
-223,7
+225,7
@@
void ExecImpl::finish()
void ExecImpl::reset()
{
void ExecImpl::reset()
{
-
hosts_.clear
();
+
clear_hosts
();
bytes_amounts_.clear();
flops_amounts_.clear();
set_start_time(-1.0);
bytes_amounts_.clear();
flops_amounts_.clear();
set_start_time(-1.0);
diff --git
a/src/kernel/activity/ExecImpl.hpp
b/src/kernel/activity/ExecImpl.hpp
index
a6c691b
..
22dfb5c
100644
(file)
--- a/
src/kernel/activity/ExecImpl.hpp
+++ b/
src/kernel/activity/ExecImpl.hpp
@@
-35,15
+35,13
@@
public:
ExecImpl& set_flops_amount(double flop_amount);
ExecImpl& set_host(s4u::Host* host);
ExecImpl& set_flops_amount(double flop_amount);
ExecImpl& set_host(s4u::Host* host);
- s4u::Host* get_host() const { return hosts_.front(); }
- const std::vector<s4u::Host*>& get_hosts() const { return hosts_; }
ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
ExecImpl& set_thread_count(int thread_count);
ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
ExecImpl& set_thread_count(int thread_count);
ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
- unsigned int get_host_number() const { return static_cast<unsigned>(
hosts_
.size()); }
+ unsigned int get_host_number() const { return static_cast<unsigned>(
get_hosts()
.size()); }
double get_seq_remaining_ratio();
double get_par_remaining_ratio();
double get_remaining() const override;
double get_seq_remaining_ratio();
double get_par_remaining_ratio();
double get_remaining() const override;