ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkGPUDataManager.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 
19 #ifndef itkGPUDataManager_h
20 #define itkGPUDataManager_h
21 
22 #include "itkObject.h"
23 #include "itkDataObject.h"
24 #include "itkObjectFactory.h"
25 #include "itkOpenCLUtil.h"
26 #include "itkGPUContextManager.h"
27 #include "itkSimpleFastMutexLock.h"
28 #include "itkMutexLockHolder.h"
29 
30 namespace itk
31 {
43 class GPUDataManager : public Object //DataObject//
44 {
46  friend class GPUKernelManager;
47 
48 public:
49 
51  typedef Object Superclass;
54 
55  itkNewMacro(Self);
56  itkTypeMacro(GPUDataManager, Object);
57 
59 
61  void SetBufferSize( unsigned int num );
62 
63  unsigned int GetBufferSize() {
64  return m_BufferSize;
65  }
66 
67  void SetBufferFlag( cl_mem_flags flags );
68 
69  void SetCPUBufferPointer( void* ptr );
70 
71  void SetCPUDirtyFlag( bool isDirty );
72 
73  void SetGPUDirtyFlag( bool isDirty );
74 
77  void SetCPUBufferDirty();
78 
81  void SetGPUBufferDirty();
82 
84  return m_IsCPUBufferDirty;
85  }
86 
88  return m_IsGPUBufferDirty;
89  }
90 
92  virtual void UpdateCPUBuffer();
93 
95  virtual void UpdateGPUBuffer();
96 
97  void Allocate();
98 
99  void SetCurrentCommandQueue( int queueid );
100 
102 
104  bool Update();
105 
107  virtual void Graft(const GPUDataManager* data);
108 
110  virtual void Initialize();
111 
113  cl_mem* GetGPUBufferPointer();
114 
116  void* GetCPUBufferPointer();
117 
118 protected:
119 
120  GPUDataManager();
121  virtual ~GPUDataManager();
122  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
123 
124 private:
125 
126  GPUDataManager(const Self&) ITK_DELETE_FUNCTION;
127  void operator=(const Self&);
128 
129 protected:
130 
131  unsigned int m_BufferSize; // # of bytes
132 
134 
136 
138  cl_mem_flags m_MemFlags;
139 
141  cl_mem m_GPUBuffer;
142  void* m_CPUBuffer;
143 
147 
150 };
151 
152 } // namespace itk
153 
154 #endif
SimpleFastMutexLock m_Mutex
void * GetCPUBufferPointer()
Critical section locking class that can be allocated on the stack.
virtual void Graft(const GPUDataManager *data)
Light weight base class for most itk classes.
MutexLockHolder< SimpleFastMutexLock > MutexHolderType
virtual void UpdateGPUBuffer()
void SetBufferFlag(cl_mem_flags flags)
A container to store a Mutex. This holder class for ensuring that locks are released in the event of ...
virtual void PrintSelf(std::ostream &os, Indent indent) const override
virtual void UpdateCPUBuffer()
GPU memory manager implemented using OpenCL. Required by GPUImage class.
void SetCPUDirtyFlag(bool isDirty)
SmartPointer< const Self > ConstPointer
int GetCurrentCommandQueueID()
void SetCurrentCommandQueue(int queueid)
GPU kernel manager implemented using OpenCL.
GPUContextManager * m_ContextManager
SmartPointer< Self > Pointer
Singleton class to store the GPU context.
void SetCPUBufferPointer(void *ptr)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
cl_mem * GetGPUBufferPointer()
Base class for most ITK classes.
Definition: itkObject.h:57
virtual void Initialize()
virtual ~GPUDataManager()
void SetBufferSize(unsigned int num)
unsigned int GetBufferSize()
void SetGPUDirtyFlag(bool isDirty)