HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGE_PropagateGroup.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __PDGE_PROPAGATE_GROUP_H__
10 #define __PDGE_PROPAGATE_GROUP_H__
11 
12 #include "PDGE_API.h"
13 
14 #include "PDGE_Dependency.h"
15 #include "PDGE_DependencyOwner.h"
16 
17 #include <UT/UT_Array.h>
18 #include <UT/UT_ArrayMap.h>
19 #include <UT/UT_NonCopyable.h>
20 #include <UT/UT_TBBSpinLock.h>
21 #include <UT/UT_UniquePtr.h>
22 
23 /*
24  * Provides a mechanism for a dependency owner to wait for all descendants
25  * from a given upstream dependency, without knowing what they are ahead of
26  * time. For example, this is used for targeted partitioning features and
27  * feedback loops in $PDG.
28  */
30 {
31 public:
32  /// Constructs a new propagate group with the specified owner. The owner
33  /// is used to when connecting this group to input groups and adding
34  /// entries that should only propagate to a certain depth or target node.
36  virtual ~PDGE_PropagateGroup();
37 
38  /// Returns the total memory usage of this propagate groiup
39  int64 getMemoryUsage(bool inclusive) const;
40 
41  /// Adds a target owner to the set of targets associated with this group.
42  /// These are the owners that the group may target, and the group will not
43  /// recurse beyond them when adding dependencies.
45  { myTargetOwners.insert(target); }
46 
47  /// Adds an input group to this propagate group. Dependencies are added
48  /// on input group entries, and propagate back down to this group during
49  /// evaluation.
50  inline void addInputGroup(PDGE_PropagateGroup* input_group)
51  { myInputGroups.append(input_group); }
52 
53  /// Resets the propagate group. This will free all owned dependencies and
54  /// clear all structures including input groups and targets.
55  void reset(PDGE_Dependency* extra_dependency);
56 
57  /// Adds an propagation entry to this group. The entry must have a target
58  /// owner and a root dependency. Optionally, an additional dependent can
59  /// be passed that will automatically be made to depend on the new entry.
60  ///
61  /// The root is the source dependency for which the entry is associated
62  /// with. The entry will wait for the root and all of its descendants
63  /// between the target owner and this group.
64  void addEntry(
66  PDGE_Dependency* root,
67  PDGE_Dependency* dependent);
68 
69  /// Copies relevant propagate depenencies from source onto the specified
70  /// downstream dependent, based on what propagate entries exist in this map.
71  void propagateDependencies(
73  PDGE_Dependency* destination);
74 
75  /// Returns the list of dependency owners for a propagate dependency owned
76  /// by this group.
77  void upstreamOwners(
79  PDGE_Dependency* dependency) const;
80 
81  /// Returns the root owner for a propagate dependency owned by this group
82  PDGE_DependencyOwner* rootOwner(PDGE_Dependency* dependent) const;
83 
84 private:
85  using GroupArray = UT_Array<PDGE_PropagateGroup*>;
86  using DependentArray = UT_Array<UT_UniquePtr<PDGE_Dependency>>;
87  using DependentMap = UT_ArrayMap<
90  using PropagateMap = UT_ArrayMap<
93 
94  void propagateInternal(PDGE_Dependency* source,
95  PDGE_Dependency* destination);
96  PDGE_Dependency* addEntryInternal(
98  const PDGE_DependencyOwner::Set& targets,
99  PDGE_Dependency* root,
100  PDGE_Dependency* dependent);
101  PDGE_Dependency* addEntryInternal(
102  PDGE_Dependency* root);
103 private:
104  GroupArray myInputGroups;
105  DependentArray myDependents;
106  PropagateMap myPropagateDependencies;
107  DependentMap myDependentMap;
108 
109  PDGE_DependencyOwner::Set myTargetOwners;
110  PDGE_DependencyOwner* myOwner;
111  PDGE_Dependency* myExtraDependency;
112  mutable UT_TBBSpinLock myLock;
113 };
114 
115 #endif
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GLboolean reset
Definition: glad.h:5138
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
long long int64
Definition: SYS_Types.h:116
GLenum target
Definition: glcorearb.h:1667
#define PDGE_API
Definition: PDGE_API.h:23
void addInputGroup(PDGE_PropagateGroup *input_group)
void addTarget(PDGE_DependencyOwner *target)