Loading...
Searching...
No Matches
itkOpenCLSize.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 itkOpenCLWorkSize_h
#define itkOpenCLWorkSize_h
#include "itkOpenCL.h"
#include "itkSize.h"
#include <string>
namespace itk
{
// Forward declaration
class OpenCLDevice;
class ITKOpenCL_EXPORT OpenCLSize
{
public:
using Self = OpenCLSize;
using SizeType1D = Size<1>;
using SizeType2D = Size<2>;
using SizeType3D = Size<3>;
struct Null
{};
static const Null null;
OpenCLSize(const Null &)
: m_Dim(0)
{
this->m_Sizes[0] = 0;
this->m_Sizes[1] = 0;
this->m_Sizes[2] = 0;
}
OpenCLSize &
operator=(const Null &)
{
*this = OpenCLSize(null);
return *this;
}
bool
IsNull() const
{
return m_Dim == 0;
}
OpenCLSize()
: m_Dim(1)
{
this->m_Sizes[0] = 1;
this->m_Sizes[1] = 1;
this->m_Sizes[2] = 1;
}
OpenCLSize(const std::size_t size)
: m_Dim(1)
{
this->m_Sizes[0] = size;
this->m_Sizes[1] = 1;
this->m_Sizes[2] = 1;
}
OpenCLSize(const std::size_t width, const std::size_t height)
: m_Dim(2)
{
this->m_Sizes[0] = width;
this->m_Sizes[1] = height;
this->m_Sizes[2] = 1;
}
OpenCLSize(const std::size_t width, const std::size_t height, const std::size_t depth)
: m_Dim(3)
{
this->m_Sizes[0] = width;
this->m_Sizes[1] = height;
this->m_Sizes[2] = depth;
}
OpenCLSize(const SizeType1D & size)
: m_Dim(1)
{
this->m_Sizes[0] = size[0];
this->m_Sizes[1] = 1;
this->m_Sizes[2] = 1;
}
OpenCLSize(const SizeType2D & size)
: m_Dim(2)
{
this->m_Sizes[0] = size[0];
this->m_Sizes[1] = size[1];
this->m_Sizes[2] = 1;
}
OpenCLSize(const SizeType3D & size)
: m_Dim(3)
{
this->m_Sizes[0] = size[0];
this->m_Sizes[1] = size[1];
this->m_Sizes[2] = size[2];
}
cl_uint
GetDimension() const
{
return m_Dim;
}
std::size_t
GetWidth() const
{
return this->m_Sizes[0];
}
std::size_t
GetHeight() const
{
return this->m_Sizes[1];
}
std::size_t
GetDepth() const
{
return this->m_Sizes[2];
}
const std::size_t *
GetSizes() const
{
return this->m_Sizes;
}
bool
IsZero() const;
std::size_t & operator[](const std::size_t dim) { return this->m_Sizes[dim]; }
std::size_t operator[](const std::size_t dim) const { return this->m_Sizes[dim]; }
static OpenCLSize
GetLocalWorkSize(const OpenCLSize & maxWorkItemSize, const std::size_t maxItemsPerGroup);
static OpenCLSize
GetLocalWorkSize(const OpenCLDevice & device);
OpenCLSize
RoundTo(const OpenCLSize & size) const;
private:
cl_uint m_Dim;
std::size_t m_Sizes[3];
};
bool ITKOpenCL_EXPORT
operator==(const OpenCLSize & lhs, const OpenCLSize & rhs);
bool ITKOpenCL_EXPORT
operator!=(const OpenCLSize & lhs, const OpenCLSize & rhs);
template <typename charT, typename traits>
inline std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> & strm, const OpenCLSize & size)
{
const cl_uint dim = size.GetDimension();
if (dim == 0)
{
strm << "OpenCLSize(null)";
}
else if (dim == 1)
{
strm << "OpenCLSize(" << size.GetWidth() << ')';
}
else if (dim == 2)
{
strm << "OpenCLSize(" << size.GetWidth() << ", " << size.GetHeight() << ')';
}
else
{
strm << "OpenCLSize(" << size.GetWidth() << ", " << size.GetHeight() << ", " << size.GetDepth() << ')';
}
return strm;
}
} // end namespace itk
#endif /* itkOpenCLWorkSize_h */
itk::OpenCLDevice
The OpenCLDevice class represents the collection of OpenCL devices to be used by the host.
Definition itkOpenCLDevice.h:59
itk::OpenCLSize
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
Definition itkOpenCLSize.h:50
itk::OpenCLSize::GetSizes
const std::vcl_size_t * GetSizes() const
Definition itkOpenCLSize.h:184
itk::OpenCLSize::OpenCLSize
OpenCLSize(const SizeType2D &size)
Definition itkOpenCLSize.h:136
itk::OpenCLSize::OpenCLSize
OpenCLSize(const std::vcl_size_t width, const std::vcl_size_t height, const std::vcl_size_t depth)
Definition itkOpenCLSize.h:114
itk::OpenCLSize::OpenCLSize
OpenCLSize(const SizeType1D &size)
Definition itkOpenCLSize.h:125
itk::OpenCLSize::GetLocalWorkSize
static OpenCLSize GetLocalWorkSize(const OpenCLDevice &device)
itk::OpenCLSize::GetLocalWorkSize
static OpenCLSize GetLocalWorkSize(const OpenCLSize &maxWorkItemSize, const std::vcl_size_t maxItemsPerGroup)
itk::OpenCLSize::OpenCLSize
OpenCLSize(const Null &)
Definition itkOpenCLSize.h:63
itk::OpenCLSize::null
static const Null null
Definition itkOpenCLSize.h:62
itk::OpenCLSize::OpenCLSize
OpenCLSize(const std::vcl_size_t size)
Definition itkOpenCLSize.h:95
itk::OpenCLSize::m_Dim
cl_uint m_Dim
Definition itkOpenCLSize.h:222
itk::OpenCLSize::RoundTo
OpenCLSize RoundTo(const OpenCLSize &size) const
itk::OpenCLSize::operator=
OpenCLSize & operator=(const Null &)
Definition itkOpenCLSize.h:72
itk::OpenCLSize::GetDepth
std::vcl_size_t GetDepth() const
Definition itkOpenCLSize.h:177
itk::OpenCLSize::GetDimension
cl_uint GetDimension() const
Definition itkOpenCLSize.h:156
itk::OpenCLSize::SizeType3D
Size< 3 > SizeType3D
Definition itkOpenCLSize.h:57
itk::OpenCLSize::operator[]
std::vcl_size_t & operator[](const std::vcl_size_t dim)
Definition itkOpenCLSize.h:195
itk::OpenCLSize::IsZero
bool IsZero() const
itk::OpenCLSize::OpenCLSize
OpenCLSize(const std::vcl_size_t width, const std::vcl_size_t height)
Definition itkOpenCLSize.h:105
itk::OpenCLSize::SizeType2D
Size< 2 > SizeType2D
Definition itkOpenCLSize.h:56
itk::OpenCLSize::m_Sizes
std::vcl_size_t m_Sizes[3]
Definition itkOpenCLSize.h:223
itk::OpenCLSize::IsNull
bool IsNull() const
Definition itkOpenCLSize.h:78
itk::OpenCLSize::GetHeight
std::vcl_size_t GetHeight() const
Definition itkOpenCLSize.h:170
itk::OpenCLSize::Self
OpenCLSize Self
Definition itkOpenCLSize.h:53
itk::OpenCLSize::OpenCLSize
OpenCLSize(const SizeType3D &size)
Definition itkOpenCLSize.h:146
itk::OpenCLSize::operator[]
std::vcl_size_t operator[](const std::vcl_size_t dim) const
Definition itkOpenCLSize.h:200
itk::OpenCLSize::OpenCLSize
OpenCLSize()
Definition itkOpenCLSize.h:85
itk::OpenCLSize::GetWidth
std::vcl_size_t GetWidth() const
Definition itkOpenCLSize.h:163
itk::OpenCLSize::SizeType1D
Size< 1 > SizeType1D
Definition itkOpenCLSize.h:55
ITKOpenCL_EXPORT
#define ITKOpenCL_EXPORT
Definition itkOpenCLExport.h:33
itkOpenCL.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
itk::OpenCLSize::Null
Definition itkOpenCLSize.h:61

Generated on 1768596610 for elastix by 1.15.0 |