Loading...
Searching...
No Matches
maskedSubExecutor.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_EF_MASKED_SUB_EXECUTOR_H
8#define PXR_EXEC_EF_MASKED_SUB_EXECUTOR_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/ef/api.h"
15
19#include "pxr/exec/vdf/types.h"
20
21#include <tbb/concurrent_unordered_map.h>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
26class VdfSchedule;
27
41class EF_API_TYPE EfMaskedSubExecutor : public VdfDatalessExecutor
42{
43 // Executor factory.
44 typedef
45 VdfExecutorFactory<
50 VdfDataManagerDeallocationMode::Background > > >
51 _Factory;
52
53public:
54
60 EF_API
62
65 EF_API
67
70 const VdfExecutorFactoryBase &GetFactory() const override {
71 return _factory;
72 }
73
77 EF_API
78 virtual void DuplicateOutputData(
79 const VdfOutput &sourceOutput,
80 const VdfOutput &destOutput);
81
90 virtual bool IsEmpty() const {
91 return false;
92 }
93
102 const VdfOutput &source,
103 const VdfOutput &dest) const {
104 const VdfExecutorInterface *parentExecutor = GetParentExecutor();
105 return
106 parentExecutor &&
107 parentExecutor->HasInvalidationTimestampMismatch(source, dest);
108 }
109
110protected:
111
112 // This executor supports invalidation. Any invalid output will not be
113 // read from the parent executor.
114 //
115 virtual bool _InvalidateOutput(
116 const VdfOutput &output,
117 const VdfMask &invalidationMask);
118
119 // This executor does not store temporary data caches, instead the locally
120 // stored invalidation state will be cleared out.
121 //
122 virtual void _ClearData();
123
124private:
125
126 // Running this executor is not supported.
127 //
128 virtual void _Run(
129 const VdfSchedule &schedule,
130 const VdfRequest &computeRequest,
131 VdfExecutorErrorLogger *errorLogger);
132
133 // Returns an output value for reading.
134 //
135 inline virtual const VdfVector *_GetOutputValueForReading(
136 const VdfOutput &output,
137 const VdfMask &mask) const override;
138
139 // Returns \c true if the output is already invalid for the given
140 // \p invalidationMask.
141 //
142 virtual bool _IsOutputInvalid(
143 const VdfId outputId,
144 const VdfMask &invalidationMask) const override;
145
146 // The factory shared amongst executors of this type.
147 //
148 static const _Factory _factory;
149
150 // A set of invalid outputs. Note, that after creating this executor, all
151 // outputs are considered valid. As outputs become invalid, they are added
152 // to the set of invalid outputs.
153 //
154 using _InvalidOutputs = tbb::concurrent_unordered_map<VdfId, VdfMask>;
155 _InvalidOutputs _invalidOutputs;
156};
157
159
160const VdfVector *
161EfMaskedSubExecutor::_GetOutputValueForReading(
162 const VdfOutput &output,
163 const VdfMask &mask) const
164{
165 // If the output has not been invalidated on this executor, return the
166 // value stored at the parent executor. Otherwise, return NULL.
167 const VdfExecutorInterface *parentExecutor = GetParentExecutor();
168 _InvalidOutputs::const_iterator it =
169 _invalidOutputs.find(output.GetId());
170 if (parentExecutor &&
171 (it == _invalidOutputs.end() || !it->second.Overlaps(mask))) {
172 return parentExecutor->GetOutputValue(output, mask);
173 }
174 return NULL;
175}
176
177PXR_NAMESPACE_CLOSE_SCOPE
178
179#endif
This sub-executor masks the parent executor.
virtual bool HasInvalidationTimestampMismatch(const VdfOutput &source, const VdfOutput &dest) const
Returns true if the invalidation timestamps mismatch between the source and dest outputs.
virtual EF_API ~EfMaskedSubExecutor()
Destructor.
virtual EF_API void DuplicateOutputData(const VdfOutput &sourceOutput, const VdfOutput &destOutput)
Duplicates the output data associated with sourceOutput and copies it to destOutput.
virtual bool _InvalidateOutput(const VdfOutput &output, const VdfMask &invalidationMask)
Called during invalidation to mark outputs as invalid and determine when the traversal can terminate ...
const VdfExecutorFactoryBase & GetFactory() const override
Factory construction.
virtual void _ClearData()
Clears all the data caches associated with any output in the network.
virtual bool IsEmpty() const
Indicates whether this executor contains data.
EF_API EfMaskedSubExecutor(const VdfExecutorInterface *parentExecutor)
Constructor.
This is a data manager for executors that uses data stored in a vector indexed by output ids.
An abstract base class for executors, which do not store any data at all.
virtual const VdfVector * _GetOutputValueForReading(const VdfOutput &output, const VdfMask &mask) const override
Returns an output value for reading.
A client may instantiate an object of this class and set it in an executor, to collect errors that ma...
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
virtual bool HasInvalidationTimestampMismatch(const VdfOutput &source, const VdfOutput &dest) const =0
Returns true, if the invalidation timestamps between the source and dest outputs do not match,...
virtual void _Run(const VdfSchedule &schedule, const VdfRequest &computeRequest, VdfExecutorErrorLogger *errorLogger)=0
Run this executor with the given schedule and request.
const VdfVector * GetOutputValue(const VdfOutput &output, const VdfMask &mask) const
Returns the cached value for a given output if it has a cache that contains all values specified by m...
const VdfExecutorInterface * GetParentExecutor() const
Returns the parent executor, if any.
virtual bool _IsOutputInvalid(const VdfId outputId, const VdfMask &invalidationMask) const =0
Returns true if the output is already invalid for the given invalidationMask.
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:37
A VdfOutput represents an output on a node.
Definition: output.h:32
VdfId GetId() const
The unique id of this output.
Definition: output.h:100
Contains a specification of how to execute a particular VdfNetwork.
Definition: schedule.h:41
This class provides an executor engine to the speculation executor.
Executor used in speculation.
This class is used to abstract away knowledge of the cache data used for each node.
Definition: vector.h:56
uint64_t VdfId
The unique identifier type for Vdf objects.
Definition: types.h:107