Lumiera  0.pre.03
»edit your freedom«
job-planning.hpp
Go to the documentation of this file.
1 /*
2  JOB-PLANNING.hpp - steps to prepare and build render jobs
3 
4  Copyright (C)
5  2012, 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 
58 #ifndef STEAM_ENGINE_JOB_PLANNING_H
59 #define STEAM_ENGINE_JOB_PLANNING_H
60 
61 #include "steam/common.hpp"
62 #include "vault/gear/job.h"
65 #include "steam/play/timings.hpp"
66 #include "lib/time/timevalue.hpp"
67 #include "lib/itertools.hpp"
68 #include "lib/nocopy.hpp"
69 
70 
71 
72 namespace steam {
73 namespace engine {
74 
75  namespace error = lumiera::error;
76 
77  using play::DataSink;
78  using play::Timings;
79  using lib::time::Time;
80  using lib::time::TimeVar;
81  using lib::time::Duration;
82  using vault::gear::Job;
83 
84 
85 
101  {
102  JobTicket& jobTicket_;
103  TimeVar const& nominalTime_;
104  FrameCnt const& frameNr_;
105 
106  public:
107  JobPlanning (JobTicket& ticket, TimeVar const& nominalTime, FrameCnt const& frameNr)
108  : jobTicket_{ticket}
109  , nominalTime_{nominalTime}
110  , frameNr_{frameNr}
111  { }
112 
113  // move construction is possible
114 
115 
116  JobTicket& ticket() { return jobTicket_; }
117  bool isTopLevel() const { return not dependentPlan_; }
118 
119 
124  Job
126  {
127  Job job = jobTicket_.createJobFor (Time{nominalTime_});
129  return job;
130  }
131 
137  Time
138  determineDeadline(Timings const& timings)
139  {
140  switch (timings.playbackUrgency)
141  {
142  case play::ASAP:
143  case play::NICE:
144  return Time::ANYTIME;
145 
146  case play::TIMEBOUND:
147  return doCalcDeadline (timings);
148  }
149  NOTREACHED ("unexpected playbackUrgency");
150  }
151 
161  Duration
163  {
164  UNIMPLEMENTED ("Job planning logic to establish Leeway for scheduling");
165  }
166 
167 
176  auto
178  {
179  return lib::transformIterator (jobTicket_.getPrerequisites()
180  ,[this](JobTicket& prereqTicket)
181  {
182  return JobPlanning{*this, prereqTicket};
183  });
184  }
185 
186  private:
189 
199  JobPlanning (JobPlanning& parent, JobTicket& prerequisite)
200  : jobTicket_{prerequisite}
201  , nominalTime_{parent.nominalTime_}
202  , frameNr_{parent.frameNr_}
203  , dependentPlan_{&parent}
204  { }
205 
206 
207  Time
208  doCalcDeadline(Timings const& timings)
209  {
210  if (isTopLevel())
211  return timings.getTimeDue(frameNr_) // anchor at timing grid
212  - jobTicket_.getExpectedRuntime() // deduce the presumably runtime
213  - timings.engineLatency // and the generic engine overhead
214  - timings.outputLatency; // Note: output latency only on top-level job
215  else
216  return dependentPlan_->determineDeadline (timings)
217  - jobTicket_.getExpectedRuntime()
218  - timings.engineLatency;
219  }
220  };
221 
222 
223 
224 }}// namespace steam::engine
225 #endif /*STEAM_ENGINE_JOB_PLANNING_H*/
static const Time ANYTIME
border condition marker value. ANYTIME <= any time value
Definition: timevalue.hpp:313
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
Definition: timevalue.hpp:232
An (abstract) capability to send media data to an external output.
Basic set of definitions and includes commonly used together.
Execution plan to generate render jobs within a specific render process.
Job buildJob()
Connect and complete the planning information assembled thus far to create a frame job descriptor...
Time determineDeadline(Timings const &timings)
Calculate the latest time point when to start the job, so it can still possibly reach the timing goal...
Generic frame timing specification.
Definition: timings.hpp:86
Types marked with this mix-in may be moved but not copied.
Definition: nocopy.hpp:49
Steam-Layer implementation namespace root.
Time getTimeDue(FrameCnt frameOffset) const
real time deadline for the given frame, without any latency.
Definition: timings.cpp:166
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
JobPlanning * dependentPlan_
link to a dependent JobPlanning, for planning of prerequisites
Mix-Ins to allow or prohibit various degrees of copying and cloning.
JobPlanning(JobPlanning &parent, JobTicket &prerequisite)
Duration engineLatency
reasonable guess at the scheduling and dispatch-delay of the render engine
Definition: timings.hpp:95
Definition of a render job.
How to define a timing specification or constraint.
View on the execution planning for a single calculation step.
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:468
Helpers for working with iterators based on the pipeline model.
Individual frame rendering task, forwarding to a closure.
Definition: job.h:268
a family of time value like entities and their relationships.
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
Definition: itertools.hpp:788
auto buildDependencyPlanning()
Build a sequence of dependent JobPlanning scopes for all prerequisites of this current JobPlanning...
auto getPrerequisites()
Core operation: iterate over the prerequisites, required to carry out a render operation based on thi...
Definition: job-ticket.hpp:155
execution plan for pulling a specific exit node.
Definition: job-ticket.hpp:78
Duration getExpectedRuntime()
Core operation: guess expected runtime for rendering.
Definition: job-ticket.cpp:94
Job createJobFor(Time nominalTime)
Core operation: build a concrete render job based on this blueprint.
Definition: job-ticket.cpp:71
Duration determineLeeway(Timings const &)
Determine a timing buffer for flexibility to allow starting the job already before its deadline; espe...