From: Arnaud Giersch Date: Sun, 22 Dec 2019 22:45:08 +0000 (+0100) Subject: Kill useless field 'parallel_' in context factories. X-Git-Tag: v3.25~239 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/852c24f4be68f06bedf43688364f770e9319f3a0 Kill useless field 'parallel_' in context factories. --- diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index 03a70bdb61..731a0f58df 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -38,7 +38,7 @@ namespace context { /* thread-specific storage for the worker's context */ thread_local SwappedContext* SwappedContext::worker_context_ = nullptr; -SwappedContextFactory::SwappedContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel()) +SwappedContextFactory::SwappedContextFactory() : ContextFactory() { parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel) } @@ -47,7 +47,7 @@ SwappedContext::SwappedContext(std::function&& code, smx_actor_t actor, : Context(std::move(code), actor), factory_(factory) { // Save maestro (=context created first) in preparation for run_all - if (not factory->parallel_ && factory->maestro_context_ == nullptr) + if (not SIMIX_context_is_parallel() && factory->maestro_context_ == nullptr) factory->maestro_context_ = this; if (has_code()) { @@ -154,7 +154,7 @@ void SwappedContextFactory::run_all() * stuff It is much easier to understand what happens if you see the working threads as bodies that swap their soul * for the ones of the simulated processes that must run. */ - if (parallel_) { + if (SIMIX_context_is_parallel()) { // We lazily create the parmap so that all options are actually processed when doing so. if (parmap_ == nullptr) parmap_.reset( @@ -192,7 +192,7 @@ void SwappedContextFactory::run_all() */ void SwappedContext::resume() { - if (factory_->parallel_) { + if (SIMIX_context_is_parallel()) { // Save my current soul (either maestro, or one of the minions) in a thread-specific area worker_context_ = static_cast(self()); // Switch my soul and the actor's one @@ -217,7 +217,7 @@ void SwappedContext::resume() */ void SwappedContext::suspend() { - if (factory_->parallel_) { + if (SIMIX_context_is_parallel()) { // Get some more work to directly swap into the next executable actor instead of yielding back to the parmap boost::optional next_work = factory_->parmap_->next(); SwappedContext* next_context; diff --git a/src/kernel/context/ContextSwapped.hpp b/src/kernel/context/ContextSwapped.hpp index 25f22c294f..532287da06 100644 --- a/src/kernel/context/ContextSwapped.hpp +++ b/src/kernel/context/ContextSwapped.hpp @@ -24,8 +24,6 @@ public: void run_all() override; private: - bool parallel_; - /* For the sequential execution */ unsigned long process_index_ = 0; // next actor to execute SwappedContext* maestro_context_ = nullptr; // save maestro's context diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index 5f1f15975f..f7b3394644 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -22,21 +22,21 @@ namespace context { // ThreadContextFactory -ThreadContextFactory::ThreadContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel()) +ThreadContextFactory::ThreadContextFactory() : ContextFactory() { - if (parallel_) + if (SIMIX_context_is_parallel()) ParallelThreadContext::initialize(); } ThreadContextFactory::~ThreadContextFactory() { - if (parallel_) + if (SIMIX_context_is_parallel()) ParallelThreadContext::finalize(); } ThreadContext* ThreadContextFactory::create_context(std::function&& code, actor::ActorImpl* actor, bool maestro) { - if (parallel_) + if (SIMIX_context_is_parallel()) return this->new_context(std::move(code), actor, maestro); else return this->new_context(std::move(code), actor, maestro); @@ -44,7 +44,7 @@ ThreadContext* ThreadContextFactory::create_context(std::function&& code void ThreadContextFactory::run_all() { - if (parallel_) { + if (SIMIX_context_is_parallel()) { // Parallel execution ParallelThreadContext::run_all(); } else { diff --git a/src/kernel/context/ContextThread.hpp b/src/kernel/context/ContextThread.hpp index 259aef0b7e..df885d631b 100644 --- a/src/kernel/context/ContextThread.hpp +++ b/src/kernel/context/ContextThread.hpp @@ -103,8 +103,6 @@ public: } private: - bool parallel_; - ThreadContext* create_context(std::function&& code, actor::ActorImpl* actor, bool maestro); }; } // namespace context