Cuda::Layout< _Type, _Dim > Class Template Reference

Description of memory layout of multidimensional data. More...

#include <layout.hpp>

List of all members.

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.


Detailed Description

template<class _Type, unsigned _Dim>
class Cuda::Layout< _Type, _Dim >

Description of memory layout of multidimensional data.

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.


Constructor & Destructor Documentation

template<class _Type, unsigned _Dim>
Cuda::Layout< _Type, _Dim >::Layout ( const Size< Dim > &  _size  )  [inline]

Constructor.

Parameters:
_size requested size (may be padded by subclasses to fulfill alignment requirements).


Member Function Documentation

template<class _Type, unsigned _Dim>
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.

Parameters:
rofs offset of region to be checked
rsize size of region to be checked

template<class _Type, unsigned _Dim>
size_t Cuda::Layout< _Type, _Dim >::getBytes (  )  const [inline]

Get total size in bytes.

Returns:
number of totally allocated bytes (including any padding)

template<class _Type, unsigned _Dim>
size_t Cuda::Layout< _Type, _Dim >::getOffset ( const SizeBase< Dim > &  index  )  const [inline]

Get offset for given index.

Parameters:
index index for which to compute offset
Returns:
offset (in elements) for given index

template<class _Type, unsigned _Dim>
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.

Parameters:
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

template<class _Type, unsigned _Dim>
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.

Parameters:
gridDim dimension of grid
blockDim dimension of block
aligned whether region is aligned to block boundaries

template<class _Type, unsigned _Dim>
size_t Cuda::Layout< _Type, _Dim >::getPitch (  )  const [inline]

Get pitch.

Returns:
number of bytes in a row (including any padding)

template<class _Type, unsigned _Dim>
size_t Cuda::Layout< _Type, _Dim >::getSize (  )  const [inline]

Get total number of elements.

Returns:
number of totally allocated elements (including any padding)

template<class _Type, unsigned _Dim>
void Cuda::Layout< _Type, _Dim >::setLayout ( const Layout< Type, Dim > &  layout  )  [inline]

Set layout.

Parameters:
layout new layout

template<class _Type, unsigned _Dim>
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.

Parameters:
pitch new pitch

template<class _Type, unsigned _Dim>
void Cuda::Layout< _Type, _Dim >::setSize ( const Size< Dim > &  _size  )  [inline]

Set size.

This also removed any padding.

Parameters:
_size new size

template<class _Type, unsigned _Dim>
void Cuda::Layout< _Type, _Dim >::setRegion ( const Size< Dim > &  _ofs,
const Size< Dim > &  _size 
) [inline]

Sets region offset and its size at once.

Parameters:
_ofs region offset
_size region size


Member Data Documentation

template<class _Type, unsigned _Dim>
float Cuda::Layout< _Type, _Dim >::spacing[Dim]

Spacing in each dimension.

This is currently unused.


The documentation for this class was generated from the following file:

Generated on Sun Sep 13 00:55:19 2009 for cudatemplates by  doxygen 1.5.6