go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGPUDataManager.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
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 *
20 * Copyright Insight Software Consortium
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0.txt
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
34 *=========================================================================*/
35 #ifndef __itkGPUDataManager_h
36 #define __itkGPUDataManager_h
37 
38 #include "itkObject.h"
39 #include "itkDataObject.h"
40 #include "itkObjectFactory.h"
41 #include "itkSimpleFastMutexLock.h"
42 #include "itkMutexLockHolder.h"
43 
44 #include "itkOpenCLContext.h"
45 
46 namespace itk
47 {
66 class ITKOpenCL_EXPORT GPUDataManager : public Object //DataObject//
67 {
69  friend class OpenCLKernelManager;
70 
71 public:
72 
74  typedef Object Superclass;
76  typedef SmartPointer< const Self > ConstPointer;
77 
79  itkNewMacro( Self );
80 
82  itkTypeMacro( GPUDataManager, Object );
83 
84  typedef MutexLockHolder< SimpleFastMutexLock > MutexHolderType;
85 
87  void SetBufferSize( unsigned int num );
88 
89  unsigned int GetBufferSize()
90  {
91  return m_BufferSize;
92  }
93 
94 
95  void SetBufferFlag( cl_mem_flags flags );
96 
97  void SetCPUBufferPointer( void * ptr );
98 
99  void SetCPUDirtyFlag( bool isDirty );
100 
101  void SetGPUDirtyFlag( bool isDirty );
102 
105  void SetCPUBufferDirty();
106 
109  void SetGPUBufferDirty();
110 
112  {
113  return m_IsCPUBufferDirty;
114  }
115 
116 
118  {
119  return m_IsGPUBufferDirty;
120  }
121 
122 
124  virtual void UpdateCPUBuffer();
125 
127  virtual void UpdateGPUBuffer();
128 
129  void Allocate();
130 
132  bool Update();
133 
135  virtual void Graft( const GPUDataManager * data );
136 
138  virtual void Initialize();
139 
141  cl_mem * GetGPUBufferPointer();
142 
144  void * GetCPUBufferPointer();
145 
147  void SetCPUBufferLock( const bool v ) { this->m_CPUBufferLock = v; }
148  itkGetConstReferenceMacro( CPUBufferLock, bool );
149 
151  void SetGPUBufferLock( const bool v ) { this->m_GPUBufferLock = v; }
152  itkGetConstReferenceMacro( GPUBufferLock, bool );
153 
154 protected:
155 
156  GPUDataManager();
157  virtual ~GPUDataManager();
158  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
159 
160 private:
161 
162  GPUDataManager( const Self & ); // purposely not implemented
163  void operator=( const Self & ); // purposely not implemented
164 
165 protected:
166 
167  unsigned int m_BufferSize; // # of bytes
168 
170 
172  cl_mem_flags m_MemFlags;
173 
175  cl_mem m_GPUBuffer;
176  void * m_CPUBuffer;
177 
181 
185 
187  SimpleFastMutexLock m_Mutex;
188 };
189 
190 } // namespace itk
191 
192 #endif
SimpleFastMutexLock m_Mutex
MutexLockHolder< SimpleFastMutexLock > MutexHolderType
OpenCLContext * m_Context
GPU memory manager implemented using OpenCL. Required by GPUImage class.
OpenCL kernel manager implemented using OpenCL.
The OpenCLContext class represents an OpenCL context.
void SetGPUBufferLock(const bool v)
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
void SetCPUBufferLock(const bool v)
#define ITKOpenCL_EXPORT
unsigned int GetBufferSize()


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo