ITK  5.2.0
Insight Toolkit
itkGPUImageDataManager.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 itkGPUImageDataManager_h
20 #define itkGPUImageDataManager_h
21 
22 #include <itkObject.h>
23 #include <itkTimeStamp.h>
24 #include <itkLightObject.h>
25 #include <itkObjectFactory.h>
26 #include "itkOpenCLUtil.h"
27 #include "itkGPUDataManager.h"
28 #include "itkGPUContextManager.h"
29 #include <mutex>
30 
31 namespace itk
32 {
33 template <typename TPixel, unsigned int NDimension>
34 class GPUImage;
35 
44 template <typename ImageType>
45 class ITK_TEMPLATE_EXPORT GPUImageDataManager : public GPUDataManager
46 {
47  // allow GPUKernelManager to access GPU buffer pointer
48  friend class GPUKernelManager;
49  friend class GPUImage<typename ImageType::PixelType, ImageType::ImageDimension>;
50 
51 public:
52  ITK_DISALLOW_COPY_AND_MOVE(GPUImageDataManager);
53 
56  using Pointer = SmartPointer<Self>;
57  using ConstPointer = SmartPointer<const Self>;
58 
59  itkNewMacro(Self);
60  itkTypeMacro(GPUImageDataManager, GPUDataManager);
61 
62  static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
63 
64  itkGetModifiableObjectMacro(GPUBufferedRegionIndex, GPUDataManager);
65  itkGetModifiableObjectMacro(GPUBufferedRegionSize, GPUDataManager);
66 
67  void
68  SetImagePointer(ImageType * img);
69 
70  ImageType *
71  GetImagePointer()
72  {
73  return this->m_Image.GetPointer();
74  }
75 
77  virtual void
78  MakeCPUBufferUpToDate();
79 
81  virtual void
82  MakeGPUBufferUpToDate();
83 
84 protected:
85  GPUImageDataManager() = default;
86  ~GPUImageDataManager() override = default;
87 
88 private:
89  WeakPointer<ImageType> m_Image; // WeakPointer has to be used here
90  // to avoid SmartPointer loop
91  int m_BufferedRegionIndex[ImageType::ImageDimension];
92  int m_BufferedRegionSize[ImageType::ImageDimension];
95 };
96 
97 } // namespace itk
98 
99 #ifndef ITK_MANUAL_INSTANTIATION
100 # include "itkGPUImageDataManager.hxx"
101 #endif
102 
103 #endif
itkObjectFactory.h
itk::GPUImageDataManager::m_GPUBufferedRegionSize
GPUDataManager::Pointer m_GPUBufferedRegionSize
Definition: itkGPUImageDataManager.h:94
itkTimeStamp.h
itk::GPUImage
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:40
itk::SmartPointer< Self >
itkOpenCLUtil.h
itk::GPUDataManager
GPU memory manager implemented using OpenCL. Required by GPUImage class.
Definition: itkGPUDataManager.h:42
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::SmartPointer::GetPointer
ObjectType * GetPointer() const noexcept
Definition: itkSmartPointer.h:132
itk::GPUImageDataManager
Definition: itkGPUImageDataManager.h:45
itkObject.h
itk::GPUKernelManager
GPU kernel manager implemented using OpenCL.
Definition: itkGPUKernelManager.h:44
itk::WeakPointer< ImageType >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::GPUImageDataManager::m_Image
WeakPointer< ImageType > m_Image
Definition: itkGPUImageDataManager.h:89
itkGPUContextManager.h
itkLightObject.h
itk::GPUImageDataManager::m_GPUBufferedRegionIndex
GPUDataManager::Pointer m_GPUBufferedRegionIndex
Definition: itkGPUImageDataManager.h:93
itkGPUDataManager.h