ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkGPUImageDataManager.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 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 > class GPUImage;
34 
43 template < typename ImageType >
44 class ITK_TEMPLATE_EXPORT GPUImageDataManager : public GPUDataManager
45 {
46  // allow GPUKernelManager to access GPU buffer pointer
47  friend class GPUKernelManager;
48  friend class GPUImage< typename ImageType::PixelType, ImageType::ImageDimension >;
49 
50 public:
51  ITK_DISALLOW_COPY_AND_ASSIGN(GPUImageDataManager);
52 
55  using Pointer = SmartPointer<Self>;
56  using ConstPointer = SmartPointer<const Self>;
57 
58  itkNewMacro(Self);
59  itkTypeMacro(GPUImageDataManager, GPUDataManager);
60 
61  static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
62 
63  itkGetModifiableObjectMacro(GPUBufferedRegionIndex, GPUDataManager);
64  itkGetModifiableObjectMacro(GPUBufferedRegionSize, GPUDataManager);
65 
66  void SetImagePointer( typename ImageType::Pointer img );
67  ImageType *GetImagePointer()
68  {
69  return this->m_Image.GetPointer();
70  }
71 
73  virtual void MakeCPUBufferUpToDate();
74 
76  virtual void MakeGPUBufferUpToDate();
77 
78 protected:
80  ~GPUImageDataManager() override {}
81 
82 private:
83  WeakPointer<ImageType> m_Image; // WeakPointer has to be used here
84  // to avoid SmartPointer loop
85  int m_BufferedRegionIndex[ImageType::ImageDimension];
86  int m_BufferedRegionSize[ImageType::ImageDimension];
89 
90 };
91 
92 } // namespace itk
93 
94 #ifndef ITK_MANUAL_INSTANTIATION
95 #include "itkGPUImageDataManager.hxx"
96 #endif
97 
98 #endif
Light weight base class for most itk classes.
GPUDataManager::Pointer m_GPUBufferedRegionSize
ObjectType * GetPointer() const noexcept
GPU memory manager implemented using OpenCL. Required by GPUImage class.
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:40
GPUDataManager::Pointer m_GPUBufferedRegionIndex
GPU kernel manager implemented using OpenCL.
WeakPointer< ImageType > m_Image