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
44namespace itk
45{
64class ITKOpenCL_EXPORT GPUDataManager : public Object // DataObject//
65{
67 friend class OpenCLKernelManager;
68
69public:
71
73 using Superclass = Object;
74 using Pointer = SmartPointer<Self>;
75 using ConstPointer = SmartPointer<const Self>;
76
78 itkNewMacro(Self);
79
81 itkTypeMacro(GPUDataManager, Object);
82
83 using MutexHolderType = std::lock_guard<std::mutex>;
84
86 void
87 SetBufferSize(unsigned int num);
88
89 unsigned int
91 {
92 return m_BufferSize;
93 }
94
95 void
96 SetBufferFlag(cl_mem_flags flags);
97
98 void
100
101 void
102 SetCPUDirtyFlag(bool isDirty);
103
104 void
105 SetGPUDirtyFlag(bool isDirty);
106
109 void
111
114 void
116
117 bool
119 {
120 return m_IsCPUBufferDirty;
121 }
122
123 bool
125 {
126 return m_IsGPUBufferDirty;
127 }
128
130 virtual void
132
134 virtual void
136
137 void
139
141 bool
143
145 virtual void
146 Graft(const GPUDataManager * data);
147
149 virtual void
151
153 cl_mem *
155
157 void *
159
161 void
162 SetCPUBufferLock(const bool v)
163 {
164 this->m_CPUBufferLock = v;
165 }
166 itkGetConstReferenceMacro(CPUBufferLock, bool);
167
169 void
170 SetGPUBufferLock(const bool v)
171 {
172 this->m_GPUBufferLock = v;
173 }
174 itkGetConstReferenceMacro(GPUBufferLock, bool);
175
176protected:
178 ~GPUDataManager() override;
179 void
180 PrintSelf(std::ostream & os, Indent indent) const override;
181
182protected:
183 unsigned int m_BufferSize{}; // # of bytes
184
185 OpenCLContext * m_Context{};
186
188 cl_mem_flags m_MemFlags{};
189
191 cl_mem m_GPUBuffer{};
192 void * m_CPUBuffer{};
193
195 bool m_IsGPUBufferDirty{};
196 bool m_IsCPUBufferDirty{};
197
199 bool m_CPUBufferLock{};
200 bool m_GPUBufferLock{};
201
203 std::mutex m_Mutex{};
204};
205
206} // namespace itk
207
208#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)
void SetGPUBufferLock(const bool v)
SmartPointer< const Self > ConstPointer
ITK_DISALLOW_COPY_AND_MOVE(GPUDataManager)
virtual void UpdateGPUBuffer()
virtual void Initialize()
void * GetCPUBufferPointer()
unsigned int GetBufferSize()
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void Graft(const GPUDataManager *data)
cl_mem * GetGPUBufferPointer()
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
The OpenCLContext class represents an OpenCL context.
OpenCL kernel manager implemented using OpenCL.
#define ITKOpenCL_EXPORT


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo