forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkExecutionScheduler.h
171 lines (134 loc) · 5.85 KB
/
vtkExecutionScheduler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*=========================================================================
Program: Visualization Toolkit
Module: vtkExecutionScheduler.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright (c) 2008, 2009 by SCI Institute, University of Utah.
This is part of the Parallel Dataflow System originally developed by
Huy T. Vo and Claudio T. Silva. For more information, see:
"Parallel Dataflow Scheme for Streaming (Un)Structured Data" by Huy
T. Vo, Daniel K. Osmari, Brian Summa, Joao L.D. Comba, Valerio
Pascucci and Claudio T. Silva, SCI Institute, University of Utah,
Technical Report #UUSCI-2009-004, 2009.
"Multi-Threaded Streaming Pipeline For VTK" by Huy T. Vo and Claudio
T. Silva, SCI Institute, University of Utah, Technical Report
#UUSCI-2009-005, 2009.
-------------------------------------------------------------------------*/
// .NAME vtkExecutionScheduler - Scheduling execution with
// thread/computing resources distributing
// .SECTION Description
// This is a class for balancing the computing resources throughout
// the network
// .SECTION See Also
// vtkComputingResources vtkThreadedStreamingPipeline
#ifndef __vtkExecutionScheduler_h
#define __vtkExecutionScheduler_h
#include "vtkObject.h"
class vtkExecutive;
class vtkComputingResources;
class vtkMultiThreader;
class vtkMutexLock;
class vtkThreadMessager;
class vtkInformation;
class vtkInformationIntegerKey;
class vtkExecutiveCollection;
class VTK_FILTERING_EXPORT vtkExecutionScheduler : public vtkObject
{
public:
static vtkExecutionScheduler* New();
vtkTypeMacro(vtkExecutionScheduler,vtkObject);
void PrintSelf(ostream &os, vtkIndent indent);
// Description:
// Return the global instance of the scheduler
static vtkExecutionScheduler *GetGlobalScheduler();
// Description:
// Key to store the priority of a task
static vtkInformationIntegerKey* TASK_PRIORITY();
// Description:
// Put the current set of executives (modules) to the be scheduled given its
// dependency graph which will be used to compute the set
// topological orders
void Schedule(vtkExecutiveCollection *execs, vtkInformation *info);
// Description:
// Put the current set of executives (modules) to the be scheduled
// given its dependency graph which will be used to compute the set
// topological orders. Then wait for their execution to be complete
void SchedulePropagate(vtkExecutiveCollection *execs, vtkInformation *info);
// Description:
// Wait until the current set of executives (modules) have finished executing
void WaitUntilDone(vtkExecutiveCollection *execs);
// Description:
// Wait until the current set of executives (modules) have their inputs released
void WaitUntilReleased(vtkExecutiveCollection *execs);
// Description:
// Wait for all tasks to be done
void WaitUntilAllDone();
// Description:
// Wait for a task that is on the scheduling queue to be done. If
// the task is not there, this will return immediately. If the exec
// is NULL, any task that is done will trigger this the return
void WaitForTaskDone(vtkExecutive *exec);
// Description:
// Similar to WaitForTaskDone but return whenever input connections
// of a task are released instead of done computing. But exec cannot
// be NULL.
void WaitForInputsReleased(vtkExecutive *exec);
// Description:
// Return the thread messager reserved for the given exec to notify
// when it is done
vtkThreadMessager* GetTaskDoneMessager(vtkExecutive *exec);
// Description:
// Return the thread messager reserved for the given exec to notify
// when it releases its inputs
vtkThreadMessager* GetInputsReleasedMessager(vtkExecutive *exec);
// Description:
// Return the mutex lock reserved for the given exec to notify
// when it releases its inputs
vtkMutexLock* GetInputsReleasedLock(vtkExecutive *exec);
// Description:
// Release the resources that are being used by the given exec
void ReleaseResources(vtkExecutive *exec);
// Description:
// Re-acquire the resource released earlier by ReleaseResource
void ReacquireResources(vtkExecutive *exec);
// Description:
// Redistribute the thread resources over the network from a sink
// with a maximum resource
void RescheduleNetwork(vtkExecutive *sink);
// Description:
// Redistribute the thread resources from a sink given a certain
// amount of resource
void RescheduleFrom(vtkExecutive *sink, vtkComputingResources *resources);
protected:
vtkExecutionScheduler();
~vtkExecutionScheduler();
vtkComputingResources *Resources;
vtkThreadMessager *ScheduleMessager;
vtkThreadMessager *ResourceMessager;
vtkMutexLock *ScheduleLock;
vtkMultiThreader *ScheduleThreader;
int ScheduleThreadId;
//BTX
class implementation;
implementation* const Implementation;
friend class implementation;
// Description:
// The scheduling thread that is responsible for queueing up module
// execution in the right order
friend void * vtkExecutionScheduler_ScheduleThread(void *data);
// Description:
// Execute thread function that is responsible for forking process
// for each module
friend void * vtkExecutionScheduler_ExecuteThread(void *data);
//ETX
private:
vtkExecutionScheduler(const vtkExecutionScheduler&); // Not implemented.
void operator=(const vtkExecutionScheduler&); // Not implemented.
};
#endif