Loading...
Searching...
No Matches
itkOpenCLMemoryObject.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkOpenCLMemoryObject_h
#define itkOpenCLMemoryObject_h
#include "itkOpenCLEventList.h"
#include "itkOpenCLSize.h"
#include "itkPoint.h"
namespace itk
{
// Forward declaration
class OpenCLContext;
class ITKOpenCL_EXPORT OpenCLMemoryObject
{
protected:
OpenCLMemoryObject(OpenCLContext * context = 0)
: m_Context(context)
, m_Id(0)
{}
OpenCLMemoryObject(OpenCLContext * context, const cl_mem id)
: m_Context(context)
, m_Id(id)
{}
~OpenCLMemoryObject();
public:
using Self = OpenCLMemoryObject;
using RectangleType = Size<4>;
using PointType = Point<std::size_t, 2>;
using SizeType = Size<2>;
enum Access
{
ReadWrite = 0x0001,
WriteOnly = 0x0002,
ReadOnly = 0x0004
};
bool
IsNull() const
{
return this->m_Id == 0;
}
cl_mem
GetMemoryId() const
{
return this->m_Id;
}
OpenCLContext *
GetContext() const
{
return this->m_Context;
}
cl_mem_object_type
GetMemoryType() const;
cl_mem_flags
GetFlags() const;
std::size_t
GetSize() const;
void *
GetHostPointer() const;
cl_uint
GetMapCount() const;
cl_uint
GetReferenceCount() const;
OpenCLMemoryObject::Access
GetAccess() const;
void
Unmap(void * ptr, const bool wait = false);
OpenCLEvent
UnmapAsync(void * ptr, const OpenCLEventList & event_list = OpenCLEventList());
cl_int
SetDestructorCallback(void(CL_CALLBACK * pfn_notify)(cl_mem, void *), void * user_data = nullptr);
protected:
void
SetId(OpenCLContext * context, const cl_mem id);
cl_map_flags
GetMapFlags(const OpenCLMemoryObject::Access access);
private:
OpenCLContext * m_Context;
cl_mem m_Id;
OpenCLMemoryObject(const Self & other) = delete;
const Self &
operator=(const Self &) = delete;
};
bool ITKOpenCL_EXPORT
operator==(const OpenCLMemoryObject & lhs, const OpenCLMemoryObject & rhs);
bool ITKOpenCL_EXPORT
operator!=(const OpenCLMemoryObject & lhs, const OpenCLMemoryObject & rhs);
template <typename charT, typename traits>
inline std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> & strm, const OpenCLMemoryObject & memoryObject)
{
if (memoryObject.IsNull())
{
strm << "OpenCLMemoryObject(null)";
return strm;
}
const char indent = ' ';
strm << "OpenCLMemoryObject\n"
<< indent << "Id: " << memoryObject.GetMemoryId() << '\n'
<< indent << "Context: " << memoryObject.GetContext() << '\n'
<< indent << "Memory type: " << memoryObject.GetMemoryType() << '\n'
<< indent << "Flags: " << memoryObject.GetFlags() << '\n'
<< indent << "Size: " << memoryObject.GetSize() << '\n'
<< indent << "Map count: " << memoryObject.GetMapCount() << '\n'
<< indent << "Reference count: " << memoryObject.GetReferenceCount() << '\n'
<< indent << "Host pointer: " << memoryObject.GetHostPointer() << '\n'
<< indent << "Access: ";
switch (memoryObject.GetAccess())
{
case OpenCLMemoryObject::ReadWrite:
strm << "Read Write";
break;
case OpenCLMemoryObject::WriteOnly:
strm << "Write Only";
break;
case OpenCLMemoryObject::ReadOnly:
strm << "Read Only";
break;
default:
strm << "Unknown";
break;
}
strm << std::endl;
return strm;
}
} // end namespace itk
#endif /* itkOpenCLMemoryObject_h */
itk::OpenCLContext
The OpenCLContext class represents an OpenCL context.
Definition itkOpenCLContext.h:77
itk::OpenCLEventList
OpenCLEventList class represents a list of OpenCLEvent objects.
Definition itkOpenCLEventList.h:33
itk::OpenCLEvent
OpenCLEvent class represents an OpenCL event object.
Definition itkOpenCLEvent.h:93
itk::OpenCLMemoryObject
The OpenCLMemoryObject class represents all common memory objects such as buffers and image objects.
Definition itkOpenCLMemoryObject.h:39
itk::OpenCLMemoryObject::SetDestructorCallback
cl_int SetDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=nullptr)
itk::OpenCLMemoryObject::~OpenCLMemoryObject
~OpenCLMemoryObject()
itk::OpenCLMemoryObject::GetMapCount
cl_uint GetMapCount() const
itk::OpenCLMemoryObject::SetId
void SetId(OpenCLContext *context, const cl_mem id)
itk::OpenCLMemoryObject::GetMapFlags
cl_map_flags GetMapFlags(const OpenCLMemoryObject::Access access)
itk::OpenCLMemoryObject::m_Context
OpenCLContext * m_Context
Definition itkOpenCLMemoryObject.h:185
itk::OpenCLMemoryObject::OpenCLMemoryObject
OpenCLMemoryObject(OpenCLContext *context=0)
Definition itkOpenCLMemoryObject.h:42
itk::OpenCLMemoryObject::Self
OpenCLMemoryObject Self
Definition itkOpenCLMemoryObject.h:64
itk::OpenCLMemoryObject::operator=
const Self & operator=(const Self &)=delete
itk::OpenCLMemoryObject::OpenCLMemoryObject
OpenCLMemoryObject(const Self &other)=delete
itk::OpenCLMemoryObject::GetMemoryType
cl_mem_object_type GetMemoryType() const
itk::OpenCLMemoryObject::OpenCLMemoryObject
OpenCLMemoryObject(OpenCLContext *context, const cl_mem id)
Definition itkOpenCLMemoryObject.h:50
itk::OpenCLMemoryObject::Access
Access
Definition itkOpenCLMemoryObject.h:87
itk::OpenCLMemoryObject::WriteOnly
@ WriteOnly
Definition itkOpenCLMemoryObject.h:89
itk::OpenCLMemoryObject::ReadOnly
@ ReadOnly
Definition itkOpenCLMemoryObject.h:90
itk::OpenCLMemoryObject::ReadWrite
@ ReadWrite
Definition itkOpenCLMemoryObject.h:88
itk::OpenCLMemoryObject::IsNull
bool IsNull() const
Definition itkOpenCLMemoryObject.h:95
itk::OpenCLMemoryObject::GetFlags
cl_mem_flags GetFlags() const
itk::OpenCLMemoryObject::SizeType
Size< 2 > SizeType
Definition itkOpenCLMemoryObject.h:67
itk::OpenCLMemoryObject::GetReferenceCount
cl_uint GetReferenceCount() const
itk::OpenCLMemoryObject::PointType
Point< std::vcl_size_t, 2 > PointType
Definition itkOpenCLMemoryObject.h:66
itk::OpenCLMemoryObject::GetMemoryId
cl_mem GetMemoryId() const
Definition itkOpenCLMemoryObject.h:102
itk::OpenCLMemoryObject::UnmapAsync
OpenCLEvent UnmapAsync(void *ptr, const OpenCLEventList &event_list=OpenCLEventList())
itk::OpenCLMemoryObject::GetContext
OpenCLContext * GetContext() const
Definition itkOpenCLMemoryObject.h:109
itk::OpenCLMemoryObject::RectangleType
Size< 4 > RectangleType
Definition itkOpenCLMemoryObject.h:65
itk::OpenCLMemoryObject::GetSize
std::vcl_size_t GetSize() const
itk::OpenCLMemoryObject::GetAccess
OpenCLMemoryObject::Access GetAccess() const
itk::OpenCLMemoryObject::GetHostPointer
void * GetHostPointer() const
itk::OpenCLMemoryObject::Unmap
void Unmap(void *ptr, const bool wait=false)
itk::OpenCLMemoryObject::m_Id
cl_mem m_Id
Definition itkOpenCLMemoryObject.h:186
itkOpenCLEventList.h
ITKOpenCL_EXPORT
#define ITKOpenCL_EXPORT
Definition itkOpenCLExport.h:33
itkOpenCLSize.h
itk
Definition itkAdvancedImageToImageMetric.h:43
itk::operator==
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
itk::operator!=
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
itk::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)
Definition itkOpenCLCommandQueue.h:135

Generated on 1768596610 for elastix by 1.15.0 |