#include <itkGPUDataManager.h>
GPU memory manager implemented using OpenCL. Required by GPUImage class.
This class serves as a base class for GPU data container for GPUImage class, which is similar to ImageBase class for Image class. However, all the image-related meta data will be already stored in image class (parent of GPUImage), therefore we did not name it GPUImageBase. Rather, this class is a GPU-specific data manager that provides functionalities for CPU-GPU data synchronization and grafting GPU data.
Definition at line 42 of file itkGPUDataManager.h.
Public Types | |
using | ConstPointer = SmartPointer<const Self> |
using | MutexHolderType = std::lock_guard<std::mutex> |
using | Pointer = SmartPointer<Self> |
using | Self = GPUDataManager |
using | Superclass = Object |
![]() | |
using | ConstPointer = SmartPointer<const Self> |
using | Pointer = SmartPointer<Self> |
using | Self = Object |
using | Superclass = LightObject |
![]() | |
using | ConstPointer = SmartPointer<const Self> |
using | Pointer = SmartPointer<Self> |
using | Self = LightObject |
Public Member Functions | |
void | Allocate () |
virtual::itk::LightObject::Pointer | CreateAnother () const |
unsigned int | GetBufferSize () const |
void * | GetCPUBufferPointer () |
int | GetCurrentCommandQueueID () const |
cl_mem * | GetGPUBufferPointer () |
const char * | GetNameOfClass () const override |
virtual void | Graft (const GPUDataManager *data) |
virtual void | Initialize () |
bool | IsCPUBufferDirty () const |
bool | IsGPUBufferDirty () const |
void | SetBufferFlag (cl_mem_flags flags) |
void | SetBufferSize (unsigned int num) |
void | SetCPUBufferDirty () |
void | SetCPUBufferPointer (void *ptr) |
void | SetCPUDirtyFlag (bool isDirty) |
void | SetCurrentCommandQueue (int queueid) |
void | SetGPUBufferDirty () |
void | SetGPUDirtyFlag (bool isDirty) |
bool | Update () |
virtual void | UpdateCPUBuffer () |
virtual void | UpdateGPUBuffer () |
![]() | |
unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
LightObject::Pointer | CreateAnother () const override |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
const char * | GetNameOfClass () const override |
virtual const TimeStamp & | GetTimeStamp () const |
bool | HasObserver (const EventObject &event) const |
void | InvokeEvent (const EventObject &) |
void | InvokeEvent (const EventObject &) const |
virtual void | Modified () const |
void | Register () const override |
void | RemoveAllObservers () |
void | RemoveObserver (unsigned long tag) const |
void | SetDebug (bool debugFlag) const |
void | SetReferenceCount (int) override |
void | UnRegister () const noexcept override |
void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
void | SetMetaDataDictionary (MetaDataDictionary &&rrhs) |
virtual void | SetObjectName (std::string _arg) |
virtual const std::string & | GetObjectName () const |
![]() | |
Pointer | Clone () const |
virtual void | Delete () |
virtual int | GetReferenceCount () const |
void | Print (std::ostream &os, Indent indent=0) const |
Static Public Member Functions | |
static Pointer | New () |
![]() | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool val) |
![]() | |
static void | BreakOnError () |
static Pointer | New () |
Protected Member Functions | |
GPUDataManager () | |
void | PrintSelf (std::ostream &os, Indent indent) const override |
~GPUDataManager () override | |
![]() | |
Object () | |
bool | PrintObservers (std::ostream &os, Indent indent) const |
void | PrintSelf (std::ostream &os, Indent indent) const override |
virtual void | SetTimeStamp (const TimeStamp &timeStamp) |
~Object () override | |
![]() | |
virtual LightObject::Pointer | InternalClone () const |
LightObject () | |
virtual void | PrintHeader (std::ostream &os, Indent indent) const |
virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
virtual | ~LightObject () |
Protected Attributes | |
unsigned int | m_BufferSize {} |
int | m_CommandQueueId {} |
GPUContextManager * | m_ContextManager {} |
void * | m_CPUBuffer {} |
cl_mem | m_GPUBuffer {} |
bool | m_IsCPUBufferDirty {} |
bool | m_IsGPUBufferDirty {} |
cl_mem_flags | m_MemFlags {} |
std::mutex | m_Mutex {} |
![]() | |
std::atomic< int > | m_ReferenceCount {} |
Friends | |
class | GPUKernelManager |
using itk::GPUDataManager::ConstPointer = SmartPointer<const Self> |
Definition at line 53 of file itkGPUDataManager.h.
using itk::GPUDataManager::MutexHolderType = std::lock_guard<std::mutex> |
Definition at line 58 of file itkGPUDataManager.h.
using itk::GPUDataManager::Pointer = SmartPointer<Self> |
Definition at line 52 of file itkGPUDataManager.h.
Definition at line 50 of file itkGPUDataManager.h.
Definition at line 51 of file itkGPUDataManager.h.
|
protected |
Referenced by GetNameOfClass(), GPUKernelManager, and Graft().
|
overrideprotected |
void itk::GPUDataManager::Allocate | ( | ) |
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::LightObject.
Reimplemented in itk::GPUImageDataManager< ImageType >, and itk::GPUImageDataManager< itk::GPUImage >.
|
inline |
Definition at line 65 of file itkGPUDataManager.h.
References m_BufferSize.
void * itk::GPUDataManager::GetCPUBufferPointer | ( | ) |
Get GPU buffer pointer
int itk::GPUDataManager::GetCurrentCommandQueueID | ( | ) | const |
cl_mem * itk::GPUDataManager::GetGPUBufferPointer | ( | ) |
Get GPU buffer pointer
|
overridevirtual |
Return the name of this class as a string. Used by the object factory (implemented in New()) to instantiate objects of a named type. Also used for debugging and other output information.
Reimplemented from itk::LightObject.
Reimplemented in itk::GPUImageDataManager< ImageType >, and itk::GPUImageDataManager< itk::GPUImage >.
References GPUDataManager().
|
virtual |
Method for grafting the content of one GPUDataManager into another one
References GPUDataManager().
|
virtual |
Initialize GPUDataManager
|
inline |
Definition at line 93 of file itkGPUDataManager.h.
References m_IsCPUBufferDirty.
|
inline |
Definition at line 99 of file itkGPUDataManager.h.
References m_IsGPUBufferDirty.
|
static |
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::LightObject.
void itk::GPUDataManager::SetBufferFlag | ( | cl_mem_flags | flags | ) |
void itk::GPUDataManager::SetBufferSize | ( | unsigned int | num | ) |
total buffer size in bytes
void itk::GPUDataManager::SetCPUBufferDirty | ( | ) |
Make GPU up-to-date and mark CPU as dirty. Call this function when you want to modify CPU data
void itk::GPUDataManager::SetCPUBufferPointer | ( | void * | ptr | ) |
void itk::GPUDataManager::SetCPUDirtyFlag | ( | bool | isDirty | ) |
void itk::GPUDataManager::SetCurrentCommandQueue | ( | int | queueid | ) |
void itk::GPUDataManager::SetGPUBufferDirty | ( | ) |
Make CPU up-to-date and mark GPU as dirty. Call this function when you want to modify GPU data
void itk::GPUDataManager::SetGPUDirtyFlag | ( | bool | isDirty | ) |
bool itk::GPUDataManager::Update | ( | ) |
Synchronize CPU and GPU buffers (using dirty flags)
|
virtual |
actual GPU->CPU memory copy takes place here
|
virtual |
actual CPU->GPU memory copy takes place here
|
friend |
allow GPUKernelManager to access GPU buffer pointer
Definition at line 45 of file itkGPUDataManager.h.
References GPUDataManager(), and GPUKernelManager.
Referenced by GPUKernelManager.
|
protected |
Definition at line 150 of file itkGPUDataManager.h.
Referenced by GetBufferSize().
|
protected |
Definition at line 154 of file itkGPUDataManager.h.
|
protected |
Definition at line 152 of file itkGPUDataManager.h.
|
protected |
Definition at line 161 of file itkGPUDataManager.h.
|
protected |
buffer pointers
Definition at line 160 of file itkGPUDataManager.h.
|
protected |
Definition at line 165 of file itkGPUDataManager.h.
Referenced by IsCPUBufferDirty().
|
protected |
checks if buffer needs to be updated
Definition at line 164 of file itkGPUDataManager.h.
Referenced by IsGPUBufferDirty().
|
protected |
buffer type
Definition at line 157 of file itkGPUDataManager.h.
|
protected |
Mutex lock to prevent r/w hazard for multithreaded code
Definition at line 168 of file itkGPUDataManager.h.