Job-Planning: simulate backing by specific JobTicket

right now we're lacking a complete working implementation of render node invocation,
and thus the Dispatcher implementation can only be verified with the help
of mocked jobs. However, at least a preliminary implementation of tagging the
invocation instance is available, and thus we're able to verify that
a given job instance indeed belongs to and is "backed" by a specific JobTicket.

This is prerequisite for building up a (likewise mocked) Fixture datastructure,
and this in turn was meant to form the basis for attacking an actual Scheduler
implementation, followed by a real render node invocation.
This commit is contained in:
Fischlurch 2023-05-01 14:07:21 +02:00
parent f6fbc15e5f
commit 56405b2e2d
7 changed files with 56 additions and 28 deletions

View file

@ -131,7 +131,7 @@ namespace engine {
REQUIRE (this->isValid(), "Attempt to generate render job for incomplete or unspecified render plan.");
REQUIRE (coordinates.channelNr < provision_.size(), "Inconsistent Job planning; channel beyond provision");
Provision const& provision = provision_[coordinates.channelNr];
JobClosure& functor = static_cast<JobClosure&> (unConst(provision.jobFunctor)); ////////////////TICKET #1295 : fix actual interface down to JobFunctor (after removing C structs)
JobClosure& functor = static_cast<JobClosure&> (unConst(provision.jobFunctor)); ////////////////TICKET #1287 : fix actual interface down to JobFunctor (after removing C structs)
InvocationInstanceID invoKey{timeHash (nominalTime, provision.invocationSeed)};
return Job(functor, invoKey, nominalTime);
@ -152,18 +152,25 @@ namespace engine {
}
namespace { ///////////////////////////////////////////////////////////////////////////////////////////TICKET #1287 : temporary workaround until we get rid of the C base structs
inline bool
operator== (InvocationInstanceID const& l, InvocationInstanceID const& r)
{
return lumiera_invokey_eq (unConst(&l), unConst(&r));
}
}
/**
* Helper for tests: verify the given invocation parameters match this JobTicket.
*/
bool
JobTicket::verifyInstance (JobFunctor& functor, Time nominalTime) const
JobTicket::verifyInstance (JobFunctor& functor, InvocationInstanceID const& invoKey, Time nominalTime) const
{
for (Provision const& p : provision_)
if (util::isSameObject (p.jobFunctor, functor))
{
TODO ("actually re-compute the invocation ID !!!!!!!!!!!!");
return true;
}
if (util::isSameObject (p.jobFunctor, functor)
and invoKey == timeHash (nominalTime, p.invocationSeed)
)
return true;
return false;
}

View file

@ -61,7 +61,7 @@ namespace engine {
//using lib::time::Time;
using vault::engine::Job;
using vault::engine::JobFunctor;
using vault::engine::JobClosure; /////////////////////////////////////////////////////////////////////TICKET #1295 : fix actual interface down to JobFunctor (after removing C structs)
using vault::engine::JobClosure; /////////////////////////////////////////////////////////////////////TICKET #1287 : fix actual interface down to JobFunctor (after removing C structs)
using lib::LinkedElements;
using lib::OrientationIndicator;
using util::isnil;
@ -116,7 +116,7 @@ using lib::LUID;
////////////////////TODO some channel or format descriptor here
Provision (JobFunctor& func, HashVal seed =0)
: jobFunctor{func}
, invocationSeed(static_cast<JobClosure&>(func).buildInstanceID(seed)) ////////////////TICKET #1295 : fix actual interface down to JobFunctor (after removing C structs)
, invocationSeed(static_cast<JobClosure&>(func).buildInstanceID(seed)) ////////////////TICKET #1287 : fix actual interface down to JobFunctor (after removing C structs)
{ }
};
@ -162,7 +162,7 @@ using lib::LUID;
protected:
static InvocationInstanceID timeHash (Time, InvocationInstanceID const&);
bool verifyInstance (JobFunctor&, Time) const;
bool verifyInstance (JobFunctor&, InvocationInstanceID const&, Time) const;
};

View file

@ -185,4 +185,13 @@ lumiera_job_get_hash (LumieraJobDefinition jobDef)
REQUIRE (jobDef);
return hash_value (forwardInvocation (*jobDef));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1287 : temporary workaround until we get rid of the C base structs
#include "lib/luid.h"
int
lumiera_invokey_eq (void* l, void* r)
{
return lumiera_uid_eq ((LumieraUid)l, (LumieraUid)r);
}
}

View file

@ -53,7 +53,7 @@
#include "lib/llist.h"
#include "lib/luid.h"
#include "lib/hash-value.h"
#include "lib/time.h"
@ -126,18 +126,6 @@ union InvocationInstanceID
struct { int32_t a,b;
int64_t t;
} part;
friend bool
operator== (InvocationInstanceID const& l, InvocationInstanceID const& r)
{
return lumiera_uid_eq (&l.luid, &r.luid);
}
friend bool
operator!= (InvocationInstanceID const& l, InvocationInstanceID const& r)
{
return not (l == r);
}
};
@ -360,6 +348,7 @@ void lumiera_job_failure (LumieraJobDefinition, JobFailureReason);
/** calculate a hash value based on the Job's \em identity. */
size_t lumiera_job_get_hash (LumieraJobDefinition);
int lumiera_invokey_eq (void* l, void* r);
#ifdef __cplusplus

View file

@ -206,8 +206,9 @@ namespace test {
{
JobFunctor& functor = dynamic_cast<JobFunctor&> (static_cast<JobClosure&> (*job.jobClosure));
Time nominalTime {TimeValue{job.parameter.nominalTime}};
InvocationInstanceID const& invoKey = job.parameter.invoKey;
return this->isValid()
and this->verifyInstance(functor, nominalTime);
and this->verifyInstance(functor, invoKey, nominalTime);
}

View file

@ -121,14 +121,16 @@ namespace test {
// build a render job to do nothing....
Job nopJob = JobTicket::NOP.createJobFor(coord);
CHECK (INSTANCEOF (vault::engine::NopJobFunctor, static_cast<JobClosure*> (nopJob.jobClosure))); //////////TICKET #1295 : fix actual interface down to JobFunctor (after removing C structs)
CHECK (INSTANCEOF (vault::engine::NopJobFunctor, static_cast<JobClosure*> (nopJob.jobClosure))); //////////TICKET #1287 : fix actual interface down to JobFunctor (after removing C structs)
CHECK (nopJob.parameter.nominalTime == coord.absoluteNominalTime);
CHECK (nopJob.parameter.invoKey == InvocationInstanceID());
InvocationInstanceID empty; ///////////////////////////////////////////////////////////////////////TICKET #1287 : temporary workaround until we get rid of the C base structs
CHECK (lumiera_invokey_eq (&nopJob.parameter.invoKey, &empty));
MockJobTicket mockTicket;
CHECK (mockTicket.discoverPrerequisites().empty());
Job mockJob = mockTicket.createJobFor (coord);
CHECK (mockTicket.verify_associated (mockJob));
CHECK ( mockTicket.verify_associated (mockJob)); // proof by invocation hash : is indeed backed by this JobTicket
CHECK (not mockTicket.verify_associated (nopJob)); // ...while some random other job is not related
TODO ("cover details of MockJobTicket");
}

View file

@ -69953,6 +69953,23 @@
<arrowlink COLOR="#b75269" DESTINATION="ID_1713196934" ENDARROW="Default" ENDINCLINATION="-871;-27;" ID="Arrow_ID_865176706" STARTARROW="None" STARTINCLINATION="-1263;70;"/>
<icon BUILTIN="stop-sign"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1682941524301" ID="ID_1050000340" MODIFIED="1682942127658" TEXT="die C-ismen sind problematisch und m&#xfc;ssen weg">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
Bisher wird noch die Fiktion aufrecht erhalten, da&#223; die Basis-Schnittstelle zum Scheduler in reinem C geschrieben ist; tats&#228;chlich ist dadurch so mancher Teil der implementierung grenzwertig bzw. w&#252;rde tats&#228;chlich mit reinem C nicht (mehr) funktionieren; au&#223;erdem bekommen wir mehfrach geschichtete Vererbungen und m&#252;ssen regelm&#228;&#223;ig casten und implizite ungepr&#252;fte Annahmen machen.
</p>
<br/>
<p>
<i><font color="#f83434">Und das gemischte Setup ist t&#252;ckisch:</font></i>&#160;habe gestern Nacht und heute ein paar Stunden einen Link-Fehler gesucht, der auf ein fehlendes <font face="Monospaced" size="2" color="#1b1981">extern &quot;C&quot; { }</font>&#160;zur&#252;ckging, aber nicht aufgefallen war, solange C++ die Definitionen inlinen konnte...
</p>
</body>
</html></richcontent>
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1682205189643" ID="ID_897564380" MODIFIED="1682205211467" TEXT="Problem: Umbau in JobTicket selber blockt">
@ -70760,6 +70777,9 @@
<icon BUILTIN="forward"/>
<node CREATED="1682885740362" ID="ID_362133279" MODIFIED="1682885761537" TEXT="untere H&#xe4;lfte: Seed bzw. zuf&#xe4;llig"/>
<node CREATED="1682885762190" ID="ID_1713133015" MODIFIED="1682885777729" TEXT="obere H&#xe4;lfte: Hash aus der nominellen Zeit"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1682941259374" ID="ID_1987226609" MODIFIED="1682941345993" TEXT="auf C++ umstellen (#1295 bzw. #1287)">
<icon BUILTIN="yes"/>
</node>
</node>
</node>
<node CREATED="1682039636789" ID="ID_986989156" MODIFIED="1682039638216" TEXT="Job">
@ -70877,8 +70897,8 @@
<node CREATED="1682808411785" ID="ID_1713196934" MODIFIED="1682808633170" TEXT="welche Parameter m&#xfc;ssen einer Invocation im allgemeinen mitgegeben werden">
<linktarget COLOR="#b75269" DESTINATION="ID_1713196934" ENDARROW="Default" ENDINCLINATION="-871;-27;" ID="Arrow_ID_865176706" SOURCE="ID_782813898" STARTARROW="None" STARTINCLINATION="-1263;70;"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1682810738487" ID="ID_1493396541" MODIFIED="1682810875535" TEXT="#1295 draft job invocation parameter representation">
<linktarget COLOR="#b22e63" DESTINATION="ID_1493396541" ENDARROW="Default" ENDINCLINATION="-1383;-51;" ID="Arrow_ID_847435526" SOURCE="ID_48632766" STARTARROW="None" STARTINCLINATION="-753;40;"/>
<linktarget COLOR="#4d4eb0" DESTINATION="ID_1493396541" ENDARROW="Default" ENDINCLINATION="-46;-58;" ID="Arrow_ID_1838720811" SOURCE="ID_1576147260" STARTARROW="None" STARTINCLINATION="148;9;"/>
<linktarget COLOR="#b22e63" DESTINATION="ID_1493396541" ENDARROW="Default" ENDINCLINATION="-1383;-51;" ID="Arrow_ID_847435526" SOURCE="ID_48632766" STARTARROW="None" STARTINCLINATION="-753;40;"/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>