forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkComputingResources.h
156 lines (123 loc) · 5.07 KB
/
vtkComputingResources.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
/*=========================================================================
Program: Visualization Toolkit
Module: vtkComputingResources.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 vtkComputingResources - Definition of computing resource
// (threads/kernels)
// .SECTION Description
// This is a class for distribute the number of threads to a network of modules
// .SECTION See Also
// vtkExecutionScheduler
#ifndef __vtkComputingResources_h
#define __vtkComputingResources_h
#include "vtkObject.h"
class vtkInformation;
class vtkProcessingUnitResource;
class vtkThreadedStreamingPipeline;
class VTK_FILTERING_EXPORT vtkComputingResources : public vtkObject
{
public:
static vtkComputingResources* New();
vtkTypeMacro(vtkComputingResources,vtkObject);
void PrintSelf(ostream &os, vtkIndent indent);
// Description:
// Set resources to an empty states
void Clear();
// Description:
// Assign a minimum amount of usable resources to this object,
// e.g. 1 thread
void ObtainMinimumResources();
// Description:
// Assign a maximum amount of usable resources to this object
void ObtainMaximumResources();
//BTX
// Description:
// Return the resources of a specific type of processing unit that
// is hold in this object
vtkProcessingUnitResource *GetResourceFor(int processingUnit);
//ETX
// Description:
// Assign the resources and information of this object to an
// executive, i.e., set the number of threads of the algorithm the
// executive is pointing to
void Deploy(vtkThreadedStreamingPipeline *exec, vtkInformation *info);
// Description:
// Take an amount of computing resources out of this object. Return
// true if it is successful.
bool Reserve(vtkComputingResources *res);
// Description:
// Add an amount of computing resources to this object
void Collect(vtkComputingResources *res);
protected:
vtkComputingResources();
~vtkComputingResources();
//BTX
class implementation;
implementation* const Implementation;
//ETX
private:
vtkComputingResources(const vtkComputingResources&); // Not implemented.
void operator=(const vtkComputingResources&); // Not implemented.
};
//BTX
//----------------------------------------------------------------------------
// A basic resource class. It is put here for later inheritance for
// any type of computing, e.g. CPU/GPU.
//----------------------------------------------------------------------------
class vtkProcessingUnitResource {
public:
virtual ~vtkProcessingUnitResource() {}
// Description:
// Return the type of unit this computing resource is holding
virtual int ProcessingUnit() = 0;
// Description:
// Return true if this resource is not empty
virtual bool HasResource() = 0;
// Description:
// Make this resource empty
virtual void Clear() = 0;
// Description:
// Give this object a minimum amount of resource it can allocate
virtual void ObtainMinimum() = 0;
// Description:
// Give this object a maximum amount of resource it can allocate
virtual void ObtainMaximum() = 0;
// Description:
// Given a ratio and a resource, increase this resource by a ratio
// of the reference resource. This is the basic function for
// resource distributing
virtual void IncreaseByRatio(float ratio, vtkProcessingUnitResource *refResource) = 0;
// Description:
// This actually set the amount of resource on the algorithm holding
// by the input executive
virtual void AllocateFor(vtkThreadedStreamingPipeline *exec) = 0;
// Description:
// Return true if this object can allocate at least refResource
virtual bool CanAccommodate(vtkProcessingUnitResource *refResource) = 0;
// Description:
// Reserve an amount of resource given by refResource from this object
virtual void Reserve(vtkProcessingUnitResource *refResource) = 0;
// Description:
// Add an amount of resource given by refResource to this object
virtual void Collect(vtkProcessingUnitResource *refResource) = 0;
};
//ETX
#endif