From 9389ce2d68d665ba12734b1c7d46447480c43d23 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 1 Jul 2008 04:53:23 +0200 Subject: [PATCH] WIP possible solution how the operation chunks could be assembled --- doc/devel/uml/class143365.html | 22 ++++ doc/devel/uml/class143493.html | 24 ++++ doc/devel/uml/class143621.html | 24 ++++ doc/devel/uml/class143749.html | 24 ++++ doc/devel/uml/class143877.html | 24 ++++ doc/devel/uml/class144005.html | 24 ++++ doc/devel/uml/class144133.html | 20 +++ src/proc/engine/nodeoperation.hpp | 194 +++++++++++++++++++++++------- src/proc/state.hpp | 16 +-- uml/lumiera/132357.diagram | 81 +++++++++++++ 10 files changed, 400 insertions(+), 53 deletions(-) create mode 100644 doc/devel/uml/class143365.html create mode 100644 doc/devel/uml/class143493.html create mode 100644 doc/devel/uml/class143621.html create mode 100644 doc/devel/uml/class143749.html create mode 100644 doc/devel/uml/class143877.html create mode 100644 doc/devel/uml/class144005.html create mode 100644 doc/devel/uml/class144133.html create mode 100644 uml/lumiera/132357.diagram diff --git a/doc/devel/uml/class143365.html b/doc/devel/uml/class143365.html new file mode 100644 index 000000000..8f96f6b27 --- /dev/null +++ b/doc/devel/uml/class143365.html @@ -0,0 +1,22 @@ + + + + + + +Class NodeWiring + + + + + +
Class NodeWiring
+

+ + + + +

Declaration :

+
+ + diff --git a/doc/devel/uml/class143493.html b/doc/devel/uml/class143493.html new file mode 100644 index 000000000..63ef30fb2 --- /dev/null +++ b/doc/devel/uml/class143493.html @@ -0,0 +1,24 @@ + + + + + + +Class InvocationStateBase + + + + + +
Class InvocationStateBase
+

+ + + + +

Declaration :

Directly inherited by : Caching

+
+
+

All public operations : allocateBuffer , fetch , isCalculated , releaseBuffer

+ + diff --git a/doc/devel/uml/class143621.html b/doc/devel/uml/class143621.html new file mode 100644 index 000000000..39379446c --- /dev/null +++ b/doc/devel/uml/class143621.html @@ -0,0 +1,24 @@ + + + + + + +Class Caching + + + + + +
Class Caching
+

+ + + + +

Declaration :

Directly inherited by : Process

+
+
+

All public operations : allocateBuffer , fetch , isCalculated , releaseBuffer

+ + diff --git a/doc/devel/uml/class143749.html b/doc/devel/uml/class143749.html new file mode 100644 index 000000000..2d3726110 --- /dev/null +++ b/doc/devel/uml/class143749.html @@ -0,0 +1,24 @@ + + + + + + +Class Process + + + + + +
Class Process
+

+ + + + +

Declaration :

Directly inherited by : InPlace

+
+
+

All public operations : allocateBuffer , fetch , isCalculated , releaseBuffer

+ + diff --git a/doc/devel/uml/class143877.html b/doc/devel/uml/class143877.html new file mode 100644 index 000000000..b3164a70a --- /dev/null +++ b/doc/devel/uml/class143877.html @@ -0,0 +1,24 @@ + + + + + + +Class InPlace + + + + + +
Class InPlace
+

+ + + + +

Declaration :

Directly inherited by : StateProxy

+
+
+

All public operations : allocateBuffer , fetch , isCalculated , releaseBuffer

+ + diff --git a/doc/devel/uml/class144005.html b/doc/devel/uml/class144005.html new file mode 100644 index 000000000..9fd2629bc --- /dev/null +++ b/doc/devel/uml/class144005.html @@ -0,0 +1,24 @@ + + + + + + +Class WiringTable + + + + + +
Class WiringTable
+

+ + + + +

Declaration :

+ +
Relation <directional aggregation by value>

Declaration :

+
Relation <unidirectional association>

Declaration :

+ + diff --git a/doc/devel/uml/class144133.html b/doc/devel/uml/class144133.html new file mode 100644 index 000000000..995d09019 --- /dev/null +++ b/doc/devel/uml/class144133.html @@ -0,0 +1,20 @@ + + + + + + +Class BuffHandle + + + + + +
Class BuffHandle
+

+ + + + +

Declaration :

+ diff --git a/src/proc/engine/nodeoperation.hpp b/src/proc/engine/nodeoperation.hpp index 55450fba7..05dc89992 100644 --- a/src/proc/engine/nodeoperation.hpp +++ b/src/proc/engine/nodeoperation.hpp @@ -20,6 +20,33 @@ */ +/** @file nodeoperation.hpp + ** Chunks of operation for invoking the rendernodes. + ** This header defines the "glue" which holds together the render node network + ** and enables to pull a result frames from the nodes. Especially, the aspect of + ** buffer management is covered here. Each node has been preconfigured by the builder + ** with a WiringDescriptor and a concrete type of a StateAdapter. These concrete + ** StateAdapter objects are assembled out of the building blocks defined in this header, + ** depending on the desired mode of operation. Any node can be built to + ** - participate in the Caching or ignore the cache + ** - actually process a result or just pull frames from a source + ** - employ in-Place calculations or use separate in/out buffers + ** Additionally, each node may have a given number of input/output pins, expecting to + ** be provided with buffers holding a specific kind of data. + ** + ** \par composition of the StateAdapter + ** For each individual ProcNode#pull() call, the WiringAdapter#callDown() builds an StateAdapter + ** instance directly on the stack, holding the actual buffer pointers and state references. Using this + ** StateAdapter, the predecessor nodes are pulled. The way these operations are carried out is encoded + ** in the actual StateAdapter type known to the NodeWiring (WiringAdapter) instance. All of these actual + ** StateAdapter types are built as implementing the engine::State interface, on top of the InvocationStateBase + ** and inheriting from a chain of strategy classes (single inheritance, mostly \em no virtual functions). + ** + ** @see engine::ProcNode + ** @see engine::StateProxy + ** @see nodewiring.hpp interface for building/wiring the nodes + ** + */ #ifndef ENGINE_NODEOPERATION_H #define ENGINE_NODEOPERATION_H @@ -33,6 +60,16 @@ namespace engine { + + /** + * (abstract) base class of all concrete StateAdapter types. + * Defines the skeleton for the node operation/calculation + */ + class InvocationStateBase + : public State + { + + }; /** * Adapter to shield the ProcNode from the actual buffer management, @@ -70,64 +107,108 @@ namespace engine { } }; - struct Caching + template + struct QueryCache : NEXT { - void retrieveResult (uint requiredOutputNr) + BuffHandle step () // brauche: current state { BuffHandle fetched = current_.fetch (genFrameID (requiredOutputNr)); if (fetched) return fetched; - - // Cache miss, need to calculate - BuffHandle calculated[NrO]; - calculateResult (&calculated); - - // commit result to Cache - current_.isCalculated (NrO, calculated, requiredOutputNr); - - return calculated[requiredOutputNr]; + else + return NEXT::step(); } }; + - struct NoCaching + template + struct PullInput : NEXT { - void retrieveResult (BuffHandle requiredOutputNr) + BuffHandle step () { - return calculateResult (0); - } - }; - - struct Process - { - BuffHandle calculateResult(BuffHandle* calculated) - { - uint nrI = this->getNrI(); - for (uint i = 0; icreateBuffTable(); + + ASSERT (this->buffTab); + ASSERT (0 < this->buffTabSize()); + ASSERT (this->nrO+this->nrI <= this->buffTabSize()); + ASSERT (this->buffTab->inHandles = &this->buffTab->handles[this->nrO]); + BuffHandle *inH = this->buffTab->inHandles; + BuffHandle::PBuff *inBuff = this->buffTab->inBuffs; + + for (uint i = 0; i < this->nrI; ++i ) { - BuffHandle inID = predNode.pull(inNo); // invoke predecessor - this->inBuff[i] = current_.getBuffer(inID); + inBuff[i] = + *(inH[i] = this->pullPredecessor(i)); // invoke predecessor // now Input #i is ready... } - uint nrO = this->getNrO(); - for (uint i = 0; iallocateBuffer(this->getBuferType(i)); ///TODO: Null pointer when no caching!!!!! - this->outBuff[i] = current_.getBuffer(calculated[i]); - // now Output buffer for channel #i is available... - } - // - // Invoke our own process() function - this->wiring_.process (this->outBuff); - - this->feedCache(); - // Inputs no longer needed - for (uint i = 0; i + struct AllocOutputFromCache + { + BuffHandle step () + { + ASSERT (this->buffTab); + ASSERT (this->nrO < this->buffTabSize()); + BuffHandle *outH = this->buffTab->handles; + BuffHandle::PBuff *outBuff = this->buffTab->buffers; + + for (uint i = 0; i < this->nrO; ++i ) + { + outBuff[i] = + *(outH[i] = this->allocateBuffer(i)); + // now Output buffer for channel #i is available... + } + return NEXT::step(); + } + }; + + template + struct ProcessData + { + BuffHandle step () + { + ASSERT (this->buffTab); + ASSERT (this->nrO+this->nrI <= this->buffTabSize()); + ASSERT (this->validateBuffers()); + + // Invoke our own process() function, providing the buffer array + this->wiring_.processFunction (this->buffTab->buffers); + + return NEXT::step(); + } + }; + + template + struct FeedCache + { + BuffHandle step () + { + // declare all Outputs as finished + this->current_.isCalculated(this->buffTab->handles, + this->nrO); + + return NEXT::step(); + } + }; + + template + struct ReleaseBuffers + { + BuffHandle step () + { + // all buffers besides the required Output no longer needed + this->current_.releaseBuffers(this->buffTab->handles, + this->buffTabSize(), + this->requiredOutputNr); + + return this->buffTab->outH[this->requiredOutputNr]; + } + }; + + template struct NoProcess { BuffHandle calculateResult(BuffHandle* calculated) @@ -150,6 +231,35 @@ namespace engine { }; + + + /* === declare the possible Assembly of these elementary steps === */ + + template + struct Strategy + { + BuffHandle step () { NOTREACHED; } + }; + + template<> + struct Strategy< Config > + : QueryCache < + PullInput< + AllocOutputFromCache< + ProcessData< + FeedCache< + ReleaseBuffers< + InvocationStateBase > > > > > > + { }; + + template<> + struct Strategy< Config > + : PullInput< + AllocOutputFromParent< + ProcessData< + ReleaseBuffers< + InvocationStateBase > > > > + { }; } // namespace engine diff --git a/src/proc/state.hpp b/src/proc/state.hpp index 6ef1e863f..7828398ed 100644 --- a/src/proc/state.hpp +++ b/src/proc/state.hpp @@ -36,21 +36,11 @@ namespace engine { class StateAdapter; - class BuffHandle + struct BuffHandle { - protected: typedef float Buff; typedef Buff* PBuff;//////TODO define the Buffer type(s) - PBuff pBuffer_; - long sourceID_; - - BuffHandle (PBuff pb, long id) - : pBuffer_(pb), - sourceID_(id) - { } - - public: PBuff operator->() const { @@ -62,6 +52,10 @@ namespace engine { ENSURE (pBuffer_); return *pBuffer_; } + + protected: + PBuff pBuffer_; + long sourceID_; }; diff --git a/uml/lumiera/132357.diagram b/uml/lumiera/132357.diagram new file mode 100644 index 000000000..a097c7137 --- /dev/null +++ b/uml/lumiera/132357.diagram @@ -0,0 +1,81 @@ +format 40 + +classcanvas 128005 class_ref 132741 // State + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 78 10 2000 + end +classcanvas 128133 class_ref 143493 // InvocationStateBase + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 203 104 2000 + end +classcanvas 128261 class_ref 143621 // Caching + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 235 157 2000 + end +classcanvas 128389 class_ref 143749 // Process + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 236 212 2000 + end +classcanvas 128517 class_ref 143877 // InPlace + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 238 268 2000 + end +classcanvas 128645 class_ref 142469 // StateProxy + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 209 332 2004 + end +classcanvas 130309 class_ref 144005 // WiringTable + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 101 298 2000 + end +classcanvas 130437 class_ref 142725 // WiringDescriptor + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 36 213 2005 + end +classcanvas 130565 class_ref 144133 // BuffHandle + draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default + xyz 36 379 2000 + end +textcanvas 131461 "const" + xyzwh 109 257 2010 29 18 +relationcanvas 128901 relation_ref 149765 // + from ref 128645 z 1999 to ref 128517 + no_role_a no_role_b + no_multiplicity_a no_multiplicity_b +relationcanvas 129029 relation_ref 149893 // + from ref 128517 z 1999 to ref 128389 + no_role_a no_role_b + no_multiplicity_a no_multiplicity_b +relationcanvas 129157 relation_ref 150021 // + from ref 128389 z 1999 to ref 128261 + no_role_a no_role_b + no_multiplicity_a no_multiplicity_b +relationcanvas 129285 relation_ref 150149 // + from ref 128261 z 1999 to ref 128133 + no_role_a no_role_b + no_multiplicity_a no_multiplicity_b +relationcanvas 129413 relation_ref 150277 // + from ref 128133 z 1999 to point 260 69 + line 129925 z 1999 to point 190 69 + line 130181 z 1999 to point 161 176 + line 130053 z 1999 to point 118 176 + line 129797 z 1999 to ref 128005 + no_role_a no_role_b + no_multiplicity_a no_multiplicity_b +relationcanvas 130693 relation_ref 150405 // + geometry VHr + from ref 130309 z 1999 stereotype "<>" xyz 43 309 3000 to point 70 326 + line 130821 z 1999 to ref 130565 + no_role_a no_role_b + multiplicity_a_pos 45 354 3000 no_multiplicity_b +relationcanvas 130949 relation_ref 150533 // + from ref 130309 z 1999 to ref 130437 + no_role_a no_role_b + no_multiplicity_a no_multiplicity_b +relationcanvas 131077 relation_ref 150661 // + geometry VHr + from ref 128645 z 1999 to point 136 371 + line 131333 z 1999 to ref 130309 + role_a_pos 148 367 3000 no_role_b + multiplicity_a_pos 122 359 3000 no_multiplicity_b +end