PSkel
 All Classes Files Functions
Public Member Functions | Protected Member Functions
PSkel::ArrayBase< T > Class Template Reference

#include <PSkelArray.h>

Inheritance diagram for PSkel::ArrayBase< T >:
PSkel::Array< T > PSkel::Array2D< T > PSkel::Array3D< T >

List of all members.

Public Member Functions

void deviceAlloc ()
void deviceFree ()
void hostAlloc (size_t width, size_t height, size_t depth)
void hostAlloc ()
void hostFree ()
__device__ __host__ size_t getWidth () const
__device__ __host__ size_t getHeight () const
__device__ __host__ size_t getDepth () const
__device__ __host__ size_t memSize () const
__device__ __host__ size_t size () const
__device__ __host__ size_t realSize () const
template<typename Arrays >
void hostSlice (Arrays array, size_t widthOffset, size_t heightOffset, size_t depthOffset, size_t width, size_t height, size_t depth)
template<typename Arrays >
void hostClone (Arrays array)
template<typename Arrays >
void hostMemCopy (Arrays array)
void copyToDevice ()
template<typename Arrays >
void copyFromDevice (Arrays array)
void copyToHost ()
__device__ __host__ operator bool () const

Protected Member Functions

__device__ __forceinline__ T & deviceGet (size_t h, size_t w, size_t d) const
__host__ __forceinline__ T & hostGet (size_t h, size_t w, size_t d) const
 ArrayBase (size_t width, size_t height, size_t depth)

Detailed Description

template<typename T>
class PSkel::ArrayBase< T >

Class that implements the basic data structure used by the parallel skeletons (such as stencil and map.) PSkel::ArrayBase is a 3D array that is also interfaced via 1D and 2D arrays. The PSkel::ArrayBase data structure that is extended by PSkel::Array, PSkel::Array2D, and PSkel::Array3D.


Constructor & Destructor Documentation

template<typename T >
PSkel::ArrayBase< T >::ArrayBase ( size_t  width,
size_t  height,
size_t  depth 
) [protected]

The ArrayBase constructor creates and allocates the specified array in the host memory.

Parameters:
[in]widthWidth for the 3D array being created.
[in]heightHeight for the 3D array being created.
[in]depthDepth for the 3D array being created.

Member Function Documentation

template<typename T >
template<typename Arrays >
void PSkel::ArrayBase< T >::copyFromDevice ( Arrays  array)

The array given as argument is copied from the device allocated memory to the host allocated memory of this array. The data is efficiently transferred from device to host.

Parameters:
[in]arraythe source array that holds the data that will be copied from device to the host memory of this array.
template<typename T >
void PSkel::ArrayBase< T >::copyToDevice ( )

The array is copied from the host allocated memory to the device allocated memory. The data is efficiently transferred from host to device. Both the host and device memory must be allocated before the data is transferred.

template<typename T >
void PSkel::ArrayBase< T >::copyToHost ( )

The array is copied from the device allocated memory to the host allocated memory. The data is efficiently transferred from device to host. Both the host and device memory must be allocated before the data is transferred.

template<typename T >
void PSkel::ArrayBase< T >::deviceAlloc ( )

Allocates the "virtual" array in device memory.

template<typename T >
void PSkel::ArrayBase< T >::deviceFree ( )

Frees the allocated device memory.

template<typename T >
__device__ __forceinline__ T & PSkel::ArrayBase< T >::deviceGet ( size_t  h,
size_t  w,
size_t  d 
) const [protected]

Access a specific element of the array allocated in the device memory. This function is accessible only during the execution in the device environment.

Parameters:
[in]hheight offset for the element being accessed.
[in]wwidth offset for the element being accessed.
[in]ddepth offset for the element being accessed.
Returns:
the reference of the element specified via parameters.
template<typename T >
size_t PSkel::ArrayBase< T >::getDepth ( ) const

Get the depth size of the "virtual" array.

Returns:
the "virtual" depth of the array data structure.
template<typename T >
size_t PSkel::ArrayBase< T >::getHeight ( ) const

Get the height size of the "virtual" array.

Returns:
the "virtual" height of the array data structure.
template<typename T >
size_t PSkel::ArrayBase< T >::getWidth ( ) const

Get the width size of the "virtual" array.

Returns:
the "virtual" width of the array data structure.
template<typename T >
void PSkel::ArrayBase< T >::hostAlloc ( )

Allocates the array in host (main) memory.

template<typename T >
template<typename Arrays >
void PSkel::ArrayBase< T >::hostClone ( Arrays  array)

Creates a clone, in the host (main) memory, of the array given as argument. The clone is a copy of the array in a different memory space.

Parameters:
[in]arrayoriginal array that will be cloned.
template<typename T >
void PSkel::ArrayBase< T >::hostFree ( )

Frees the allocated host (main) memory.

template<typename T >
T & PSkel::ArrayBase< T >::hostGet ( size_t  h,
size_t  w,
size_t  d 
) const [protected]

Access a specific element of the array allocated in the host memory. This function is accessible only during the execution in the host environment.

Parameters:
[in]hheight offset for the element being accessed.
[in]wwidth offset for the element being accessed.
[in]ddepth offset for the element being accessed.
Returns:
the reference of the element specified via parameters.
template<typename T >
template<typename Arrays >
void PSkel::ArrayBase< T >::hostMemCopy ( Arrays  array)

Copies the data, in the host (main) memory, from the array given as argument.

Parameters:
[in]arrayoriginal array that will be copied.
template<typename T >
template<typename Arrays >
void PSkel::ArrayBase< T >::hostSlice ( Arrays  array,
size_t  widthOffset,
size_t  heightOffset,
size_t  depthOffset,
size_t  width,
size_t  height,
size_t  depth 
)

Creates a sliced reference, in the host (main) memory, of the array given as argument. The slice points to the same memory space as the sliced array.

Parameters:
[in]arrayoriginal array that will be sliced.
[in]widthOffsetthe width offset for the sliced region, relative to the array given as argument.
[in]heightOffsetthe height offset for the sliced region, relative to the array given as argument.
[in]depthOffsetthe depth offset for the sliced region, relative to the array given as argument.
[in]widththe width of the slice.
[in]heightthe height of the slice.
[in]depththe depth of the slice.
template<typename T >
size_t PSkel::ArrayBase< T >::memSize ( ) const

Get the size, in bytes, of the allocated memory for the "virtual" array.

Returns:
the total of bytes allocated in memory for the "virtual" array.
template<typename T >
PSkel::ArrayBase< T >::operator bool ( ) const

Verifies if there is memory allocated for the array data structure. This function can be called both from device and host environment, and the respective memory space is verified.

Returns:
true if there is a valid memory spaced allocated for the array; false otherwise.
template<typename T >
size_t PSkel::ArrayBase< T >::realSize ( ) const

Get the size of the real allocated array, i.e. the number of elements

Returns:
the size of the real allocated array.
template<typename T >
size_t PSkel::ArrayBase< T >::size ( ) const

Get the size of the "virtual" array, i.e. the number of elements

Returns:
the size of the "virtual" array.

The documentation for this class was generated from the following files:
 All Classes Files Functions