7 #ifndef PXR_EXEC_EF_PAGE_CACHE_BASED_EXECUTOR_H 8 #define PXR_EXEC_EF_PAGE_CACHE_BASED_EXECUTOR_H 14 #include "pxr/exec/ef/loftedOutputSet.h" 27 PXR_NAMESPACE_OPEN_SCOPE
41 template <
typename>
class EngineType,
42 typename DataManagerType>
55 _engine(*this, &this->_dataManager),
56 _cacheStorage(cacheStorage),
86 const VdfMask &mask)
const override;
91 const VdfMask &mask)
const override;
100 const VdfRequest &computeRequest,
105 bool _IsCaching()
const;
113 bool _InvalidateOutput(
115 const VdfMask &invalidationMask)
override;
119 virtual bool _PreProcessInvalidation(
120 const VdfMaskedOutputVector &invalidationRequest,
121 VdfMaskedOutputVector *processedRequest)
override;
124 void _ClearDataForOutput(
129 EngineType<DataManagerType> _engine;
145 template <
template <
typename>
class EngineType,
typename DataManagerType>
154 Base::SetOutputValue(output, value, mask);
159 if (_cacheStorage->_IsKeyOutput(output, mask)) {
160 _currentCache = _cacheStorage->_GetOrCreateCache(value);
164 template <
template <
typename>
class EngineType,
typename DataManagerType>
169 _loftedOutputs.RemoveAllOutputsForNode(node);
173 template <
template <
typename>
class EngineType,
typename DataManagerType>
184 Base::_dataManager.GetInputValue(connection, mask)) {
193 template <
template <
typename>
class EngineType,
typename DataManagerType>
205 Base::_dataManager.GetOutputValueForReading(
206 Base::_dataManager.GetDataHandle(output.
GetId()), mask)) {
211 return _GetPageCacheValue(output, mask);
214 template <
template <
typename>
class EngineType,
typename DataManagerType>
218 const VdfRequest &computeRequest,
222 if (computeRequest.IsEmpty()) {
230 _loftedOutputs.Resize(*schedule.
GetNetwork());
234 if (
TF_VERIFY(_currentCache) && _IsCaching()) {
235 const DataManagerType &dataManager = Base::_dataManager;
236 const VdfRequest &cacheableRequest =
237 _cacheStorage->GetCacheableRequest(computeRequest);
238 VdfRequest::IndexedView cacheableView(cacheableRequest);
243 schedule, computeRequest, errorLogger,
244 [&dataManager, &cacheableView, cache, storage]
249 const VdfVector *value = dataManager.GetOutputValueForReading(
252 if (!value || !cacheableView.Get(requestedIndex)) {
266 storage->_Commit(mo, *value, &access);
272 _engine.RunSchedule(schedule, computeRequest, errorLogger);
276 template <
template <
typename>
class EngineType,
typename DataManagerType>
281 _cacheStorage->IsEnabled() &&
285 template <
template <
typename>
class EngineType,
typename DataManagerType>
297 if (!_currentCache) {
305 if (
const VdfVector *cachedValue = cacheAccess.GetValue(output, mask)) {
308 if (_loftedOutputs.Add(output, mask)) {
311 Base::_TouchOutput(output);
323 template <
template <
typename>
class EngineType,
typename DataManagerType>
327 const VdfMask &invalidationMask)
330 if (Base::_InvalidateOutput(output, invalidationMask)) {
333 _loftedOutputs.Remove(
345 template <
template <
typename>
class EngineType,
typename DataManagerType>
348 const VdfMaskedOutputVector &invalidationRequest,
349 VdfMaskedOutputVector *processedRequest)
353 const size_t numLoftedOutputs = _loftedOutputs.GetSize();
354 if (numLoftedOutputs == 0) {
362 _cacheStorage->_FindDependencies(invalidationRequest);
371 processedRequest->reserve(
372 invalidationRequest.size() +
373 std::min(numLoftedOutputs, deps.size()));
378 _loftedOutputs.CollectLoftedDependencies(deps, processedRequest);
379 if (processedRequest->empty()) {
386 processedRequest->insert(
387 processedRequest->end(),
388 invalidationRequest.begin(), invalidationRequest.end());
397 template <
template <
typename>
class EngineType,
typename DataManagerType>
402 Base::_ClearDataForOutput(outputId, nodeId);
403 _loftedOutputs.Remove(outputId, nodeId,
VdfMask());
407 template <
template <
typename>
class EngineType,
typename DataManagerType>
411 _loftedOutputs.Clear();
414 PXR_NAMESPACE_CLOSE_SCOPE
A class that fully represents a connection between two VdfNodes.
const VdfMask & GetMask() const
Returns the VdfMask.
A client may instantiate an object of this class and set it in an executor, to collect errors that ma...
Base class for executors that use a data manager.
Manages a page cache and provides methods for invalidation of cached values.
VdfId GetId() const
The unique id of this output.
virtual const VdfVector * _GetOutputValueForReading(const VdfOutput &output, const VdfMask &mask) const override
Returns an output value for reading.
This is the base class for all nodes in a VdfNetwork.
VdfId GetId() const
Returns the unique id of this node in its network.
A VdfMask is placed on connections to specify the data flowing through them.
This accessor grants shared read access to the cache, preventing any concurrent write access.
An output-to-value storage for caching.
This class is used to abstract away knowledge of the cache data used for each node.
virtual ~EfPageCacheBasedExecutor()
Destructor.
Executes a VdfNetwork to compute a requested set of values.
const VdfOutput & GetSourceOutput() const
Returns the output (ie. source) for this connection.
const VdfNetwork * GetNetwork() const
Returns the network for this schedule.
static EF_API bool HasReachedMemoryLimit()
Returns true, if the upper memory limit has been reached, and the object is no longer allowed to allo...
Contains a specification of how to execute a particular VdfNetwork.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
virtual void _ClearData() override
Virtual implementation of ClearData, which can optionally be overridden by derived classes.
#define TRACE_FUNCTION()
Records a timestamp when constructed and a timespan event when destructed, using the name of the func...
An accessor that provides exclusive read/write access to the cache.
std::unordered_map< const VdfOutput *, VdfMask, TfHash > VdfOutputToMaskMap
A map from output pointer to mask.
Class to hold on to an externally owned output and a mask.
A VdfOutput represents an output on a node.
const VdfNode & GetNode() const
Returns the owning node for this output.
VdfOutput * GetOutput() const
Returns the VdfOutput.
virtual const VdfVector * _GetInputValue(const VdfConnection &connection, const VdfMask &mask) const override
Returns value for the cache that flows across connection.
EfPageCacheBasedExecutor(EfPageCacheStorage *cacheStorage)
Constructor.
void WillDeleteNode(const VdfNode &node)
Removes any internal references to node upon deleting the node from the VdfNetwork.
Tracks the set of lofted outputs (outputs whose values were sourced from the page cache during evalua...
virtual void SetOutputValue(const VdfOutput &output, const VdfVector &value, const VdfMask &mask) override
Set an output value.
uint64_t VdfId
The unique identifier type for Vdf objects.