AGX Dynamics 2.41.3.2
Loading...
Searching...
No Matches
Task.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_TASK_H
18#define AGX_TASK_H
19
20#include <agx/Job.h>
21#include <agx/Device.h>
22#include <agx/HashSet.h>
23#include <agx/Component.h>
24#include <agx/Parameter.h>
25#include <agx/Referenced.h>
26#include <agx/String.h>
27#include <agx/Vector.h>
28#include <agx/Statistics.h>
29
30#include <agxData/Buffer.h>
32
33
34namespace agx
35{
36 class TiXmlElement;
37 class Solver;
38 class Thread;
39 class Clock;
40 class TaskTimingReportHandle;
41
47
48
49
50
58 {
59 public:
61
62 // Allow concatenated syntax: path.to.tasks:implementationName
63 static Task* load(const String& path, Device* device = CpuDevice::instance());
64 static Task* load(const char* path, Device* device = CpuDevice::instance());
65
66 static Task* load(TiXmlElement *eTask, Device* device);
67 static Task* load(const Path& path, Device* device = CpuDevice::instance());
68 // static Task *load(const String& path, Device *device, const String& implementation);
69 static Task* load(const Path& path, const Name& implementation, Device* device = CpuDevice::instance());
70
71 static Task* load(const Path& path, const Name& implementation, const agx::ParameterBindingVector& parameterList, Device* device = CpuDevice::instance());
72 static Task* load(const Path& path, const Name& implementation, agx::ParameterBindingVector& parameterList, bool allowFormatPromotions, Device* device = CpuDevice::instance());
73
74 virtual void configure(TiXmlElement* eTask) override;
75 void configure(TiXmlElement* eTask, bool loadParameters);
76
77 void save(agx::TiXmlElement* parent) const override;
78
80 {
83 PROFILING_FULL
84 };
85
87 static ProfilingMode getProfilingMode();
88
89 public:
92
95
98
101
104
107
108 public:
109
112 NO_EVENTS = 0,
113
114 // Bits set to indicate events that does not imply a failed match.
115 EMPTY_BINDING_LIST = (1<<0), // Matched by default since the list of supplied parameters was empty.
116 PARAMETER_VALID = (1<<1), // A parameter was valid and therefore didn't need a new binding.
117 PARAMETER_NOT_REQUIRED = (1<<2), // A parameter was marked as not required and therefore didn't need a new binding.
118 PARAMETER_BOUND = (1<<3), // A parameter was already bound and therefore didn't need a new binding.
119 PARAMETER_HAS_BOUND_PATH = (1<<4), // A parameter has a bind path already and therefore didn't need a new binding.
120 FORMATS_MATCH = (1<<5), // A parameter and a new binding had the same format.
121 NEED_DEVICE_TRANSFORM = (1<<6), // The device has requested to get data of the new binding type in the format of the parameter. Transformation will be required.
122
123 // Bits set to signal a failed match.
124 MISSING_BINDING = (1<<7), // When a task has a parameter that needs a new binding but didn't get one.
125 BINDING_LACKS_TYPE = (1<<8), // A new binding didn't have a type.
126 FORMATS_MISSMATCH = (1<<9), // The format of a new binding was incompatible with the parameter format.
127 EXTRA_BINDING = (1<<10), // There were new bindings that didn't have a corresponding parameter.
128 INCONSISTEN_PARAMETERS = (1<<11), // Don't think this can ever happen. Means that a loop over all parameters didn't visit all of them.
129
130 // Mask of all events that doesn't imply a failed match.
131 // Note that the NO_MATCH_MASK test has precendence, so match-testing should only use that.
132 MATCH_MASK = EMPTY_BINDING_LIST | PARAMETER_VALID | PARAMETER_NOT_REQUIRED | PARAMETER_BOUND | PARAMETER_HAS_BOUND_PATH | FORMATS_MATCH | NEED_DEVICE_TRANSFORM,
133
134 // The following is the union of all events signaling a failed parameter match. Bitwise and between this mask and a ParameterMatch is == 0 when there is a match.
135 NO_MATCH_MASK = MISSING_BINDING | BINDING_LACKS_TYPE | FORMATS_MISSMATCH | EXTRA_BINDING | INCONSISTEN_PARAMETERS
136 };
137 static void printParameterMatch( UInt32 parameterMatch );
138
139 public:
145
149 void execute();
150
154 virtual void wait();
155
159 bool isRunning() const;
160
164 void setEnable(bool flag);
165
169 bool isEnabled() const;
170
174 virtual void setTargetThread(agx::Thread *thread);
175
179 agx::Thread *getTargetThread();
180
184 agx::Thread *getDispatchThread();
185
189 void addParameter(agx::Parameter *parameter);
190 void addParameter(agx::Parameter *parameter, size_t index);
191
196 void removeParameter(size_t index);
197
201 const agx::ParameterPtrVector& getParameters() const;
202
206 agx::Parameter *getParameter(const agx::Name& name);
207 const agx::Parameter *getParameter(const agx::Name& name) const;
208
209 // ScalarParameter
210 agx::ScalarParameter *getScalarParameter(const agx::Name& name);
211 const agx::ScalarParameter *getScalarParameter(const agx::Name& name) const;
212
213 // ArrayParameter
214 agx::ArrayParameter *getArrayParameter(const agx::Name& name);
215 const agx::ArrayParameter *getArrayParameter(const agx::Name& name) const;
216
217 // PointerParameter
218 agx::PointerParameter *getPointerParameter(const agx::Name& name);
219 const agx::PointerParameter *getPointerParameter(const agx::Name& name) const;
220
224 agx::Parameter *getParameter(size_t index);
225 const agx::Parameter *getParameter(size_t index) const;
226
227
230 UInt32 matchParameters(agx::ParameterBindingVector& bindings, bool allowFormatPromotions);
231
235 agx::TaskGroup *getGroup();
236 const agx::TaskGroup *getGroup() const;
237
238
242 const agx::TaskPtrVector& getParents() const;
243
247 const agx::TaskPtrVector& getChildren() const;
248
249
250
256 void addDependency(const agx::Path& path);
257 void addDependencies(const agx::String& paths); // Semi-colon separated
258
264
265 // Search recursively for a parent dependency
266 bool hasDependency(agx::Task *parent) const;
267
271 void replace(agx::Task *other);
272
273 void traverse(const Callback1<Task *>& callback, bool breadthFirst = true);
274
275 void print() const;
276 void print(std::ostream& stream) const;
278 void printBindings(std::ostream& stream);
279
280 virtual void setContext( agx::Object* context ) override;
281 void setModel(agx::Model *model);
282
283 public:
287 virtual agx::Job *getPreJob() = 0;
288
292 virtual agx::Job *getPostJob() = 0;
293
294
295
296 public:
297 virtual void rebind() override;
298
299 void addTriggerPath(const agx::Path& path);
300 void addTriggerPaths(const agx::String& paths);
301 void addResolvePath(const agx::Path& path);
302 void addResolvePaths(const agx::String& paths);
303
304 public:
305
307
308
310 agx::Real32 getWallTime() const;
311
313 agx::Real32 getOverheadTime() const;
314
316 agx::Real32 getComputeCost() const;
317
318 agx::Real32 getAccumulatedWallTime() const;
319 agx::Real32 getAccumulatedOverheadTime() const;
320 agx::Real32 getAccumulatedComputeCost() const;
321 agx::UInt getNumAccumulationSamples() const;
322
324 void resetAccumulationTimers(bool recursive = true);
325
326 // private
328 void endCallback(agx::Real32 computeCost, agx::Real32 overheadCost = 0);
329
330 protected:
331
332 virtual ~Task();
333
334
335 // void setGroup(Task *group);
337
338 static void addConnection(Task *parent, Task *child);
339 static void removeConnection(Task *parent, Task *child);
340
341 virtual void parameterAddedCallback(Parameter* /*parameter*/) {}
342 virtual void parameterRemovedCallback(Parameter* /*parameter*/) {}
343 virtual void subtaskAddedCallback(Task* /*subtask*/) {}
344
345 // Must be called after the number of kernel jobs is known, during dispatch
346 void prepareGlobalResultSorting(size_t numJobs);
347
348 protected:
349 friend class Component;
350 friend class UnresolvedTask;
351 friend class TaskManager;
352 friend class Solver;
353
354 void init();
355
356 // void defaultRunCallback();
360 void disconnectFromParent(Task* ancestor);
361 void disconnectFromChild(Task* descendant);
362 void connectToParent(Task* ancestor);
363 void connectToChild(Task* descendant);
365
366 friend class TaskGroup;
367 void setGroup(TaskGroup *group);
368
369
370 friend class Thread;
373
374#ifndef SWIG
375 virtual Object *getResourceImpl(const Path& path, agx::Model *model) override;
376#endif
377
378 private:
379 bool m_enabled;
380 std::atomic<bool> m_running;
381
382 Thread *m_targetThread;
383 Thread *m_dispatchThread;
384 Timer m_overheadTimer;
385 // Timer m_runTimer;
386 Timer m_wallTimer;
387
388
389
390 // Currently not decided how task timer reporting will be handled, with internal Real32s or through Statistics.
391 // Keeping both as part of the object for now since we do not want to have to change this header file when
392 // changing the reporting strategy.
393 Real32 m_wallTime;
394 Real32 m_computeCost;
395 Real32 m_overheadTime;
396 Real32 m_accumulatedWallTime;
397 Real32 m_accumulatedComputeCost;
398 Real32 m_accumulatedOverheadTime;
399 UInt m_numAccumulations;
400
401 TaskTimingReportHandleRef m_statisticsHandle;
402
403
404 TaskGroup *m_group;
405 TaskPtrVector m_parents;
406 TaskPtrVector m_children;
407
408 ParameterPtrVector m_parameters;
409 ParameterPtrVector m_globalResultParameters;
411
412 struct BindPath
413 {
414 enum Type
415 {
416 INVALID=-1,
417 DEPENDENCY,
418 RESOLVE,
419 TRIGGER
420 };
421
422 BindPath() : type((Type)agx::InvalidIndex), binding(nullptr) {}
423 BindPath(const Path& _path, Type _type) : path(_path), type(_type), binding(nullptr) {}
424
425 Path path;
426 Type type;
427 ObjectRef binding;
428 };
429
430 Vector<BindPath> m_bindPaths;
431 Path m_bindContextPath;
432 ObjectObserver m_bindContext;
433
434 AGX_DECLARE_POINTER_TYPES(DisableHelper);
435 class DisableHelper : public Referenced
436 {
437 public:
438 DisableHelper(Task *task);
439
440 void restore();
441
442 void registerSubtask(Task* subtask);
443 void removeSubtask(Task* subtask);
444
445 protected:
446 virtual ~DisableHelper();
447
448 private:
449 void emptyPre();
450 void emptyPost();
451
452 private:
453 Task *m_task;
454 JobPtrVector m_oldPreChildren;
455 UInt32 m_oldNumPostDependencies;
456 Callback m_oldPre;
457 Callback m_oldPost;
458 };
459
460 DisableHelperRef m_disableHelper;
461
462 static ProfilingMode s_profilingMode;
463 };
464
465
470 {
471 public:
473
474 SerialTask(const agx::Name& name, const Job::Callback& runCallback, agx::Device* device = agx::CpuDevice::instance());
475
479 void setDispatch(const Job::Callback& dispatchCallback);
480
481
485 virtual void run() {}
486
487
489
490 virtual agx::Job *getPreJob() override;
491 virtual agx::Job *getPostJob() override;
492 virtual void setTargetThread(agx::Thread *thread) override;
493
494 protected:
495 virtual ~SerialTask();
496
497 private:
498 class SerialJob : public Job
499 {
500 public:
501 virtual ~SerialJob();
502
503 private:
504 virtual void implementation() override;
505 };
506
507 private:
508 SerialJob m_job;
509 };
510
511
516 {
517 public:
519 ParallelTask(const agx::Name& name, const agx::Job::Callback& dispatchCallback, agx::Device* device = agx::CpuDevice::instance());
520
524 void addJob(agx::Job *job);
525
530
532
533 void setDispatch(const agx::Job::Callback& dispatchCallback);
534
535 virtual agx::Job *getPreJob() override;
536 virtual agx::Job *getPostJob() override;
537 virtual void setTargetThread(agx::Thread *thread) override;
538
539 protected:
540 virtual ~ParallelTask();
541
542 friend class Solver;
544
545 private:
546 class PreJob : public Job
547 {
548 public:
549 virtual ~PreJob();
550
551 private:
552 virtual void implementation() override;
553 };
554
555 class PostJob : public Job
556 {
557 public:
558 virtual ~PostJob();
559
560 private:
561 virtual void implementation() override;
562 };
563
564 class DispatchJob : public Job
565 {
566 public:
567 virtual ~DispatchJob();
568
569 private:
570 virtual void implementation() override;
571 };
572
573 private:
574 PreJob m_preJob;
575 PostJob m_postJob;
576 DispatchJob m_dispatchJob;
577 JobPtrVector m_jobStack;
578 Index m_jobIndexCounter;
579 };
580
581
586 {
587 public:
588 TaskGroup(const agx::Name& name, bool isSequential = true, agx::Device *device = agx::CpuDevice::instance());
589
591 bool isSequential() const;
592
593 void setSequential(bool flag);
594
599 void addSubtask(agx::Task *subtask);
600
602 void addSubtaskBetween(agx::Task *subtask, agx::Task *parent, agx::Task *child);
603 void addSubtaskBetween(agx::Task *subtask, const agx::String& parent, const agx::String& child);
604
606 void addSubtaskAfter(agx::Task *subtask, agx::Task *parent);
607 void addSubtaskAfter(agx::Task *subtask, const agx::String& parent);
608
610 void addSubtaskBefore(agx::Task *subtask, agx::Task *child);
611 void addSubtaskBefore(agx::Task *subtask, const agx::String& child);
612
617 void removeSubtask(agx::Task *subtask);
618
623 void removeSubtask(const agx::Name& name);
624
629
633 void serialize(bool recursive = false);
634
638 const agx::TaskRefVector& getSubtasks() const;
639
643 agx::Task *getSubtask(const agx::String& name, size_t index = 0);
644
645
646 virtual void traverse(const Callback1<Task *>& callback, bool breadthFirst = true);
647
649
650
651 virtual agx::Job* getPreJob() override;
652 virtual agx::Job* getPostJob() override;
653 virtual void setTargetThread(agx::Thread* thread) override;
654
655 protected:
656 virtual ~TaskGroup();
657
658 private:
659 friend class Task;
660 void registerSubtask(Task* subtask);
661 void endCallback();
662
663 private:
664 class PreJob : public Job
665 {
666 public:
667 virtual ~PreJob();
668
669 private:
670 virtual void implementation() override;
671 };
672
673 class PostJob : public Job
674 {
675 public:
676 virtual ~PostJob();
677
678 private:
679 virtual void implementation() override;
680 };
681
682 private:
683 friend class Solver;
684
685 bool m_sequential;
686 PreJob m_preJob;
687 PostJob m_postJob;
688 TaskRefVector m_subtasks;
689 };
690
691 /* Implementation */
693
694 AGX_FORCE_INLINE bool Task::isEnabled() const { return m_enabled; }
695 AGX_FORCE_INLINE bool Task::isRunning() const { return m_running; }
697 AGX_FORCE_INLINE const TaskGroup *Task::getGroup() const { return m_group; }
698
699
700 AGX_FORCE_INLINE const TaskPtrVector& Task::getParents() const { return m_parents; }
701 AGX_FORCE_INLINE const TaskPtrVector& Task::getChildren() const { return m_children; }
702 AGX_FORCE_INLINE Thread *Task::getTargetThread() { return m_targetThread; }
703
704
705 AGX_FORCE_INLINE const ParameterPtrVector& Task::getParameters() const { return m_parameters; }
706 AGX_FORCE_INLINE Parameter *Task::getParameter(const Name& name) { return this->getObject<Parameter>(name); }
707 AGX_FORCE_INLINE const Parameter *Task::getParameter(const Name& name) const { return const_cast<Task *>(this)->getParameter(name); }
708
709 AGX_FORCE_INLINE ScalarParameter *Task::getScalarParameter(const Name& name) { return this->getObject<ScalarParameter>(name); }
710 AGX_FORCE_INLINE const ScalarParameter *Task::getScalarParameter(const Name& name) const { return const_cast<Task *>(this)->getScalarParameter(name); }
711
712 AGX_FORCE_INLINE ArrayParameter *Task::getArrayParameter(const Name& name) { return this->getObject<ArrayParameter>(name); }
713 AGX_FORCE_INLINE const ArrayParameter *Task::getArrayParameter(const Name& name) const { return const_cast<Task *>(this)->getArrayParameter(name); }
714
715 AGX_FORCE_INLINE PointerParameter *Task::getPointerParameter(const Name& name) { return this->getObject<PointerParameter>(name); }
716 AGX_FORCE_INLINE const PointerParameter *Task::getPointerParameter(const Name& name) const { return const_cast<Task *>(this)->getPointerParameter(name); }
717
718 AGX_FORCE_INLINE Parameter *Task::getParameter(size_t index) { return m_parameters[index]; }
719 AGX_FORCE_INLINE const Parameter *Task::getParameter(size_t index) const { return m_parameters[index]; }
720
721 AGX_FORCE_INLINE Thread *Task::getDispatchThread() { return m_dispatchThread; }
722
723 AGX_FORCE_INLINE Real32 Task::getWallTime() const { return m_wallTime; }
724 AGX_FORCE_INLINE Real32 Task::getComputeCost() const { return m_computeCost; }
725 AGX_FORCE_INLINE Real32 Task::getOverheadTime() const { return m_overheadTime; }
726 AGX_FORCE_INLINE Real32 Task::getAccumulatedWallTime() const { return m_accumulatedWallTime; }
727 AGX_FORCE_INLINE Real32 Task::getAccumulatedOverheadTime() const { return m_accumulatedOverheadTime; }
728 AGX_FORCE_INLINE Real32 Task::getAccumulatedComputeCost() const { return m_accumulatedComputeCost; }
729 AGX_FORCE_INLINE UInt Task::getNumAccumulationSamples() const { return m_numAccumulations; }
730
731
732
733 // TaskGroup
734 AGX_FORCE_INLINE bool TaskGroup::isSequential() const { return m_sequential; }
735 AGX_FORCE_INLINE const TaskRefVector& TaskGroup::getSubtasks() const { return m_subtasks; }
736
737
738}
739
740#endif /* _AGX_TASK_H_ */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXCORE_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Only use as member allocated variable.
Definition: Value.h:285
Abstract representation of a value.
Definition: Value.h:49
Array parameter.
Definition: Parameter.h:329
Templated callback with one argument.
Definition: Callback.h:101
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
static CpuDevice * instance()
An agx::Device is an abstract representation of a device on which data can be stored and processed.
Definition: Device.h:58
An event with one argument.
Definition: Event.h:103
An event with two arguments.
Definition: Event.h:122
T CallbackType
Definition: Event.h:37
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks.
Definition: Job.h:63
Inheritance with partial specialization due to bug with ref_ptr containers.
A model is an abstract representation of the class of an agx::Object.
Definition: Model.h:41
Representation of a name string.
Definition: Name.h:33
agx::Object is a refcounted object with a name.
Definition: Object.h:59
ParallelTask.
Definition: Task.h:516
Job * getDispatchJob()
ParallelTask(const agx::Name &name, const agx::Job::Callback &dispatchCallback, agx::Device *device=agx::CpuDevice::instance())
ParallelTask(const agx::Name &name, agx::Device *device=agx::CpuDevice::instance())
void setDispatch(const agx::Job::Callback &dispatchCallback)
virtual agx::Job * getPreJob() override
virtual agx::Job * getPostJob() override
virtual void setTargetThread(agx::Thread *thread) override
Set a specific thread which must execute this task.
virtual ~ParallelTask()
void removeAllJobs()
Remove all jobs (except the original pre/dispatch/post jobs)
void addJob(agx::Job *job)
Add a job to the task.
A representation of a task/kernel parameter, which can be bound using a string path or explicitly to ...
Definition: Parameter.h:62
Representation of a path, a list of name components.
Definition: Path.h:33
Pointer parameter.
Definition: Parameter.h:435
Scalar parameter.
Definition: Parameter.h:256
SerialTask.
Definition: Task.h:470
SerialTask(const agx::Name &name, const Job::Callback &runCallback, agx::Device *device=agx::CpuDevice::instance())
SerialTask(const agx::Name &name, agx::Device *device=agx::CpuDevice::instance())
virtual ~SerialTask()
virtual agx::Job * getPostJob() override
virtual agx::Job * getPreJob() override
void setDispatch(const Job::Callback &dispatchCallback)
Specify the task dispatch to execute.
virtual void run()
Execution callback.
Definition: Task.h:485
virtual void setTargetThread(agx::Thread *thread) override
Set a specific thread which must execute this task.
TaskGroup.
Definition: Task.h:586
void serialize(bool recursive=false)
Serialize the task.
void setSequential(bool flag)
void removeSubtask(const agx::Name &name)
Remove a subtask by name.
void addSubtaskAfter(agx::Task *subtask, agx::Task *parent)
Add a subtask to be executed after a specified task.
void addSubtaskBetween(agx::Task *subtask, agx::Task *parent, agx::Task *child)
Add a subtask between two existing tasks.
agx::Task * getSubtask(const agx::String &name, size_t index=0)
void addSubtaskBefore(agx::Task *subtask, agx::Task *child)
Add a subtask to be executed before a specified task.
void addSubtaskBefore(agx::Task *subtask, const agx::String &child)
virtual agx::Job * getPreJob() override
void addSubtask(agx::Task *subtask)
Add a subtask.
void addSubtaskBetween(agx::Task *subtask, const agx::String &parent, const agx::String &child)
void addSubtaskAfter(agx::Task *subtask, const agx::String &parent)
virtual void setTargetThread(agx::Thread *thread) override
Set a specific thread which must execute this task.
virtual ~TaskGroup()
void removeSubtask(agx::Task *subtask)
Remove a subtask.
virtual agx::Job * getPostJob() override
bool isSequential() const
Definition: Task.h:734
void removeAllSubtasks()
Remove all subtasks.
void writeDependencyDotGraph() const
TaskGroup(const agx::Name &name, bool isSequential=true, agx::Device *device=agx::CpuDevice::instance())
const agx::TaskRefVector & getSubtasks() const
Definition: Task.h:735
virtual void traverse(const Callback1< Task * > &callback, bool breadthFirst=true)
A representation of a generic task.
Definition: Task.h:58
ExecutionEvent completionEvent
Triggered after the task has completed.
Definition: Task.h:97
virtual void wait()
Block until the task has completed execution.
virtual void rebind() override
void connectToChild(Task *descendant)
agx::Thread * getTargetThread()
Definition: Task.h:702
const agx::TaskPtrVector & getParents() const
Definition: Task.h:700
void addParameter(agx::Parameter *parameter, size_t index)
void addDependency(agx::Task *parent)
Add a dependency.
static void setProfilingMode(ProfilingMode mode)
void setEnable(bool flag)
Enable/disable a task.
static Task * load(const String &path, Device *device=CpuDevice::instance())
void print() const
Event2< Task *, Parameter * > ParameterEvent
Definition: Task.h:91
void printBindings()
void removeDependency(agx::Task *parent)
Remove a dependency.
static Task * load(TiXmlElement *eTask, Device *device)
bool hasDependency(agx::Task *parent) const
ParameterEvent removeParameterEvent
Triggered when a parameter is removed.
Definition: Task.h:103
static bool hasUnhandledException()
void prepareGlobalResultSorting(size_t numJobs)
virtual void setContext(agx::Object *context) override
ProfilingMode
Definition: Task.h:80
@ PROFILING_FAST
Definition: Task.h:82
@ PROFILING_NONE
Definition: Task.h:81
void disconnectFromParent(Task *ancestor)
void init()
agx::Parameter * getParameter(const agx::Name &name)
Definition: Task.h:706
bool isRunning() const
Definition: Task.h:695
ExecutionEvent startEvent
Triggered before the task begins.
Definition: Task.h:94
bool isEnabled() const
Definition: Task.h:694
virtual void setTargetThread(agx::Thread *thread)
Set a specific thread which must execute this task.
void registerBufferReadersAndWriters()
UInt32 matchParameters(agx::ParameterBindingVector &bindings, bool allowFormatPromotions)
UInt32 matchParameters(const ParameterTable &bindings)
void removeParameter(size_t index)
void save(agx::TiXmlElement *parent) const override
void beginCallback()
ParameterMatch
Used for tracing mismatched parameter bindings.
Definition: Task.h:111
static void addConnection(Task *parent, Task *child)
UInt32 matchParameters(const agx::ParameterBindingVector &bindings)
virtual agx::Job * getPostJob()=0
virtual Object * getResourceImpl(const Path &path, agx::Model *model) override
static Task * load(const Path &path, const Name &implementation, agx::ParameterBindingVector &parameterList, bool allowFormatPromotions, Device *device=CpuDevice::instance())
void dispatchBlocking(Thread *thread)
void setGroup(TaskGroup *group)
void addTriggerPath(const agx::Path &path)
virtual void configure(TiXmlElement *eTask) override
void addDependency(const agx::Path &path)
void unregisterBufferReadersAndWriters()
ParameterEvent addParameterEvent
Triggered when a parameter is added.
Definition: Task.h:100
void addTriggerPaths(const agx::String &paths)
agx::PointerParameter * getPointerParameter(const agx::Name &name)
Definition: Task.h:715
const agx::ParameterPtrVector & getParameters() const
Definition: Task.h:705
agx::Real32 getOverheadTime() const
Definition: Task.h:725
static void printParameterMatch(UInt32 parameterMatch)
virtual void parameterAddedCallback(Parameter *)
Definition: Task.h:341
static Task * load(const Path &path, const Name &implementation, Device *device=CpuDevice::instance())
agx::Thread * getDispatchThread()
Definition: Task.h:721
void addResolvePaths(const agx::String &paths)
static ProfilingMode getProfilingMode()
Definition: Task.h:692
void enableCallback(agxData::Value *enable)
static void removeConnection(Task *parent, Task *child)
void connectToParent(Task *ancestor)
const agx::TaskPtrVector & getChildren() const
Definition: Task.h:701
Event1< Task * > ExecutionEvent
Definition: Task.h:90
virtual agx::Job * getPreJob()=0
void print(std::ostream &stream) const
void printBindings(std::ostream &stream)
virtual ~Task()
virtual void parameterRemovedCallback(Parameter *)
Definition: Task.h:342
agx::UInt getNumAccumulationSamples() const
Definition: Task.h:729
static Task * load(const char *path, Device *device=CpuDevice::instance())
static Task * load(const Path &path, const Name &implementation, const agx::ParameterBindingVector &parameterList, Device *device=CpuDevice::instance())
Task(const agx::Name &name, agx::Device *device=agx::CpuDevice::instance())
Constructor.
void verifyParameters()
void addParameter(agx::Parameter *parameter)
Add a parameter.
static Task * load(const Path &path, Device *device=CpuDevice::instance())
agx::TaskGroup * getGroup()
Definition: Task.h:696
static void signalUnhandledException()
void endCallback(agx::Real32 computeCost, agx::Real32 overheadCost=0)
void traverse(const Callback1< Task * > &callback, bool breadthFirst=true)
void addDependencies(const agx::String &paths)
agx::Real32 getWallTime() const
Performance statistics.
Definition: Task.h:723
static agx::Model * ClassModel()
agx::ScalarParameter * getScalarParameter(const agx::Name &name)
Definition: Task.h:709
void removeParameter(agx::Parameter *parameter)
Remove a parameter.
agx::Real32 getAccumulatedWallTime() const
Definition: Task.h:726
agx::ArrayParameter * getArrayParameter(const agx::Name &name)
Definition: Task.h:712
void replace(agx::Task *other)
Replace the task with another task by rerouting the dependencies.
void resetAccumulationTimers(bool recursive=true)
Reset accumulated performance statistics.
void execute()
Execute the task.
virtual void subtaskAddedCallback(Task *)
Definition: Task.h:343
void setModel(agx::Model *model)
agx::Real32 getAccumulatedComputeCost() const
Definition: Task.h:728
void configure(TiXmlElement *eTask, bool loadParameters)
agx::Real32 getAccumulatedOverheadTime() const
Definition: Task.h:727
agx::Real32 getComputeCost() const
Definition: Task.h:724
agxData::Val< Bool > enableParameter
Enable/disable the task, normally use setEnable/isEnabled instead.
Definition: Task.h:106
void addResolvePath(const agx::Path &path)
void disconnectFromChild(Task *descendant)
agx::Thread is a representation of an OS specific implementation of a computational thread.
Definition: Thread.h:200
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Definition: Timer.h:62
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:32
agx::observer_ptr< Object > ObjectObserver
Definition: Object.h:50
uint64_t UInt
Definition: Integer.h:27
float Real32
Definition: Real.h:44
VectorPOD< class Job * > JobPtrVector
Definition: Job.h:51
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
agx::ref_ptr< Object > ObjectRef
Definition: Object.h:50
UInt32 Index
Definition: Integer.h:44