2012-02-13 00:37:57 +01:00
|
|
|
/*
|
|
|
|
|
JOB.hpp - render job closure
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2012, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROC_ENGINE_JOB_H
|
|
|
|
|
#define PROC_ENGINE_JOB_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <gavl/gavl.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef void* LList; ////////////////////////////////////TODO
|
2012-02-17 01:54:51 +01:00
|
|
|
typedef uint64_t InvocationInstanceID; /////////////////TODO
|
2012-02-13 00:37:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
enum JobState
|
|
|
|
|
{
|
|
|
|
|
DONE, ///< already done, nothing to do
|
|
|
|
|
RUNNING, ///< job is currently running
|
|
|
|
|
WAITING, ///< waits for some prerequisite resource
|
|
|
|
|
REJECTED, ///< sorry, can't do that Dave
|
|
|
|
|
EXPIRED, ///< deadline expired
|
|
|
|
|
ABORTED ///< got aborted
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-26 04:11:31 +02:00
|
|
|
enum JobKind
|
|
|
|
|
{
|
|
|
|
|
CALC_JOB, ///< calculating frame data, CPU bound
|
|
|
|
|
LOAD_JOB, ///< accessing prerequisites, IO bound
|
|
|
|
|
META_JOB ///< render process self organisation
|
|
|
|
|
};
|
|
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
|
2012-02-17 01:54:51 +01:00
|
|
|
/**
|
|
|
|
|
* closure representing the execution context of a job.
|
|
|
|
|
* The information reachable through this closure is specific
|
|
|
|
|
* for this kind of job, but static and typically shared among
|
|
|
|
|
* all jobs for a given feed and segment of the timeline
|
|
|
|
|
*/
|
|
|
|
|
struct lumiera_jobClosure { /* placeholder */ };
|
|
|
|
|
typedef struct lumiera_jobClosure* LumieraJobClosure;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-01-11 16:48:28 +01:00
|
|
|
* invocation parameter for the individual frame calculation job.
|
|
|
|
|
* Embedded into the job descriptor and passed to #lumiera_job_invoke when triggering
|
2012-02-17 01:54:51 +01:00
|
|
|
*/
|
|
|
|
|
struct lumiera_jobParameter_struct
|
|
|
|
|
{
|
|
|
|
|
gavl_time_t nominalTime;
|
2012-04-27 18:59:08 +02:00
|
|
|
InvocationInstanceID invoKey;
|
2012-02-18 19:42:20 +01:00
|
|
|
//////////////////////////////////////////////////////////////TODO: place an additional parameter value here, or make the instanceID globally unique?
|
2012-02-17 01:54:51 +01:00
|
|
|
};
|
|
|
|
|
typedef struct lumiera_jobParameter_struct lumiera_jobParameter;
|
|
|
|
|
typedef lumiera_jobParameter* LumieraJobParameter;
|
|
|
|
|
|
|
|
|
|
|
2012-02-19 00:43:35 +01:00
|
|
|
/** complete definition of an individual job */
|
|
|
|
|
struct lumiera_jobDefinition_struct
|
|
|
|
|
{
|
2012-04-27 18:59:08 +02:00
|
|
|
LumieraJobClosure jobClosure; ///< type and context of the job, including the actual functor
|
|
|
|
|
lumiera_jobParameter parameter; ///< the "moving parts" for this individual invocation (Job)
|
2012-02-19 00:43:35 +01:00
|
|
|
};
|
|
|
|
|
typedef struct lumiera_jobDefinition_struct lumiera_jobDefinition;
|
|
|
|
|
|
|
|
|
|
|
2012-02-17 01:54:51 +01:00
|
|
|
/**
|
|
|
|
|
* descriptor record used by the scheduler to organise job invocation.
|
2012-02-19 00:43:35 +01:00
|
|
|
* The actual job's definition, i.e. the invocation parameter and
|
|
|
|
|
* the closure necessary to invoke the job as a function
|
|
|
|
|
* is embedded (by value) into this descriptor.
|
|
|
|
|
*
|
|
|
|
|
* @note while this descriptor as such is self-contained,
|
|
|
|
|
* the referred LumieraJobClosure needs to be allocated
|
|
|
|
|
* and managed separately. Indeed, this closure happens
|
|
|
|
|
* to live within the segment data, as part of the JobTicket.
|
2012-02-17 01:54:51 +01:00
|
|
|
*/
|
2012-02-13 00:37:57 +01:00
|
|
|
struct lumiera_jobDescriptor_struct
|
|
|
|
|
{
|
|
|
|
|
gavl_time_t when;
|
2012-02-19 00:43:35 +01:00
|
|
|
JobState jobState;
|
|
|
|
|
|
|
|
|
|
lumiera_jobDefinition jobDefinition;
|
2012-02-13 00:37:57 +01:00
|
|
|
|
|
|
|
|
/* == Job prerequisites == */
|
|
|
|
|
LList waiting;
|
|
|
|
|
LList failed;
|
|
|
|
|
LList completed;
|
|
|
|
|
};
|
2012-02-17 01:54:51 +01:00
|
|
|
typedef struct lumiera_jobDescriptor_struct lumiera_jobDescriptor;
|
2012-02-13 00:37:57 +01:00
|
|
|
typedef lumiera_jobDescriptor* LumieraJobDescriptor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 16:48:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
#ifdef __cplusplus /* ============== C++ Interface ================= */
|
|
|
|
|
|
2012-04-26 04:11:31 +02:00
|
|
|
#include "lib/error.hpp"
|
2012-02-18 19:42:20 +01:00
|
|
|
#include "lib/time/timevalue.hpp"
|
2012-02-13 00:37:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace proc {
|
|
|
|
|
namespace engine {
|
|
|
|
|
|
2013-01-11 16:48:28 +01:00
|
|
|
using lib::time::TimeValue;
|
|
|
|
|
using lib::time::Time;
|
2012-02-13 00:37:57 +01:00
|
|
|
|
2012-04-28 04:18:00 +02:00
|
|
|
typedef lumiera_jobParameter const& JobParameter;
|
|
|
|
|
|
|
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
/**
|
|
|
|
|
* Frame rendering task, represented as closure.
|
2012-02-19 00:43:35 +01:00
|
|
|
* This functor encodes all information necessary to trigger
|
|
|
|
|
* and invoke the actual rendering operation. It will be embedded
|
|
|
|
|
* by value into a job descriptor and then enqueued with the scheduler
|
2012-02-18 00:49:53 +01:00
|
|
|
* for invocation just in time. The job interface exposes everything necessary
|
|
|
|
|
* to plan, handle, schedule and abort jobs. The implementation refers to the
|
|
|
|
|
* concrete "execution plan" encoded into the corresponding engine::JobTicket.
|
2012-02-19 00:43:35 +01:00
|
|
|
* The latter is embedded into the storage for one segment of the low-level model
|
|
|
|
|
* and thus is shared for all frames and channels within this part of the timeline.
|
|
|
|
|
* Thus, the lumiera_jobParameter struct contains the "moving parts"
|
|
|
|
|
* different for each \em individual job.
|
2012-02-13 00:37:57 +01:00
|
|
|
*
|
2012-02-19 00:43:35 +01:00
|
|
|
* @todo 2/12 WIP-WIP-WIP defining the invocation sequence and render jobs
|
2012-02-13 00:37:57 +01:00
|
|
|
*/
|
|
|
|
|
class Job
|
2012-02-19 00:43:35 +01:00
|
|
|
: public lumiera_jobDefinition
|
2012-02-13 00:37:57 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
Job()
|
|
|
|
|
{
|
2012-02-19 00:43:35 +01:00
|
|
|
UNIMPLEMENTED ("job creation, planning and scheduling");
|
2012-02-13 00:37:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// using standard copy operations
|
|
|
|
|
|
|
|
|
|
|
2012-02-19 00:43:35 +01:00
|
|
|
void triggerJob() const;
|
|
|
|
|
void signalFailure() const;
|
2012-02-17 01:54:51 +01:00
|
|
|
|
|
|
|
|
|
2012-02-18 19:42:20 +01:00
|
|
|
Time
|
|
|
|
|
getNominalTime() const
|
|
|
|
|
{
|
2012-02-19 00:43:35 +01:00
|
|
|
return Time (TimeValue(parameter.nominalTime));
|
2012-02-18 19:42:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InvocationInstanceID
|
|
|
|
|
getInvocationInstanceID() const
|
|
|
|
|
{
|
2012-02-19 00:43:35 +01:00
|
|
|
return this->parameter.invoKey;
|
2012-02-18 19:42:20 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-26 04:11:31 +02:00
|
|
|
JobKind getKind() const;
|
2012-02-19 00:43:35 +01:00
|
|
|
bool isValid() const;
|
2012-02-13 00:37:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace proc::engine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif /* =========================== CL Interface ===================== */
|
|
|
|
|
|
|
|
|
|
|
2012-02-17 01:54:51 +01:00
|
|
|
/** trigger execution of a specific job,
|
|
|
|
|
* assuming availability of all prerequisites */
|
2012-02-19 00:43:35 +01:00
|
|
|
void lumiera_job_invoke (lumiera_jobDefinition);
|
2012-02-17 01:54:51 +01:00
|
|
|
|
|
|
|
|
/** signal inability to invoke this job
|
|
|
|
|
* @todo decide what and how to communicate details of the failure
|
|
|
|
|
* @remarks the purpose of this function is to allow for reliable checkpoints
|
2012-04-28 04:18:00 +02:00
|
|
|
* within the network of dependent job invocations, even after
|
2012-02-17 01:54:51 +01:00
|
|
|
* missing deadlines or aborting a sequence of jobs */
|
2012-02-19 00:43:35 +01:00
|
|
|
void lumiera_job_failure (lumiera_jobDefinition);
|
2012-02-17 01:54:51 +01:00
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|