Chain-Load: skeleton of topology-generation
...use a pass over the nodes, with some alternating set of current and next nodes, which are to be connected
This commit is contained in:
parent
ea84935f2a
commit
60dc34a799
3 changed files with 153 additions and 42 deletions
|
|
@ -62,6 +62,7 @@ namespace test {
|
|||
{
|
||||
simpleUsage();
|
||||
verify_Node();
|
||||
verify_Topology();
|
||||
|
||||
witch_gate();
|
||||
}
|
||||
|
|
@ -78,8 +79,8 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
/** @test TODO diagnostic blah
|
||||
* @todo WIP 11/23 🔁 define ⟶ implement
|
||||
/** @test data structure to represent a computation Node
|
||||
* @todo WIP 11/23 ✔ define ⟶ ✔ implement
|
||||
*/
|
||||
void
|
||||
verify_Node()
|
||||
|
|
@ -88,6 +89,8 @@ namespace test {
|
|||
|
||||
Node n0; // Default-created empty Node
|
||||
CHECK (n0.hash == 0);
|
||||
CHECK (n0.level == 0);
|
||||
CHECK (n0.repeat == 0);
|
||||
CHECK (n0.pred.size() == 0 );
|
||||
CHECK (n0.succ.size() == 0 );
|
||||
CHECK (n0.pred == Node::Tab{0});
|
||||
|
|
@ -105,17 +108,17 @@ namespace test {
|
|||
CHECK (55 == n2.hash);
|
||||
|
||||
n0.addPred(n1); // establish bidirectional link between Nodes
|
||||
CHECK (isSameObject(*n0.pred[0], n1));
|
||||
CHECK (isSameObject(*n1.succ[0], n0));
|
||||
CHECK (isSameObject (*n0.pred[0], n1));
|
||||
CHECK (isSameObject (*n1.succ[0], n0));
|
||||
CHECK (not n0.pred[1]);
|
||||
CHECK (not n1.succ[1]);
|
||||
CHECK (n2.pred == Node::Tab{0});
|
||||
CHECK (n2.succ == Node::Tab{0});
|
||||
|
||||
n2.addSucc(n0); // works likewise in the other direction
|
||||
CHECK (isSameObject(*n0.pred[0], n1));
|
||||
CHECK (isSameObject(*n0.pred[1], n2)); // next link added into next free slot
|
||||
CHECK (isSameObject(*n2.succ[0], n0));
|
||||
CHECK (isSameObject (*n0.pred[0], n1));
|
||||
CHECK (isSameObject (*n0.pred[1], n2)); // next link added into next free slot
|
||||
CHECK (isSameObject (*n2.succ[0], n0));
|
||||
CHECK (not n0.pred[2]);
|
||||
CHECK (not n2.succ[1]);
|
||||
|
||||
|
|
@ -132,20 +135,20 @@ namespace test {
|
|||
CHECK (n00.hash == 17052526497278249714u);
|
||||
CHECK (n0.hash == 6050854883719206282u);
|
||||
|
||||
CHECK (isSameObject(*n1.succ[0], n0));
|
||||
CHECK (isSameObject(*n1.succ[1], n00));
|
||||
CHECK (isSameObject(*n2.succ[0], n0));
|
||||
CHECK (isSameObject(*n2.succ[1], n00));
|
||||
CHECK (isSameObject(*n00.pred[0], n2));
|
||||
CHECK (isSameObject(*n00.pred[1], n1));
|
||||
CHECK (isSameObject(*n0.pred[0], n1));
|
||||
CHECK (isSameObject(*n0.pred[1], n2));
|
||||
CHECK (isSameObject (*n1.succ[0], n0));
|
||||
CHECK (isSameObject (*n1.succ[1], n00));
|
||||
CHECK (isSameObject (*n2.succ[0], n0));
|
||||
CHECK (isSameObject (*n2.succ[1], n00));
|
||||
CHECK (isSameObject (*n00.pred[0], n2));
|
||||
CHECK (isSameObject (*n00.pred[1], n1));
|
||||
CHECK (isSameObject (*n0.pred[0], n1));
|
||||
CHECK (isSameObject (*n0.pred[1], n2));
|
||||
|
||||
CHECK (n00.hash == 17052526497278249714u);
|
||||
n00.calculate(); // calculation is NOT idempotent (inherently statefull)
|
||||
CHECK (n00.hash == 13151338213516862912u);
|
||||
|
||||
CHECK (isnil (n0.succ));
|
||||
CHECK (isnil (n0.succ)); // number of predecessors or successors properly accounted for
|
||||
CHECK (isnil (n00.succ));
|
||||
CHECK (n00.succ.empty());
|
||||
CHECK (0 == n00.succ.size());
|
||||
|
|
@ -159,6 +162,22 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
/** @test TODO build topology by connecting the nodes
|
||||
* @todo WIP 11/23 🔁 define ⟶ implement
|
||||
*/
|
||||
void
|
||||
verify_Topology()
|
||||
{
|
||||
auto graph = TestChainLoad<32>{}
|
||||
.buildToplolgy();
|
||||
|
||||
CHECK (31 == graph.topLevel());
|
||||
CHECK (0 == graph.getSeed());
|
||||
CHECK (0 == graph.getHash());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @test TODO diagnostic blah
|
||||
* @todo WIP 11/23 🔁 define ⟶ implement
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -60,10 +60,10 @@
|
|||
|
||||
#include <boost/functional/hash.hpp>
|
||||
//#include <functional>
|
||||
//#include <utility>
|
||||
#include <utility>
|
||||
//#include <string>
|
||||
//#include <deque>
|
||||
#include <vector>
|
||||
//#include <vector>
|
||||
#include <memory>
|
||||
#include <array>
|
||||
|
||||
|
|
@ -82,7 +82,8 @@ namespace test {
|
|||
// using util::isnil;
|
||||
using util::unConst;
|
||||
// using std::forward;
|
||||
// using std::move;
|
||||
using std::swap;
|
||||
using std::move;
|
||||
using boost::hash_combine;
|
||||
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ namespace test {
|
|||
*/
|
||||
template<size_t numNodes =DEFAULT_SIZ, size_t maxFan =DEFAULT_FAN>
|
||||
class TestChainLoad
|
||||
: util::NonCopyable
|
||||
: util::MoveOnly
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
@ -121,46 +122,51 @@ namespace test {
|
|||
Iter end() { return after; }
|
||||
friend Iter end(Tab& tab) { return tab.end(); }
|
||||
|
||||
void clear() { after = _Arr::begin(); } ///< @warning pointer data in array not cleared
|
||||
|
||||
size_t size() const { return unConst(this)->end()-_Arr::begin(); }
|
||||
bool empty() const { return 0 == size(); }
|
||||
|
||||
Iter
|
||||
add(Node& n)
|
||||
add(Node* n)
|
||||
{
|
||||
if (after != _Arr::end())
|
||||
{
|
||||
*after = &n;
|
||||
*after = n;
|
||||
return after++;
|
||||
}
|
||||
NOTREACHED ("excess node linkage");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
size_t hash;
|
||||
Tab pred;
|
||||
Tab succ;
|
||||
size_t level{0}, repeat{0};
|
||||
Tab pred{0}, succ{0};
|
||||
|
||||
Node(size_t seed =0)
|
||||
: hash{seed}
|
||||
, pred{0}
|
||||
, succ{0}
|
||||
{ }
|
||||
|
||||
Node&
|
||||
addPred (Node& other)
|
||||
addPred (Node* other)
|
||||
{
|
||||
pred.add(other);
|
||||
other.succ.add(*this);
|
||||
NOTREACHED ("excess node linkage");
|
||||
REQUIRE (other);
|
||||
pred.add (other);
|
||||
other->succ.add (this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Node&
|
||||
addSucc (Node& other)
|
||||
addSucc (Node* other)
|
||||
{
|
||||
pred.add(other);
|
||||
other.pred.add(*this);
|
||||
NOTREACHED ("excess node linkage");
|
||||
REQUIRE (other);
|
||||
succ.add (other);
|
||||
other->pred.add (this);
|
||||
return *this;
|
||||
}
|
||||
Node& addPred(Node& other) { return addPred(&other); }
|
||||
Node& addSucc(Node& other) { return addSucc(&other); }
|
||||
|
||||
size_t
|
||||
calculate()
|
||||
|
|
@ -173,6 +179,7 @@ namespace test {
|
|||
};
|
||||
|
||||
private:
|
||||
using NodeTab = typename Node::Tab;
|
||||
using NodeStorage = std::array<Node, numNodes>;
|
||||
|
||||
std::unique_ptr<NodeStorage> nodes_;
|
||||
|
|
@ -181,7 +188,45 @@ namespace test {
|
|||
TestChainLoad()
|
||||
: nodes_{new NodeStorage}
|
||||
{ }
|
||||
|
||||
|
||||
size_t size() const { return nodes_->size(); }
|
||||
size_t topLevel() const { return nodes_->back().level; }
|
||||
size_t getSeed() const { return nodes_->front().hash; }
|
||||
size_t getHash() const { return nodes_->back().hash; }
|
||||
|
||||
|
||||
/* ===== topology control ===== */
|
||||
|
||||
/**
|
||||
* Use current configuration and seed to (re)build Node connectivity.
|
||||
*/
|
||||
TestChainLoad
|
||||
buildToplolgy()
|
||||
{
|
||||
NodeTab a,b,
|
||||
*curr{&a}, *next{&b};
|
||||
Node* node = &nodes_->front();
|
||||
size_t level{0};
|
||||
|
||||
curr->add (node++);
|
||||
++level;
|
||||
while (node < &nodes_->back())
|
||||
{
|
||||
Node* n = (*curr)[0];
|
||||
next->add (node++);
|
||||
(*next)[0]->level = level;
|
||||
(*next)[0]->addPred(n);
|
||||
swap (next, curr);
|
||||
next->clear();
|
||||
++level;
|
||||
}
|
||||
ENSURE (node == &nodes_->back());
|
||||
node->level = level;
|
||||
node->addPred ((*curr)[0]);
|
||||
return move(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -95829,24 +95829,40 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1697741633966" ID="ID_787175245" MODIFIED="1697741674433" TEXT="Nutzen vorher klären">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node CREATED="1697741661950" ID="ID_1735458016" MODIFIED="1697741661950" TEXT="Darstellung der Abhängigkeits-Struktur"/>
|
||||
<node CREATED="1697741689551" ID="ID_1012140830" MODIFIED="1697741694906" TEXT="Art der Datenübergabe"/>
|
||||
<node CREATED="1697741661950" ID="ID_1735458016" MODIFIED="1697741661950" TEXT="Darstellung der Abhängigkeits-Struktur">
|
||||
<node CREATED="1699813901659" ID="ID_1631918713" MODIFIED="1699813909295" TEXT="als verkettete Node-Records"/>
|
||||
<node CREATED="1699813912394" ID="ID_708064837" MODIFIED="1699813927012" TEXT="feste Limitierung der Breite des DAG"/>
|
||||
</node>
|
||||
<node CREATED="1697741689551" ID="ID_1012140830" MODIFIED="1697741694906" TEXT="Art der Datenübergabe">
|
||||
<node CREATED="1699813788379" ID="ID_746892067" MODIFIED="1699813811048" TEXT="ChainLoad kann das Scheduler-API verwenden"/>
|
||||
<node CREATED="1699813872512" ID="ID_464773266" MODIFIED="1699813898416" TEXT="ChainLoad bietet einen JobFunctor, der auf einem Node-Pointer arbeitet"/>
|
||||
<node CREATED="1699813845859" ID="ID_1345582113" MODIFIED="1699813864796" TEXT="der errechnete chained-Hash ist direkt abrufbar (von der End-Node)"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1697743909120" ID="ID_483537733" MODIFIED="1697743924734" TEXT="#1346 reproducible computational load">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1697740877587" ID="ID_1275890321" MODIFIED="1699747567145" TEXT="TestChainLoad_test">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699747322625" ID="ID_1190216980" MODIFIED="1699747559682" TEXT="verify_Node">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1699747322625" ID="ID_1190216980" MODIFIED="1699804627509" TEXT="verify_Node">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1699753108010" ID="ID_1374103098" MODIFIED="1699754432064" TEXT="Default-Konstruktion">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699753116721" ID="ID_1947111817" MODIFIED="1699753141716" TEXT="Verbindung mit anderen Nodes">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1699753116721" ID="ID_1947111817" MODIFIED="1699803887451" TEXT="Verbindung mit anderen Nodes">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699753131711" ID="ID_1177424615" MODIFIED="1699753141717" TEXT="Hash-Berechnung">
|
||||
<node COLOR="#338800" CREATED="1699753131711" ID="ID_1177424615" MODIFIED="1699803889454" TEXT="Hash-Berechnung">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1699804617226" ID="ID_277685591" MODIFIED="1699804626403" TEXT="Verbindungsgrad">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699804864545" ID="ID_73838770" MODIFIED="1699804873145" TEXT="verify_Topology">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699805908357" ID="ID_955671536" MODIFIED="1699813655109" TEXT="einfachster Verlinkungs-Durchlauf">
|
||||
<icon BUILTIN="pencil"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -95857,12 +95873,21 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699746880572" ID="ID_1016750692" MODIFIED="1699758515003" TEXT="Rahmen">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1699805761305" ID="ID_185771075" MODIFIED="1699805795004" TEXT="move-only wegen builder syntax">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1699805783017" ID="ID_1511899969" MODIFIED="1699805795875" TEXT="alloziert sofort einen Block mit allen Nodes">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699746814207" ID="ID_1830964354" MODIFIED="1699758515002" TEXT="Node">
|
||||
<icon BUILTIN="pencil"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699746817756" ID="ID_490992503" MODIFIED="1699746834411" TEXT="Generator">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699805813117" ID="ID_593874916" MODIFIED="1699805822698" TEXT="buildTopology: Grundstruktur">
|
||||
<icon BUILTIN="pencil"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699746891934" ID="ID_1003055056" MODIFIED="1699803875494" TEXT="Node">
|
||||
|
|
@ -95883,11 +95908,15 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699803850765" ID="ID_1046832305" MODIFIED="1699803862199" TEXT="weitere Payload">
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699803850765" ID="ID_1046832305" MODIFIED="1699813995892" TEXT="weitere Payload">
|
||||
<linktarget COLOR="#16a827" DESTINATION="ID_1046832305" ENDARROW="Default" ENDINCLINATION="72;59;" ID="Arrow_ID_1961863856" SOURCE="ID_944363802" STARTARROW="None" STARTINCLINATION="-128;-105;"/>
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1699803858055" ID="ID_598864815" MODIFIED="1699803859975" TEXT="hash">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1699813952833" ID="ID_1674807101" MODIFIED="1699813955421" TEXT="level">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1699747423371" ID="ID_1818811688" MODIFIED="1699803681498" TEXT="Berechnung">
|
||||
|
|
@ -95901,6 +95930,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699747521150" ID="ID_356376425" MODIFIED="1699747533637" TEXT="kann durch Repetitionen aufwendig gemacht werden">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1699813962931" ID="ID_944363802" MODIFIED="1699814010982" TEXT="repetition-Count in der Node speichern">
|
||||
<arrowlink COLOR="#16a827" DESTINATION="ID_1046832305" ENDARROW="Default" ENDINCLINATION="72;59;" ID="Arrow_ID_1961863856" STARTARROW="None" STARTINCLINATION="-128;-105;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1699756460900" ID="ID_1877216077" MODIFIED="1699758391567" TEXT="Implementierung per boost-Hash">
|
||||
<icon BUILTIN="yes"/>
|
||||
|
|
@ -95952,6 +95985,20 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1699805829000" ID="ID_270316664" MODIFIED="1699805831707" TEXT="Topologie">
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699805833671" ID="ID_580627690" MODIFIED="1699805843455" TEXT="Verlinkungs-Algorithmus">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699805853717" ID="ID_1156505101" MODIFIED="1699805858453" TEXT="Schleifenrahmen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699805863906" ID="ID_857574027" MODIFIED="1699805883001" TEXT="Steuergrößen einführen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1699805890752" ID="ID_604823204" MODIFIED="1699805896284" TEXT="Limitierungen einhalten">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1697737304920" ID="ID_1305412516" MODIFIED="1697737436489" TEXT="DemoVideoGenerator">
|
||||
|
|
|
|||
Loading…
Reference in a new issue