Lumiera  0.pre.03
»edit your freedom«
feed-manifold-test.cpp
Go to the documentation of this file.
1 /*
2  FeedManifold(Test) - check consistency of buffer table chunk allocation
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
19 #include "lib/test/run.hpp"
20 #include "lib/error.hpp"
21 
24 #include "lib/format-cout.hpp"
25 
26 #include <memory>
27 
28 using test::Test;
29 
30 
31 namespace steam {
32 namespace engine{
33 namespace test {
34 
35  namespace { // used internally
36 
37  const uint TABLE_SIZ = 100000;
38  const uint CHUNK_MAX = 8000;
39  const uint WIDTH_MAX = 3;
40 
41 
42 #if false
43 
44  template<class E>
45  struct DummyArray : lib::RefArray<E>
46  {
47  E decoy;
48  E const& operator[] (size_t) const { return decoy; }
49  size_t size() const { return CHUNK_MAX;}
50  };
51  DummyArray<ChannelDescriptor> dummy1;
52  DummyArray<InChanDescriptor> dummy2;
53 
54 
57  struct MockSizeRequest
58  : Connectivity
59  {
60  uint ii,oo;
61 
62  MockSizeRequest()
63  : Connectivity(dummy1,dummy2,0,NodeID()),
64  ii(rani (CHUNK_MAX)),
65  oo(rani (CHUNK_MAX))
66  { }
67 
68  virtual uint getNrI() const { return ii; }
69  virtual uint getNrO() const { return oo; }
70 
71  virtual BuffHandle callDown (StateClosure_OBSOLETE&, uint) const
72  { throw lumiera::Error("not intended to be called"); }
73  };
74 #endif
75 
76 
77 
78 #if false
79  void*
80  detect_start_level (BuffTableStorage& sto)
81  {
82  return BuffTableChunk(MockSizeRequest(), sto ).outHandle;
83  } // address of first available storage element
84 
85 
86  inline void*
87  first_behind (BuffTable const& thisChunk, const uint nrI)
88  {
89  return &thisChunk.inHandle[nrI];
90  }
91 
92 
93  inline bool
94  not_within(void* candidate, void* lower, void* upper)
95  {
96  return (candidate < lower) || (upper <= candidate);
97  }
98 
99 
100  bool
101  consistencyCheck (BuffTable const& b, Connectivity const& num, void* lastLevel)
102  {
103  return (b.outHandle == lastLevel ) // storage is allocated continuously
104  && (b.outBuff <= b.inBuff ) // input slots are behind the output slots
105  && (b.outHandle <= b.inHandle)
106  && (b.inBuff == &b.outBuff [num.nrO])
107  && (b.inHandle == &b.outHandle[num.nrO])
108  && (not_within(b.outBuff, b.outHandle, &b.inHandle[num.nrO])) // storage doesn't overlap
109  && (not_within(b.inBuff, b.outHandle, &b.inHandle[num.nrO]))
110  && (not_within(b.outHandle, b.outBuff, &b.inBuff[num.nrO]))
111  && (not_within(b.inHandle, b.outBuff, &b.inBuff[num.nrO]))
112  ;
113  }
114 #endif
115  } // (End) internal defs
116 
117 
118 
119  /***************************************************************/
126  class FeedManifold_test : public Test
127  {
128 #if false
129  using PSto = std::unique_ptr<BuffTableStorage>;
130 
131  PSto pStorage;
132 #endif
133  ulong counter;
134 
135  void
136  run(Arg) override
137  {
138  seedRand();
139  counter = 0;
140 
141 #if false
142  // allocate storage block to be used chunk wise
143  pStorage.reset (new BuffTableStorage (TABLE_SIZ));
144 
145  invocation (0, detect_start_level(*pStorage));
146 
147  pStorage.reset(0); // dtor throws assertion error if corrupted
148 
149  cout << "BuffTable chunks allocated: "<<counter<< "\n";
150 #endif
151  }
152 
153 
157  void invocation (uint consumed, void* lastLevel)
158  {
159 #if false
160  MockSizeRequest numbers;
161  consumed += numbers.getNrI()+numbers.getNrO();
162  if (TABLE_SIZ <= consumed)
163  return; // end recursion
164 
165  ++counter;
166  BuffTableChunk thisChunk (numbers, *pStorage);
167  CHECK (consistencyCheck (thisChunk, numbers, lastLevel));
168 
169  uint nrBranches ( 1 + rani(WIDTH_MAX));
170  while (nrBranches--)
171  invocation (consumed, first_behind (thisChunk,numbers.getNrI()));
172 #endif
173  }
174  };
175 
176 
178  LAUNCHER (FeedManifold_test, "unit engine");
179 
180 
181 
182 }}} // namespace steam::engine::test
void invocation(uint consumed, void *lastLevel)
recurse down randomly until exhausting storage
Abstraction: Array of const references.
Definition: ref-array.hpp:42
Obsolete, to be rewritten /////TICKET #826 to be allocated on the stack while evaluating a ProcNode::...
Automatically use custom string conversion in C++ stream output.
Obsolete, to be rewritten /////TICKET #826.
Definition: run.hpp:40
int rani(uint bound=_iBOUND())
Definition: random.hpp:135
Steam-Layer implementation namespace root.
Abstract Base Class for all testcases.
Definition: run.hpp:53
Abstraction to access the state of a currently ongoing render/calculation process, as it is tied to the supporting facilities of the vault layer.
Simplistic test class runner.
Interface to the processing nodes and the render nodes network.
Lumiera error handling (C++ interface).
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
Interface: Description of the input and output ports, processing function and predecessor nodes for a...
Identification tuple for denoting render nodes unambiguously.
Definition: frameid.hpp:45
Tables of buffer handles and corresponding dereferenced buffer pointers.
Definition: bufftable.hpp:57
Interface and Base definition for all Lumiera Exceptions.
Definition: error.hpp:62