#include <layout.hpp>
Public Member Functions | |
Layout () | |
Default constructor. | |
Layout (const Size< Dim > &_size) | |
Constructor. | |
void | checkBounds (const Size< Dim > &rofs, const Size< Dim > &rsize) |
Check bounds for given region. | |
size_t | getBytes () const |
Get total size in bytes. | |
size_t | getOffset (const SizeBase< Dim > &index) const |
Get offset for given index. | |
bool | contiguous () const |
Determine if layout is contiguous. | |
void | getExecutionConfiguration (dim3 &gridDim, dim3 &blockDim, bool &aligned, size_t &dofs, Size< Dim > &rmin, Size< Dim > &rmax, const Size< Dim > &rofs, const Size< Dim > &rsize) const |
Get execution configuration for Cuda. | |
void | getExecutionConfiguration (dim3 &gridDim, dim3 &blockDim, bool &aligned) const |
Get execution configuration for Cuda. | |
size_t | getPitch () const |
Get pitch. | |
size_t | getSize () const |
Get total number of elements. | |
void | setLayout (const Layout< Type, Dim > &layout) |
Set layout. | |
void | setPitch (size_t pitch) |
Set pitch. | |
void | setSize (const Size< Dim > &_size) |
Set size. | |
void | setRegion (const Size< Dim > &_ofs, const Size< Dim > &_size) |
Sets region offset and its size at once. | |
Public Attributes | |
Size< Dim > | size |
Size of the layout in each dimension (in elements). | |
Size< Dim > | region_ofs |
Offset of region of interesst. | |
Size< Dim > | region_size |
Size of region of interest. | |
Size< Dim > | stride |
Step size of the layout in each dimension (in elements). | |
float | spacing [Dim] |
Spacing in each dimension. |
To achieve optimal memory bandwidth in CUDA, it is crucial to follow some memory layout rules. The purpose of this class is to hold the layout information in addition to the actual size of the data. Moreover, the Layout class contains fields for specifying geometric properties in each dimension (see Layout::spacing) and a region of interest (see Layout::region_ofs and see Layout::region_size). These fields are often used in application code and therefore provided for convenience, but are not handled by the Layout class itself.
Cuda::Layout< _Type, _Dim >::Layout | ( | const Size< Dim > & | _size | ) | [inline] |
Constructor.
_size | requested size (may be padded by subclasses to fulfill alignment requirements). |
void Cuda::Layout< _Type, _Dim >::checkBounds | ( | const Size< Dim > & | rofs, | |
const Size< Dim > & | rsize | |||
) | [inline] |
Check bounds for given region.
If the given region exceeds the size of this layout, an error is reported.
rofs | offset of region to be checked | |
rsize | size of region to be checked |
size_t Cuda::Layout< _Type, _Dim >::getBytes | ( | ) | const [inline] |
Get total size in bytes.
size_t Cuda::Layout< _Type, _Dim >::getOffset | ( | const SizeBase< Dim > & | index | ) | const [inline] |
Get offset for given index.
index | index for which to compute offset |
void Cuda::Layout< _Type, _Dim >::getExecutionConfiguration | ( | dim3 & | gridDim, | |
dim3 & | blockDim, | |||
bool & | aligned, | |||
size_t & | dofs, | |||
Size< Dim > & | rmin, | |||
Size< Dim > & | rmax, | |||
const Size< Dim > & | rofs, | |||
const Size< Dim > & | rsize | |||
) | const [inline] |
Get execution configuration for Cuda.
This method suggests an execution configuration suitable for accessing the given region within this layout.
gridDim | dimension of grid | |
blockDim | dimension of block | |
aligned | whether region is aligned to block boundaries | |
dofs | data offset according to first block of region | |
rmin | rmax region to be processed in kernel coordinates | |
rofs | offset of region to be processed | |
rsize | size of region to be processed |
void Cuda::Layout< _Type, _Dim >::getExecutionConfiguration | ( | dim3 & | gridDim, | |
dim3 & | blockDim, | |||
bool & | aligned | |||
) | const [inline] |
Get execution configuration for Cuda.
This method suggests an execution configuration suitable for accessing every element within this layout.
gridDim | dimension of grid | |
blockDim | dimension of block | |
aligned | whether region is aligned to block boundaries |
size_t Cuda::Layout< _Type, _Dim >::getPitch | ( | ) | const [inline] |
Get pitch.
size_t Cuda::Layout< _Type, _Dim >::getSize | ( | ) | const [inline] |
Get total number of elements.
void Cuda::Layout< _Type, _Dim >::setLayout | ( | const Layout< Type, Dim > & | layout | ) | [inline] |
Set layout.
layout | new layout |
void Cuda::Layout< _Type, _Dim >::setPitch | ( | size_t | pitch | ) | [inline] |
Set pitch.
Computes the step size in each dimension for later offset calculations. The image size must be set before calling this method.
pitch | new pitch |
void Cuda::Layout< _Type, _Dim >::setSize | ( | const Size< Dim > & | _size | ) | [inline] |
Set size.
This also removed any padding.
_size | new size |
void Cuda::Layout< _Type, _Dim >::setRegion | ( | const Size< Dim > & | _ofs, | |
const Size< Dim > & | _size | |||
) | [inline] |
Sets region offset and its size at once.
_ofs | region offset | |
_size | region size |
float Cuda::Layout< _Type, _Dim >::spacing[Dim] |
Spacing in each dimension.
This is currently unused.