7 #ifndef PXR_EXEC_EF_PAGE_CACHE_BASED_EXECUTOR_H
8 #define PXR_EXEC_EF_PAGE_CACHE_BASED_EXECUTOR_H
18 #include "pxr/base/tf/mallocTag.h"
41 template <
typename>
class EngineType,
42 typename DataManagerType>
56 _cacheStorage(cacheStorage),
60 TF_VERIFY(_cacheStorage);
105 bool _IsCaching()
const;
113 bool _InvalidateOutput(
115 const VdfMask &invalidationMask)
override;
119 virtual bool _PreProcessInvalidation(
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>
222 if (computeRequest.
IsEmpty()) {
227 TfAutoMallocTag2 tag(
"Ef",
"EfPageCacheBasedExecutor::Run");
230 _loftedOutputs.Resize(*schedule.
GetNetwork());
234 if (TF_VERIFY(_currentCache) && _IsCaching()) {
235 const DataManagerType &dataManager = Base::_dataManager;
237 _cacheStorage->GetCacheableRequest(computeRequest);
243 schedule, computeRequest, errorLogger,
244 [&dataManager, &cacheableView, cache, storage]
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>
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();
EfPageCacheBasedExecutor(EfPageCacheStorage *cacheStorage)
virtual void _ClearData() override
const VdfNetwork * GetNetwork() const
Manages a page cache and provides methods for invalidation of cached values.
getFileOption("OpenEXR:storage") storage
#define PXR_NAMESPACE_OPEN_SCOPE
GLsizei const GLfloat * value
VDF_API bool IsEmpty() const
const VdfMask & GetMask() const
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
A VdfMask is placed on connections to specify the data flowing through them.
**But if you need a or simply need to know when the task has note that the like this
const VdfNode & GetNode() const
virtual ~EfPageCacheBasedExecutor()
An output-to-value storage for caching. The class provides accessor types for thread-safe, as well as unprotected access.
virtual const VdfVector * _GetInputValue(const VdfConnection &connection, const VdfMask &mask) const override
Executes a VdfNetwork to compute a requested set of values. Caches the computed data in a EfPageCache...
DataManagerType _dataManager
Contains a specification of how to execute a particular VdfNetwork.
GLuint GLint GLboolean GLint GLenum access
static EF_API bool HasReachedMemoryLimit()
void WillDeleteNode(const VdfNode &node)
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.
const VdfOutput & GetSourceOutput() const
Returns the output (ie. source) for this connection.
#define PXR_NAMESPACE_CLOSE_SCOPE
virtual const VdfVector * _GetOutputValueForReading(const VdfOutput &output, const VdfMask &mask) const override
std::vector< VdfMaskedOutput > VdfMaskedOutputVector
virtual void SetOutputValue(const VdfOutput &output, const VdfVector &value, const VdfMask &mask) override
VdfOutput * GetOutput() const
uint64_t VdfId
The unique identifier type for Vdf objects.