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) Lumiera.org
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
67 #ifndef STEAM_ENGINE_JOB_PLANNING_H
68 #define STEAM_ENGINE_JOB_PLANNING_H
69 
70 #include "steam/common.hpp"
71 #include "vault/gear/job.h"
74 #include "steam/play/timings.hpp"
75 #include "lib/time/timevalue.hpp"
76 #include "lib/itertools.hpp"
77 #include "lib/nocopy.hpp"
78 
79 
80 
81 namespace steam {
82 namespace engine {
83 
84  namespace error = lumiera::error;
85 
86  using play::DataSink;
87  using play::Timings;
88  using lib::time::Time;
89  using lib::time::TimeVar;
90  using lib::time::Duration;
91  using vault::gear::Job;
92 
93 
94 
110  {
111  JobTicket& jobTicket_;
112  TimeVar const& nominalTime_;
113  FrameCnt const& frameNr_;
114 
115  public:
116  JobPlanning (JobTicket& ticket, TimeVar const& nominalTime, FrameCnt const& frameNr)
117  : jobTicket_{ticket}
118  , nominalTime_{nominalTime}
119  , frameNr_{frameNr}
120  { }
121 
122  // move construction is possible
123 
124 
125  JobTicket& ticket() { return jobTicket_; }
126  bool isTopLevel() const { return not dependentPlan_; }
127 
128 
133  Job
135  {
136  Job job = jobTicket_.createJobFor (Time{nominalTime_});
138  return job;
139  }
140 
146  Time
147  determineDeadline(Timings const& timings)
148  {
149  switch (timings.playbackUrgency)
150  {
151  case play::ASAP:
152  case play::NICE:
153  return Time::ANYTIME;
154 
155  case play::TIMEBOUND:
156  return doCalcDeadline (timings);
157  }
158  NOTREACHED ("unexpected playbackUrgency");
159  }
160 
170  Duration
172  {
173  UNIMPLEMENTED ("Job planning logic to establish Leeway for scheduling");
174  }
175 
176 
185  auto
187  {
188  return lib::transformIterator (jobTicket_.getPrerequisites()
189  ,[this](JobTicket& prereqTicket)
190  {
191  return JobPlanning{*this, prereqTicket};
192  });
193  }
194 
195  private:
198 
208  JobPlanning (JobPlanning& parent, JobTicket& prerequisite)
209  : jobTicket_{prerequisite}
210  , nominalTime_{parent.nominalTime_}
211  , frameNr_{parent.frameNr_}
212  , dependentPlan_{&parent}
213  { }
214 
215 
216  Time
217  doCalcDeadline(Timings const& timings)
218  {
219  if (isTopLevel())
220  return timings.getTimeDue(frameNr_) // anchor at timing grid
221  - jobTicket_.getExpectedRuntime() // deduce the presumably runtime
222  - timings.engineLatency // and the generic engine overhead
223  - timings.outputLatency; // Note: output latency only on top-level job
224  else
225  return dependentPlan_->determineDeadline (timings)
226  - jobTicket_.getExpectedRuntime()
227  - timings.engineLatency;
228  }
229  };
230 
231 
232 
233 }}// namespace steam::engine
234 #endif /*STEAM_ENGINE_JOB_PLANNING_H*/
static const Time ANYTIME
border condition marker value. ANYTIME <= any time value
Definition: timevalue.hpp:322
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
Definition: timevalue.hpp:241
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:95
Types marked with this mix-in may be moved but not copied.
Definition: nocopy.hpp:58
Steam-Layer implementation namespace root.
Time getTimeDue(FrameCnt frameOffset) const
real time deadline for the given frame, without any latency.
Definition: timings.cpp:175
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
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:104
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:477
Helpers for working with iterators based on the pipeline model.
Individual frame rendering task, forwarding to a closure.
Definition: job.h:277
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:797
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:164
execution plan for pulling a specific exit node.
Definition: job-ticket.hpp:87
Duration getExpectedRuntime()
Core operation: guess expected runtime for rendering.
Definition: job-ticket.cpp:102
Job createJobFor(Time nominalTime)
Core operation: build a concrete render job based on this blueprint.
Definition: job-ticket.cpp:79
Duration determineLeeway(Timings const &)
Determine a timing buffer for flexibility to allow starting the job already before its deadline; espe...