ROSE  0.11.145.0
AstSharedMemoryParallelSimpleProcessing.h
1 // Author: Gergo Barany
2 // $Id: AstSharedMemoryParallelSimpleProcessing.h,v 1.1 2008/01/08 02:56:39 dquinlan Exp $
3 
4 // Class for parallelizing AstSimpleProcessing traversals; see the comment in
5 // AstSharedMemoryParallelProcessing.h for general information.
6 
7 #ifndef ASTSHAREDMEMORYPARALLELSIMPLEPROCESSING_H
8 #define ASTSHAREDMEMORYPARALLELSIMPLEPROCESSING_H
9 
10 #include "AstSimpleProcessing.h"
11 #include "AstSharedMemoryParallelProcessing.h"
12 
13 // parallel SIMPLE processing class
14 
15 // Class representing a traversal that can run in parallel with some other instances of the same type. It is basically a
16 // combined processing class with a thin synchronization layer. The user will probably never need to instantiate this
17 // class, they should use the AstSharedMemoryParallel*Processing classes instead.
21 {
22 public:
26  typedef Superclass::TraversalPtrList TraversalPtrList;
27 
30  const TraversalPtrList &);
31 
32  void set_runningParallelTraversal(bool val);
33 
34 protected:
35  virtual void visit(SgNode *astNode);
36  virtual void atTraversalEnd();
37 
38 private:
39  size_t visitedNodes;
40  bool runningParallelTraversal;
41  size_t synchronizationWindowSize;
42 };
43 
44 // Class for parallel execution of a number of traversals. This is a drop-in
45 // replacement for the corresponding AstCombined*Processing class, the usage
46 // is identical except that you call traverseInParallel() instead of
47 // traverse(). (Calling traverse() is identical to AstCombined*Processing,
48 // i.e. it will not run in parallel.)
51 {
52 public:
55  typedef Superclass::TraversalPtrList TraversalPtrList;
56 
58  typedef std::vector<ParallelizableTraversalPtr> ParallelizableTraversalPtrList;
59 
61  AstSharedMemoryParallelSimpleProcessing(const TraversalPtrList &, int threads);
62 
63  void traverseInParallel(SgNode *basenode, t_traverseOrder treeTraverseOrder);
64 
65 private:
66  size_t numberOfThreads;
67  size_t synchronizationWindowSize;
68 };
69 
70 // parallel PRE POST processing class
71 
72 // Class representing a traversal that can run in parallel with some other instances of the same type. It is basically a
73 // combined processing class with a thin synchronization layer. The user will probably never need to instantiate this
74 // class, they should use the AstSharedMemoryParallel*Processing classes instead.
78 {
79 public:
83  typedef Superclass::TraversalPtrList TraversalPtrList;
84 
87  const TraversalPtrList &);
88 
89  void set_runningParallelTraversal(bool val);
90 
91 protected:
92  virtual void preOrderVisit(SgNode *astNode);
93  virtual void atTraversalEnd();
94 
95 private:
96  size_t visitedNodes;
97  bool runningParallelTraversal;
98  size_t synchronizationWindowSize;
99 };
100 
101 // Class for parallel execution of a number of traversals. This is a drop-in
102 // replacement for the corresponding AstCombined*Processing class, the usage
103 // is identical except that you call traverseInParallel() instead of
104 // traverse(). (Calling traverse() is identical to AstCombined*Processing,
105 // i.e. it will not run in parallel.)
108 {
109 public:
112  typedef Superclass::TraversalPtrList TraversalPtrList;
113 
115  typedef std::vector<ParallelizableTraversalPtr> ParallelizableTraversalPtrList;
116 
118  AstSharedMemoryParallelPrePostProcessing(const TraversalPtrList &,int threads);
119 
120  void traverseInParallel(SgNode *basenode);
121 
122 private:
123  size_t numberOfThreads;
124  size_t synchronizationWindowSize;
125 };
126 
127 #endif
Class for traversing the AST.
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9846
virtual void visit(SgNode *astNode)
this method is called at every traversed node.
virtual void preOrderVisit(SgNode *astNode)
these methods are called at every traversed node.