AGX Dynamics 2.42.2.1
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/Component.h>
23#include <agx/Parameter.h>
24#include <agx/Referenced.h>
25#include <agx/String.h>
26#include <agx/Vector.h>
27#include <agx/Statistics.h>
28
29#include <agxData/Buffer.h>
31
32
33namespace agx
34{
35 class TiXmlElement;
36 class Solver;
37 class Thread;
38 class Clock;
39 class TaskTimingReportHandle;
40
46
47
48
49
57 {
58 public:
60
61 // Allow concatenated syntax: path.to.tasks:implementationName
62 static Task* load(const String& path, Device* device = CpuDevice::instance());
63 static Task* load(const char* path, Device* device = CpuDevice::instance());
64
65 static Task* load(TiXmlElement *eTask, Device* device);
66 static Task* load(const Path& path, Device* device = CpuDevice::instance());
67 // static Task *load(const String& path, Device *device, const String& implementation);
68 static Task* load(const Path& path, const Name& implementation, Device* device = CpuDevice::instance());
69
70 static Task* load(const Path& path, const Name& implementation, const agx::ParameterBindingVector& parameterList, Device* device = CpuDevice::instance());
71 static Task* load(const Path& path, const Name& implementation, agx::ParameterBindingVector& parameterList, bool allowFormatPromotions, Device* device = CpuDevice::instance());
72
73 virtual void configure(TiXmlElement* eTask) override;
74 void configure(TiXmlElement* eTask, bool loadParameters);
75
76 void save(agx::TiXmlElement* parent) const override;
77
79 {
82 PROFILING_FULL
83 };
84
86 static ProfilingMode getProfilingMode();
87
88 public:
91
94
97
100
103
106
107 public:
108
111 NO_EVENTS = 0,
112
113 // Bits set to indicate events that does not imply a failed match.
114 EMPTY_BINDING_LIST = (1<<0), // Matched by default since the list of supplied parameters was empty.
115 PARAMETER_VALID = (1<<1), // A parameter was valid and therefore didn't need a new binding.
116 PARAMETER_NOT_REQUIRED = (1<<2), // A parameter was marked as not required and therefore didn't need a new binding.
117 PARAMETER_BOUND = (1<<3), // A parameter was already bound and therefore didn't need a new binding.
118 PARAMETER_HAS_BOUND_PATH = (1<<4), // A parameter has a bind path already and therefore didn't need a new binding.
119 FORMATS_MATCH = (1<<5), // A parameter and a new binding had the same format.
120 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.
121
122 // Bits set to signal a failed match.
123 MISSING_BINDING = (1<<7), // When a task has a parameter that needs a new binding but didn't get one.
124 BINDING_LACKS_TYPE = (1<<8), // A new binding didn't have a type.
125 FORMATS_MISSMATCH = (1<<9), // The format of a new binding was incompatible with the parameter format.
126 EXTRA_BINDING = (1<<10), // There were new bindings that didn't have a corresponding parameter.
127 INCONSISTEN_PARAMETERS = (1<<11), // Don't think this can ever happen. Means that a loop over all parameters didn't visit all of them.
128
129 // Mask of all events that doesn't imply a failed match.
130 // Note that the NO_MATCH_MASK test has precendence, so match-testing should only use that.
131 MATCH_MASK = EMPTY_BINDING_LIST | PARAMETER_VALID | PARAMETER_NOT_REQUIRED | PARAMETER_BOUND | PARAMETER_HAS_BOUND_PATH | FORMATS_MATCH | NEED_DEVICE_TRANSFORM,
132
133 // 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.
134 NO_MATCH_MASK = MISSING_BINDING | BINDING_LACKS_TYPE | FORMATS_MISSMATCH | EXTRA_BINDING | INCONSISTEN_PARAMETERS
135 };
136 static void printParameterMatch( UInt32 parameterMatch );
137
138 public:
144
148 void execute();
149
153 virtual void wait();
154
158 bool isRunning() const;
159
163 void setEnable(bool flag);
164
168 bool isEnabled() const;
169
173 virtual void setTargetThread(agx::Thread *thread);
174
178 agx::Thread *getTargetThread();
179
183 agx::Thread *getDispatchThread();
184
188 void addParameter(agx::Parameter *parameter);
189 void addParameter(agx::Parameter *parameter, size_t index);
190
195 void removeParameter(size_t index);
196
200 const agx::ParameterPtrVector& getParameters() const;
201
205 agx::Parameter *getParameter(const agx::Name& name);
206 const agx::Parameter *getParameter(const agx::Name& name) const;
207
208 // ScalarParameter
209 agx::ScalarParameter *getScalarParameter(const agx::Name& name);
210 const agx::ScalarParameter *getScalarParameter(const agx::Name& name) const;
211
212 // ArrayParameter
213 agx::ArrayParameter *getArrayParameter(const agx::Name& name);
214 const agx::ArrayParameter *getArrayParameter(const agx::Name& name) const;
215
216 // PointerParameter
217 agx::PointerParameter *getPointerParameter(const agx::Name& name);
218 const agx::PointerParameter *getPointerParameter(const agx::Name& name) const;
219
223 agx::Parameter *getParameter(size_t index);
224 const agx::Parameter *getParameter(size_t index) const;
225
226
229 UInt32 matchParameters(agx::ParameterBindingVector& bindings, bool allowFormatPromotions);
230
234 agx::TaskGroup *getGroup();
235 const agx::TaskGroup *getGroup() const;
236
237
241 const agx::TaskPtrVector& getParents() const;
242
246 const agx::TaskPtrVector& getChildren() const;
247
248
249
255 void addDependency(const agx::Path& path);
256 void addDependencies(const agx::String& paths); // Semi-colon separated
257
263
264 // Search recursively for a parent dependency
265 bool hasDependency(agx::Task *parent) const;
266
270 void replace(agx::Task *other);
271
272 void traverse(const Callback1<Task *>& callback, bool breadthFirst = true);
273
274 void print() const;
275 void print(std::ostream& stream) const;
277 void printBindings(std::ostream& stream);
278
279 virtual void setContext( agx::Object* context ) override;
280 void setModel(agx::Model *model);
281
282 public:
286 virtual agx::Job *getPreJob() = 0;
287
291 virtual agx::Job *getPostJob() = 0;
292
293
294
295 public:
296 virtual void rebind() override;
297
298 void addTriggerPath(const agx::Path& path);
299 void addTriggerPaths(const agx::String& paths);
300 void addResolvePath(const agx::Path& path);
301 void addResolvePaths(const agx::String& paths);
302
303 public:
304
306
307
309 agx::Real32 getWallTime() const;
310
312 agx::Real32 getOverheadTime() const;
313
315 agx::Real32 getComputeCost() const;
316
317 agx::Real32 getAccumulatedWallTime() const;
318 agx::Real32 getAccumulatedOverheadTime() const;
319 agx::Real32 getAccumulatedComputeCost() const;
320 agx::UInt getNumAccumulationSamples() const;
321
323 void resetAccumulationTimers(bool recursive = true);
324
325 // private
327 void endCallback(agx::Real32 computeCost, agx::Real32 overheadCost = 0);
328
329 protected:
330
331 virtual ~Task();
332
333
334 // void setGroup(Task *group);
336
337 static void addConnection(Task *parent, Task *child);
338 static void removeConnection(Task *parent, Task *child);
339
340 virtual void parameterAddedCallback(Parameter* /*parameter*/) {}
341 virtual void parameterRemovedCallback(Parameter* /*parameter*/) {}
342 virtual void subtaskAddedCallback(Task* /*subtask*/) {}
343
344 // Must be called after the number of kernel jobs is known, during dispatch
345 void prepareGlobalResultSorting(size_t numJobs);
346
347 protected:
348 friend class Component;
349 friend class UnresolvedTask;
350 friend class TaskManager;
351 friend class Solver;
352
353 void init();
354
355 // void defaultRunCallback();
359 void disconnectFromParent(Task* ancestor);
360 void disconnectFromChild(Task* descendant);
361 void connectToParent(Task* ancestor);
362 void connectToChild(Task* descendant);
364
365 friend class TaskGroup;
366 void setGroup(TaskGroup *group);
367
368
369 friend class Thread;
372
373#ifndef SWIG
374 virtual Object *getResourceImpl(const Path& path, agx::Model *model) override;
375#endif
376
377 private:
378 bool m_enabled;
379 std::atomic<bool> m_running;
380
381 Thread *m_targetThread;
382 Thread *m_dispatchThread;
383 Timer m_overheadTimer;
384 // Timer m_runTimer;
385 Timer m_wallTimer;
386
387
388
389 // Currently not decided how task timer reporting will be handled, with internal Real32s or through Statistics.
390 // Keeping both as part of the object for now since we do not want to have to change this header file when
391 // changing the reporting strategy.
392 Real32 m_wallTime;
393 Real32 m_computeCost;
394 Real32 m_overheadTime;
395 Real32 m_accumulatedWallTime;
396 Real32 m_accumulatedComputeCost;
397 Real32 m_accumulatedOverheadTime;
398 UInt m_numAccumulations;
399
400 TaskTimingReportHandleRef m_statisticsHandle;
401
402
403 TaskGroup *m_group;
404 TaskPtrVector m_parents;
405 TaskPtrVector m_children;
406
407 ParameterPtrVector m_parameters;
408 ParameterPtrVector m_globalResultParameters;
410
411 struct BindPath
412 {
413 enum Type
414 {
415 INVALID=-1,
416 DEPENDENCY,
417 RESOLVE,
418 TRIGGER
419 };
420
421 BindPath() : type((Type)agx::InvalidIndex), binding(nullptr) {}
422 BindPath(const Path& _path, Type _type) : path(_path), type(_type), binding(nullptr) {}
423
424 Path path;
425 Type type;
426 ObjectRef binding;
427 };
428
429 Vector<BindPath> m_bindPaths;
430 Path m_bindContextPath;
431 ObjectObserver m_bindContext;
432
433 AGX_DECLARE_POINTER_TYPES(DisableHelper);
434 class DisableHelper : public Referenced
435 {
436 public:
437 DisableHelper(Task *task);
438
439 void restore();
440
441 void registerSubtask(Task* subtask);
442 void removeSubtask(Task* subtask);
443
444 protected:
445 virtual ~DisableHelper();
446
447 private:
448 void emptyPre();
449 void emptyPost();
450
451 private:
452 Task *m_task;
453 JobPtrVector m_oldPreChildren;
454 UInt32 m_oldNumPostDependencies;
455 Callback m_oldPre;
456 Callback m_oldPost;
457 };
458
459 DisableHelperRef m_disableHelper;
460
461 static ProfilingMode s_profilingMode;
462 };
463
464
469 {
470 public:
472
473 SerialTask(const agx::Name& name, const Job::Callback& runCallback, agx::Device* device = agx::CpuDevice::instance());
474
478 void setDispatch(const Job::Callback& dispatchCallback);
479
480
484 virtual void run() {}
485
486
488
489 virtual agx::Job *getPreJob() override;
490 virtual agx::Job *getPostJob() override;
491 virtual void setTargetThread(agx::Thread *thread) override;
492
493 protected:
494 virtual ~SerialTask();
495
496 private:
497 class SerialJob : public Job
498 {
499 public:
500 virtual ~SerialJob();
501
502 private:
503 virtual void implementation() override;
504 };
505
506 private:
507 SerialJob m_job;
508 };
509
510
515 {
516 public:
518 ParallelTask(const agx::Name& name, const agx::Job::Callback& dispatchCallback, agx::Device* device = agx::CpuDevice::instance());
519
523 void addJob(agx::Job *job);
524
529
531
532 void setDispatch(const agx::Job::Callback& dispatchCallback);
533
534 virtual agx::Job *getPreJob() override;
535 virtual agx::Job *getPostJob() override;
536 virtual void setTargetThread(agx::Thread *thread) override;
537
538 protected:
539 virtual ~ParallelTask();
540
541 friend class Solver;
543
544 private:
545 class PreJob : public Job
546 {
547 public:
548 virtual ~PreJob();
549
550 private:
551 virtual void implementation() override;
552 };
553
554 class PostJob : public Job
555 {
556 public:
557 virtual ~PostJob();
558
559 private:
560 virtual void implementation() override;
561 };
562
563 class DispatchJob : public Job
564 {
565 public:
566 virtual ~DispatchJob();
567
568 private:
569 virtual void implementation() override;
570 };
571
572 private:
573 PreJob m_preJob;
574 PostJob m_postJob;
575 DispatchJob m_dispatchJob;
576 JobPtrVector m_jobStack;
577 Index m_jobIndexCounter;
578 };
579
580
585 {
586 public:
587 TaskGroup(const agx::Name& name, bool isSequential = true, agx::Device *device = agx::CpuDevice::instance());
588
590 bool isSequential() const;
591
592 void setSequential(bool flag);
593
598 void addSubtask(agx::Task *subtask);
599
601 void addSubtaskBetween(agx::Task *subtask, agx::Task *parent, agx::Task *child);
602 void addSubtaskBetween(agx::Task *subtask, const agx::String& parent, const agx::String& child);
603
605 void addSubtaskAfter(agx::Task *subtask, agx::Task *parent);
606 void addSubtaskAfter(agx::Task *subtask, const agx::String& parent);
607
609 void addSubtaskBefore(agx::Task *subtask, agx::Task *child);
610 void addSubtaskBefore(agx::Task *subtask, const agx::String& child);
611
616 void removeSubtask(agx::Task *subtask);
617
622 void removeSubtask(const agx::Name& name);
623
628
632 void serialize(bool recursive = false);
633
637 const agx::TaskRefVector& getSubtasks() const;
638
642 agx::Task *getSubtask(const agx::String& name, size_t index = 0);
643
644
645 virtual void traverse(const Callback1<Task *>& callback, bool breadthFirst = true);
646
648
649
650 virtual agx::Job* getPreJob() override;
651 virtual agx::Job* getPostJob() override;
652 virtual void setTargetThread(agx::Thread* thread) override;
653
654 protected:
655 virtual ~TaskGroup();
656
657 private:
658 friend class Task;
659 void registerSubtask(Task* subtask);
660 void endCallback();
661
662 private:
663 class PreJob : public Job
664 {
665 public:
666 virtual ~PreJob();
667
668 private:
669 virtual void implementation() override;
670 };
671
672 class PostJob : public Job
673 {
674 public:
675 virtual ~PostJob();
676
677 private:
678 virtual void implementation() override;
679 };
680
681 private:
682 friend class Solver;
683
684 bool m_sequential;
685 PreJob m_preJob;
686 PostJob m_postJob;
687 TaskRefVector m_subtasks;
688 };
689
690 /* Implementation */
692
693 AGX_FORCE_INLINE bool Task::isEnabled() const { return m_enabled; }
694 AGX_FORCE_INLINE bool Task::isRunning() const { return m_running; }
696 AGX_FORCE_INLINE const TaskGroup *Task::getGroup() const { return m_group; }
697
698
699 AGX_FORCE_INLINE const TaskPtrVector& Task::getParents() const { return m_parents; }
700 AGX_FORCE_INLINE const TaskPtrVector& Task::getChildren() const { return m_children; }
701 AGX_FORCE_INLINE Thread *Task::getTargetThread() { return m_targetThread; }
702
703
704 AGX_FORCE_INLINE const ParameterPtrVector& Task::getParameters() const { return m_parameters; }
705 AGX_FORCE_INLINE Parameter *Task::getParameter(const Name& name) { return this->getObject<Parameter>(name); }
706 AGX_FORCE_INLINE const Parameter *Task::getParameter(const Name& name) const { return const_cast<Task *>(this)->getParameter(name); }
707
708 AGX_FORCE_INLINE ScalarParameter *Task::getScalarParameter(const Name& name) { return this->getObject<ScalarParameter>(name); }
709 AGX_FORCE_INLINE const ScalarParameter *Task::getScalarParameter(const Name& name) const { return const_cast<Task *>(this)->getScalarParameter(name); }
710
711 AGX_FORCE_INLINE ArrayParameter *Task::getArrayParameter(const Name& name) { return this->getObject<ArrayParameter>(name); }
712 AGX_FORCE_INLINE const ArrayParameter *Task::getArrayParameter(const Name& name) const { return const_cast<Task *>(this)->getArrayParameter(name); }
713
714 AGX_FORCE_INLINE PointerParameter *Task::getPointerParameter(const Name& name) { return this->getObject<PointerParameter>(name); }
715 AGX_FORCE_INLINE const PointerParameter *Task::getPointerParameter(const Name& name) const { return const_cast<Task *>(this)->getPointerParameter(name); }
716
717 AGX_FORCE_INLINE Parameter *Task::getParameter(size_t index) { return m_parameters[index]; }
718 AGX_FORCE_INLINE const Parameter *Task::getParameter(size_t index) const { return m_parameters[index]; }
719
720 AGX_FORCE_INLINE Thread *Task::getDispatchThread() { return m_dispatchThread; }
721
722 AGX_FORCE_INLINE Real32 Task::getWallTime() const { return m_wallTime; }
723 AGX_FORCE_INLINE Real32 Task::getComputeCost() const { return m_computeCost; }
724 AGX_FORCE_INLINE Real32 Task::getOverheadTime() const { return m_overheadTime; }
725 AGX_FORCE_INLINE Real32 Task::getAccumulatedWallTime() const { return m_accumulatedWallTime; }
726 AGX_FORCE_INLINE Real32 Task::getAccumulatedOverheadTime() const { return m_accumulatedOverheadTime; }
727 AGX_FORCE_INLINE Real32 Task::getAccumulatedComputeCost() const { return m_accumulatedComputeCost; }
728 AGX_FORCE_INLINE UInt Task::getNumAccumulationSamples() const { return m_numAccumulations; }
729
730
731
732 // TaskGroup
733 AGX_FORCE_INLINE bool TaskGroup::isSequential() const { return m_sequential; }
734 AGX_FORCE_INLINE const TaskRefVector& TaskGroup::getSubtasks() const { return m_subtasks; }
735
736
737}
738
739#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:61
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:515
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:469
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:484
virtual void setTargetThread(agx::Thread *thread) override
Set a specific thread which must execute this task.
TaskGroup.
Definition: Task.h:585
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:733
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:734
virtual void traverse(const Callback1< Task * > &callback, bool breadthFirst=true)
A representation of a generic task.
Definition: Task.h:57
ExecutionEvent completionEvent
Triggered after the task has completed.
Definition: Task.h:96
virtual void wait()
Block until the task has completed execution.
virtual void rebind() override
void connectToChild(Task *descendant)
agx::Thread * getTargetThread()
Definition: Task.h:701
const agx::TaskPtrVector & getParents() const
Definition: Task.h:699
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:90
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:102
static bool hasUnhandledException()
void prepareGlobalResultSorting(size_t numJobs)
virtual void setContext(agx::Object *context) override
ProfilingMode
Definition: Task.h:79
@ PROFILING_FAST
Definition: Task.h:81
@ PROFILING_NONE
Definition: Task.h:80
void disconnectFromParent(Task *ancestor)
void init()
agx::Parameter * getParameter(const agx::Name &name)
Definition: Task.h:705
bool isRunning() const
Definition: Task.h:694
ExecutionEvent startEvent
Triggered before the task begins.
Definition: Task.h:93
bool isEnabled() const
Definition: Task.h:693
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:110
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:99
void addTriggerPaths(const agx::String &paths)
agx::PointerParameter * getPointerParameter(const agx::Name &name)
Definition: Task.h:714
const agx::ParameterPtrVector & getParameters() const
Definition: Task.h:704
agx::Real32 getOverheadTime() const
Definition: Task.h:724
static void printParameterMatch(UInt32 parameterMatch)
virtual void parameterAddedCallback(Parameter *)
Definition: Task.h:340
static Task * load(const Path &path, const Name &implementation, Device *device=CpuDevice::instance())
agx::Thread * getDispatchThread()
Definition: Task.h:720
void addResolvePaths(const agx::String &paths)
static ProfilingMode getProfilingMode()
Definition: Task.h:691
void enableCallback(agxData::Value *enable)
static void removeConnection(Task *parent, Task *child)
void connectToParent(Task *ancestor)
const agx::TaskPtrVector & getChildren() const
Definition: Task.h:700
Event1< Task * > ExecutionEvent
Definition: Task.h:89
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:341
agx::UInt getNumAccumulationSamples() const
Definition: Task.h:728
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:695
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:722
static agx::Model * ClassModel()
agx::ScalarParameter * getScalarParameter(const agx::Name &name)
Definition: Task.h:708
void removeParameter(agx::Parameter *parameter)
Remove a parameter.
agx::Real32 getAccumulatedWallTime() const
Definition: Task.h:725
agx::ArrayParameter * getArrayParameter(const agx::Name &name)
Definition: Task.h:711
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:342
void setModel(agx::Model *model)
agx::Real32 getAccumulatedComputeCost() const
Definition: Task.h:727
void configure(TiXmlElement *eTask, bool loadParameters)
agx::Real32 getAccumulatedOverheadTime() const
Definition: Task.h:726
agx::Real32 getComputeCost() const
Definition: Task.h:723
agxData::Val< Bool > enableParameter
Enable/disable the task, normally use setEnable/isEnabled instead.
Definition: Task.h:105
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:199
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:43
VectorPOD< class Job * > JobPtrVector
Definition: Job.h:49
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
agx::ref_ptr< Object > ObjectRef
Definition: Object.h:50
UInt32 Index
Definition: Integer.h:44