From 4176576db00a0b50bf02141d6b4eb275272f7269 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 27 Jun 2023 03:21:10 +0200 Subject: [PATCH] Scheduler: consider what operations are necessary for layer-1 ....still about to find out what kinds of Activities there are, and what reasonably to implement on layer-2 vs. layer-1 It is clear that the worker will typically invoke a doWork() operation on layer-2, which in turn will iterate layer-1. Each worker pulls and performs internal managmenet tasks exclusively until encountering the next real render task, at which point it will drop an exclusion flag and then engage into performing the actual extended work for rendering... --- src/vault/gear/scheduler-commutator.hpp | 116 +++++++++++++++++++ src/vault/gear/scheduler-control.hpp | 75 ------------- src/vault/gear/scheduler-invocation.hpp | 46 +++++--- src/vault/gear/scheduler.hpp | 4 +- wiki/thinkPad.ichthyo.mm | 143 +++++++++++++++++++++++- 5 files changed, 289 insertions(+), 95 deletions(-) create mode 100644 src/vault/gear/scheduler-commutator.hpp delete mode 100644 src/vault/gear/scheduler-control.hpp diff --git a/src/vault/gear/scheduler-commutator.hpp b/src/vault/gear/scheduler-commutator.hpp new file mode 100644 index 000000000..eb5738c5b --- /dev/null +++ b/src/vault/gear/scheduler-commutator.hpp @@ -0,0 +1,116 @@ +/* + SCHEDULER-COMMUTATOR.hpp - coordination layer of the render engine scheduler + + Copyright (C) Lumiera.org + 2023, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +/** @file scheduler-commutator.hpp + ** Layer-2 of the Scheduler: coordination and interaction of activities. + ** This is the upper layer of the implementation and provides high-level functionality. + ** + ** @see ////TODO_test usage example + ** @see scheduler.cpp implementation + ** + ** @todo WIP-WIP-WIP 6/2023 »Playback Vertical Slice« + ** + */ + + +#ifndef SRC_VAULT_GEAR_SCHEDULER_COMMUTATOR_H_ +#define SRC_VAULT_GEAR_SCHEDULER_COMMUTATOR_H_ + + +#include "vault/common.hpp" +#include "lib/nocopy.hpp" +#include "vault/gear/scheduler-invocation.hpp" +//#include "lib/symbol.hpp" +//#include "lib/util.hpp" + +//#include + + +namespace vault{ +namespace gear { + +// using util::isnil; +// using std::string; + + + /** + * Scheduler Layer-2 : coordination. + * + * @see SomeSystem + * @see NA_test + */ + class SchedulerCommutator + : util::NonCopyable + { + + public: +// explicit + SchedulerCommutator() + { } + + void + doWork (SchedulerInvocation& layer1) + { + layer1.feedPriorisation(); + while (layer1.isDue (currentLevel())) + { + Activity* activity = layer1.pullHead(); + if (isInternalWork (activity)) + performInternalWork (activity); + else + { + performExternalWork (activity); + return; + } + } + } + + size_t + currentLevel() const + { + UNIMPLEMENTED ("define waterlevel based on current time"); + } + + bool + isInternalWork (Activity* activity) + { + UNIMPLEMENTED ("determine if an Activity counts as internal management task"); + } + + void + performInternalWork (Activity* activity) + { + UNIMPLEMENTED ("evaluate a term"); + } + + void + performExternalWork (Activity* activity) + { + UNIMPLEMENTED ("drop the exclusion flag and then engage into the external render activity"); + } + }; + + + +}} // namespace vault::gear +#endif /*SRC_VAULT_GEAR_SCHEDULER_COMMUTATOR_H_*/ diff --git a/src/vault/gear/scheduler-control.hpp b/src/vault/gear/scheduler-control.hpp deleted file mode 100644 index bc7bd807b..000000000 --- a/src/vault/gear/scheduler-control.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - SCHEDULER-CONTROL.hpp - coordination layer of the render engine scheduler - - Copyright (C) Lumiera.org - 2023, Hermann Vosseler - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - - -/** @file scheduler-control.hpp - ** Layer-2 of the Scheduler: coordination of activities. - ** This is the upper layer of the implementation and provides high-level functionality. - ** - ** @see ////TODO_test usage example - ** @see scheduler.cpp implementation - ** - ** @todo WIP-WIP-WIP 6/2023 »Playback Vertical Slice« - ** - */ - - -#ifndef SRC_VAULT_GEAR_SCHEDULER_CONTROL_H_ -#define SRC_VAULT_GEAR_SCHEDULER_CONTROL_H_ - - -#include "vault/common.hpp" -#include "lib/nocopy.hpp" -//#include "lib/symbol.hpp" -//#include "lib/util.hpp" - -//#include - - -namespace vault{ -namespace gear { - -// using util::isnil; -// using std::string; - - - /** - * Scheduler Layer-2 : coordination. - * - * @see SomeSystem - * @see NA_test - */ - class SchedulerControl - : util::NonCopyable - { - - public: -// explicit - SchedulerControl() - { } - - }; - - - -}} // namespace vault::gear -#endif /*SRC_VAULT_GEAR_SCHEDULER_CONTROL_H_*/ diff --git a/src/vault/gear/scheduler-invocation.hpp b/src/vault/gear/scheduler-invocation.hpp index 8ffedf2e5..373168206 100644 --- a/src/vault/gear/scheduler-invocation.hpp +++ b/src/vault/gear/scheduler-invocation.hpp @@ -110,29 +110,49 @@ namespace gear { /** - * Pick up a new Activity and enqueue it according to time order + * Pick up all new Activities from the entrance queue + * and enqueue them according to time order */ void - prioriseNext() + feedPriorisation() { ActOrder actOrder; - bool hasInput = instruct_.pop (actOrder); - if (not hasInput) - return; - priority_.push (move (actOrder)); + while (instruct_.pop (actOrder)) + priority_.push (move (actOrder)); } /** - * If there is an Activity to process now, pick it from the scheduling queue + * @return `nullptr` if the queue is empty, else the Activity corresponding + * to the currently most urgent element (without dequeuing it). */ - Activity& - acceptHead() + Activity* + peekHead() { - Activity* activity = priority_.top().activity; - ///////////////////////////////////////////////////////////////////////////////OOO need to handle an empty queue or an Activity not ready to schedule yet - priority_.pop(); - return *activity; + return priority_.empty()? nullptr + : priority_.top().activity; + } + + /** + * If there is an Activity to process now, pick it from the scheduling queue + * @return `nullptr` if the prioritisation queue is empty, + * else a pointer to the most urgent Activity dequeued thereby. + */ + Activity* + pullHead() + { + Activity* activity = peekHead(); + if (activity) + priority_.pop(); + return activity; + } + + /** Determine if there is work to do right now */ + bool + isDue (size_t level) const + { + return not priority_.empty() + and priority_.top().waterlevel <= level; } }; diff --git a/src/vault/gear/scheduler.hpp b/src/vault/gear/scheduler.hpp index db53d62d3..795cc0edd 100644 --- a/src/vault/gear/scheduler.hpp +++ b/src/vault/gear/scheduler.hpp @@ -42,7 +42,7 @@ #include "lib/error.hpp" #include "vault/gear/block-flow.hpp" -#include "vault/gear/scheduler-control.hpp" +#include "vault/gear/scheduler-commutator.hpp" #include "vault/gear/scheduler-invocation.hpp" //#include "lib/symbol.hpp" #include "lib/nocopy.hpp" @@ -67,7 +67,7 @@ namespace gear { class Scheduler { SchedulerInvocation layer1_; - SchedulerControl layer2_; + SchedulerCommutator layer2_; public: explicit diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index c6297830a..e50b33a5d 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -77919,7 +77919,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -77992,12 +77992,88 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Beispiel: __throw_if_empty() +

+ +
+
+ + + + + + + +

+ und sollte nur in Frage gestellt werden, sofern dafür explizit  ein unverhältnismäßiger Overhead nachweisbar ist... +

+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + - - - @@ -78008,6 +78084,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + +

+ ja — und zwar über den Scheduler selbst +

+ +
+
@@ -78020,9 +78108,48 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + +

+ die Ausführungs-Struktur liegt in den Termen (nicht in der Queue) +

+ +
+ +
+ + + + + + + + + + + + + + + + + +

+ wichtig für die IO-Jobs +

+ +
+ +
+
@@ -78038,6 +78165,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + +