Image Utilities (IU)
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Groups Pages
Public Member Functions | Data Fields
iu::LinearDeviceMemory< PixelType, Ndim >::KernelData Struct Reference

Struct pointer KernelData that can be used in CUDA kernels. More...

#include <lineardevicememory.h>

Public Member Functions

__host__ KernelData (const LinearDeviceMemory< PixelType, Ndim > &mem)
 
__host__ ~KernelData ()
 
template<typename ResultType = void>
__device__ std::enable_if
<(Ndim==2), ResultType >::type 
getPosition (const unsigned int &linear_idx, unsigned int &idx0, unsigned int &idx1)
 
template<typename ResultType = void>
__device__ std::enable_if
<(Ndim==3), ResultType >::type 
getPosition (const unsigned int &linear_idx, unsigned int &idx0, unsigned int &idx1, unsigned int &idx2)
 
template<typename ResultType = void>
__device__ std::enable_if
<(Ndim==4), ResultType >::type 
getPosition (const unsigned int &linear_idx, unsigned int &idx0, unsigned int &idx1, unsigned int &idx2, unsigned int &idx3)
 
template<typename ResultType = void>
__device__ std::enable_if
<(Ndim==5), ResultType >::type 
getPosition (const unsigned int &linear_idx, unsigned int &idx0, unsigned int &idx1, unsigned int &idx2, unsigned int &idx3, unsigned int &idx4)
 
template<typename ResultType = unsigned int>
__device__ std::enable_if
<(Ndim > 1), ResultType >
::type 
getLinearIndex (const unsigned int &idx0, const unsigned int &idx1)
 
template<typename ResultType = unsigned int>
__device__ std::enable_if
<(Ndim > 2), ResultType >
::type 
getLinearIndex (const unsigned int &idx0, const unsigned int &idx1, const unsigned int &idx2)
 
template<typename ResultType = unsigned int>
__device__ std::enable_if
<(Ndim > 3), ResultType >
::type 
getLinearIndex (const unsigned int &idx0, const unsigned int &idx1, const unsigned int &idx2, const unsigned int &idx3)
 
template<typename ResultType = unsigned int>
__device__ std::enable_if
<(Ndim > 4), ResultType >
::type 
getLinearIndex (const unsigned int &idx0, const unsigned int &idx1, const unsigned int &idx2, const unsigned int &idx3, const unsigned int &idx4)
 
__device__ PixelType & operator() (const unsigned int &idx)
 
template<typename ResultType = PixelType>
__device__ std::enable_if
<(Ndim > 1), ResultType & >
::type 
operator() (const unsigned int &idx0, const unsigned int &idx1)
 
template<typename ResultType = PixelType>
__device__ std::enable_if
<(Ndim > 2), ResultType & >
::type 
operator() (const unsigned int &idx0, const unsigned int &idx1, const unsigned int &idx2)
 
template<typename ResultType = PixelType>
__device__ std::enable_if
<(Ndim > 3), ResultType & >
::type 
operator() (const unsigned int &idx0, const unsigned int &idx1, const unsigned int &idx2, const unsigned int &idx3)
 
template<typename ResultType = PixelType>
__device__ std::enable_if
<(Ndim > 4), ResultType & >
::type 
operator() (const unsigned int &idx0, const unsigned int &idx1, const unsigned int &idx2, const unsigned int &idx3, const unsigned int &idx4)
 

Data Fields

PixelType * data_
 
int numel_
 
int * size_
 
int * stride_
 

Detailed Description

template<typename PixelType, unsigned int Ndim>
struct iu::LinearDeviceMemory< PixelType, Ndim >::KernelData

Struct pointer KernelData that can be used in CUDA kernels.

This struct provides the device data pointer as well as important class properties.

template<typename PixelType>
__global__ void cudaFunctionKernel(iu::LinearDeviceMemory<PixelType>::KernelData memory, PixelType value)
{
const unsigned int x = threadIdx.x + blockIdx.x * blockDim.x;
if (x < memory.numel_ )
{
img(x) += value;
}
}
template<typename PixelType>
void doSomethingWithCuda(iu::LinearDeviceMemory<PixelType> *memory, PixelType value)
{
dim3 dimBlock(32,1);
dim3 dimGrid(iu::divUp(img->numel(), dimBlock.x), 1);
cudaFunctionKernel<PixelType><<<dimGrid, dimBlock>>>(*memory, value);
IU_CUDA_CHECK;
}

Constructor & Destructor Documentation

template<typename PixelType, unsigned int Ndim>
__host__ iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::KernelData ( const LinearDeviceMemory< PixelType, Ndim > &  mem)
inline

Constructor

template<typename PixelType, unsigned int Ndim>
__host__ iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::~KernelData ( )
inline

Destructor

Member Function Documentation

template<typename PixelType, unsigned int Ndim>
template<typename ResultType = unsigned int>
__device__ std::enable_if<(Ndim > 1), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getLinearIndex ( const unsigned int &  idx0,
const unsigned int &  idx1 
)
inline

Convert pixel position to linear index

Parameters
idx0Position at dimension 0
idx1Position at dimension 1
Returns
Linear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = unsigned int>
__device__ std::enable_if<(Ndim > 2), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getLinearIndex ( const unsigned int &  idx0,
const unsigned int &  idx1,
const unsigned int &  idx2 
)
inline

Convert pixel position to linear index

Parameters
idx0Position at dimension 0
idx1Position at dimension 1
idx2Position at dimension 2
Returns
Linear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = unsigned int>
__device__ std::enable_if<(Ndim > 3), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getLinearIndex ( const unsigned int &  idx0,
const unsigned int &  idx1,
const unsigned int &  idx2,
const unsigned int &  idx3 
)
inline

Convert pixel position to linear index

Parameters
idx0Position at dimension 0
idx1Position at dimension 1
idx2Position at dimension 2
idx3Position at dimension 3
Returns
Linear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = unsigned int>
__device__ std::enable_if<(Ndim > 4), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getLinearIndex ( const unsigned int &  idx0,
const unsigned int &  idx1,
const unsigned int &  idx2,
const unsigned int &  idx3,
const unsigned int &  idx4 
)
inline

Convert pixel position to linear index

Parameters
idx0Position at dimension 0
idx1Position at dimension 1
idx2Position at dimension 2
idx3Position at dimension 3
idx4Position at dimension 4
Returns
Linear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = void>
__device__ std::enable_if<(Ndim == 2), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getPosition ( const unsigned int &  linear_idx,
unsigned int &  idx0,
unsigned int &  idx1 
)
inline

Get pixel position for a linear index

Parameters
[in]idx0Position at dimension 0
[in]idx1Position at dimension 1
[out]linear_idxLinear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = void>
__device__ std::enable_if<(Ndim == 3), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getPosition ( const unsigned int &  linear_idx,
unsigned int &  idx0,
unsigned int &  idx1,
unsigned int &  idx2 
)
inline

Get pixel position for a linear index

Parameters
[in]idx0Position at dimension 0
[in]idx1Position at dimension 1
[in]idx2Position at dimension 2
[out]linear_idxLinear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = void>
__device__ std::enable_if<(Ndim == 4), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getPosition ( const unsigned int &  linear_idx,
unsigned int &  idx0,
unsigned int &  idx1,
unsigned int &  idx2,
unsigned int &  idx3 
)
inline

Get pixel position for a linear index

Parameters
[in]idx0Position at dimension 0
[in]idx1Position at dimension 1
[in]idx2Position at dimension 2
[in]idx3Position at dimension 3
[out]linear_idxLinear index
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = void>
__device__ std::enable_if<(Ndim == 5), ResultType>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::getPosition ( const unsigned int &  linear_idx,
unsigned int &  idx0,
unsigned int &  idx1,
unsigned int &  idx2,
unsigned int &  idx3,
unsigned int &  idx4 
)
inline

Get pixel position for a linear index

Parameters
[in]idx0Position at dimension 0
[in]idx1Position at dimension 1
[in]idx2Position at dimension 2
[in]idx3Position at dimension 3
[in]idx4Position at dimension 4
[out]linear_idxLinear index
template<typename PixelType, unsigned int Ndim>
__device__ PixelType& iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::operator() ( const unsigned int &  idx)
inline

Access the memory via the () operator.

Parameters
idxIndex to access.
Returns
value at index.
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = PixelType>
__device__ std::enable_if<(Ndim > 1), ResultType&>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::operator() ( const unsigned int &  idx0,
const unsigned int &  idx1 
)
inline

Access the memory via the () operator.

Parameters
idx0Index at position 0 to access.
idx1Index at position 1 to access.
Returns
value at index.
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = PixelType>
__device__ std::enable_if<(Ndim > 2), ResultType&>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::operator() ( const unsigned int &  idx0,
const unsigned int &  idx1,
const unsigned int &  idx2 
)
inline

Access the memory via the () operator.

Parameters
idx0Index at position 0 to access.
idx1Index at position 1 to access.
idx2Index at position 2 to access.
Returns
value at index.
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = PixelType>
__device__ std::enable_if<(Ndim > 3), ResultType&>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::operator() ( const unsigned int &  idx0,
const unsigned int &  idx1,
const unsigned int &  idx2,
const unsigned int &  idx3 
)
inline

Access the memory via the () operator.

Parameters
idx0Index at position 0 to access.
idx1Index at position 1 to access.
idx2Index at position 2 to access.
idx3Index at position 3 to access.
Returns
value at index.
template<typename PixelType, unsigned int Ndim>
template<typename ResultType = PixelType>
__device__ std::enable_if<(Ndim > 4), ResultType&>::type iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::operator() ( const unsigned int &  idx0,
const unsigned int &  idx1,
const unsigned int &  idx2,
const unsigned int &  idx3,
const unsigned int &  idx4 
)
inline

Access the memory via the () operator.

Parameters
idx0Index at position 0 to access.
idx1Index at position 1 to access.
idx2Index at position 2 to access.
idx3Index at position 3 to access.
idx4Index at position 4 to access.
Returns
value at index.

Field Documentation

template<typename PixelType, unsigned int Ndim>
PixelType* iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::data_

Pointer to device buffer.

template<typename PixelType, unsigned int Ndim>
int iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::numel_

numel of the memory.

template<typename PixelType, unsigned int Ndim>
int* iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::size_

size of the memory (on device)

template<typename PixelType, unsigned int Ndim>
int* iu::LinearDeviceMemory< PixelType, Ndim >::KernelData::stride_

stride of the memory (on device)


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