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 "itkOpenCLContext.h"
42 #include <mutex>
43 
44 namespace itk
45 {
64 class ITKOpenCL_EXPORT GPUDataManager : public Object //DataObject//
65 {
67  friend class OpenCLKernelManager;
68 
69 public:
71 
73  typedef Object Superclass;
74  typedef SmartPointer< Self > Pointer;
75  typedef SmartPointer< const Self > ConstPointer;
76 
78  itkNewMacro( Self );
79 
81  itkTypeMacro( GPUDataManager, Object );
82 
83  using MutexHolderType = std::lock_guard<std::mutex>;
84 
86  void SetBufferSize( unsigned int num );
87 
88  unsigned int GetBufferSize()
89  {
90  return m_BufferSize;
91  }
92 
93  void SetBufferFlag( cl_mem_flags flags );
94 
95  void SetCPUBufferPointer( void * ptr );
96 
97  void SetCPUDirtyFlag( bool isDirty );
98 
99  void SetGPUDirtyFlag( bool isDirty );
100 
104 
108 
110  {
111  return m_IsCPUBufferDirty;
112  }
113 
115  {
116  return m_IsGPUBufferDirty;
117  }
118 
120  virtual void UpdateCPUBuffer();
121 
123  virtual void UpdateGPUBuffer();
124 
125  void Allocate();
126 
128  bool Update();
129 
131  virtual void Graft( const GPUDataManager * data );
132 
134  virtual void Initialize();
135 
138 
141 
143  void SetCPUBufferLock( const bool v ) { this->m_CPUBufferLock = v; }
144  itkGetConstReferenceMacro( CPUBufferLock, bool );
145 
147  void SetGPUBufferLock( const bool v ) { this->m_GPUBufferLock = v; }
148  itkGetConstReferenceMacro( GPUBufferLock, bool );
149 
150 protected:
151 
153  ~GPUDataManager() override;
154  void PrintSelf( std::ostream & os, Indent indent ) const override;
155 
156 protected:
157 
158  unsigned int m_BufferSize; // # of bytes
159 
161 
163  cl_mem_flags m_MemFlags;
164 
166  cl_mem m_GPUBuffer;
167  void * m_CPUBuffer;
168 
172 
176 
178  std::mutex m_Mutex;
179 };
180 
181 } // namespace itk
182 
183 #endif
GPU memory manager implemented using OpenCL. Required by GPUImage class.
void SetCPUBufferLock(const bool v)
void SetBufferSize(unsigned int num)
void SetCPUBufferPointer(void *ptr)
SmartPointer< const Self > ConstPointer
void SetGPUBufferLock(const bool v)
OpenCLContext * m_Context
cl_mem * GetGPUBufferPointer()
virtual void UpdateGPUBuffer()
virtual void Initialize()
unsigned int GetBufferSize()
SmartPointer< Self > Pointer
ITK_DISALLOW_COPY_AND_ASSIGN(GPUDataManager)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void Graft(const GPUDataManager *data)
void SetCPUDirtyFlag(bool isDirty)
virtual void UpdateCPUBuffer()
void SetBufferFlag(cl_mem_flags flags)
void SetGPUDirtyFlag(bool isDirty)
~GPUDataManager() override
std::lock_guard< std::mutex > MutexHolderType
void * GetCPUBufferPointer()
The OpenCLContext class represents an OpenCL context.
OpenCL kernel manager implemented using OpenCL.
#define ITKOpenCL_EXPORT


Generated on 1667476801 for elastix by doxygen 1.9.1 elastix logo