HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
executor.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_EXEC_VDF_EXECUTOR_H
8 #define PXR_EXEC_VDF_EXECUTOR_H
9 
10 ///\file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/base/tf/mallocTag.h"
15 #include "pxr/base/trace/trace.h"
19 #include "pxr/exec/vdf/request.h"
22 
24 
26 class VdfSchedule;
27 
28 ///////////////////////////////////////////////////////////////////////////////
29 ///
30 /// \class VdfExecutor
31 ///
32 /// \brief Executes a VdfNetwork to compute a requested set of values.
33 ///
34 ///
35 template <
36  template <typename> class EngineType,
37  typename DataManagerType>
38 class VdfExecutor :
39  public VdfDataManagerBasedExecutor<DataManagerType, VdfExecutorInterface>
40 {
41  // Base class type.
42  typedef
44  Base;
45 
46  // The speculation executor engine alias declaration, to be bound as a
47  // template template parameter.
48  template <typename T>
49  using SpeculationEngineType =
50  typename EngineType<T>::SpeculationExecutorEngine;
51 
52  // Executor factory.
53  typedef
57  _Factory;
58 
59 public:
60 
61  /// Default constructor.
62  ///
63  VdfExecutor() : _engine(*this, &this->_dataManager) {}
64 
65  /// Destructor.
66  ///
67  virtual ~VdfExecutor() {}
68 
69  /// Factory construction.
70  ///
71  virtual const VdfExecutorFactoryBase &GetFactory() const override final {
72  return _factory;
73  }
74 
75 private:
76 
77  // Run this executor with the given \p schedule and \p request.
78  //
79  virtual void _Run(
80  const VdfSchedule &schedule,
81  const VdfRequest &computeRequest,
82  VdfExecutorErrorLogger *errorLogger) override;
83 
84  // Causes the DataManager to clear its temporary execution buffers.
85  //
86  virtual void _ClearData() override;
87 
88 private:
89 
90  // The factory shared amongst executors of this type.
91  //
92  static const _Factory _factory;
93 
94  // This is the engine that will do most of our hard work for us.
95  //
96  EngineType<DataManagerType> _engine;
97 };
98 
99 ///////////////////////////////////////////////////////////////////////////////
100 
101 template <template <typename> class EngineType, typename DataManagerType>
104 
105 template <template <typename> class EngineType, typename DataManagerType>
106 void
108  const VdfSchedule &schedule,
109  const VdfRequest &computeRequest,
110  VdfExecutorErrorLogger *errorLogger)
111 {
112  // If we have an empty request, bail.
113  if (computeRequest.IsEmpty()) {
114  return;
115  }
116 
117  TRACE_FUNCTION();
118  TfAutoMallocTag2 tag("Ef", "VdfExecutor::Run");
119 
120  _engine.RunSchedule(schedule, computeRequest, errorLogger);
121 }
122 
123 template <template <typename> class EngineType, typename DataManagerType>
124 void
126 {
127  Base::_dataManager.Clear();
128 }
129 
131 
132 #endif
VdfExecutor()
Definition: executor.h:63
virtual const VdfExecutorFactoryBase & GetFactory() const overridefinal
Definition: executor.h:71
virtual ~VdfExecutor()
Definition: executor.h:67
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
VDF_API bool IsEmpty() const
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:626
Executes a VdfNetwork to compute a requested set of values.
Definition: executor.h:38
Executor used in speculation.
Contains a specification of how to execute a particular VdfNetwork.
Definition: schedule.h:40
#define TRACE_FUNCTION()
Definition: trace.h:30
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74