Extended CUDA Library (ecuda)  2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Types | Public Member Functions | Friends | List of all members
ecuda::array< T, N, P > Class Template Reference

A fixed-size array stored in device memory. More...

#include <array.hpp>

Inheritance diagram for ecuda::array< T, N, P >:

Public Types

typedef base_type::value_type value_type
 cell data type More...
 
typedef base_type::size_type size_type
 unsigned integral type More...
 
typedef base_type::difference_type difference_type
 signed integral type More...
 
typedef base_type::reference reference
 cell reference type More...
 
typedef base_type::const_reference const_reference
 cell const reference type More...
 
typedef base_type::pointer pointer
 cell pointer type More...
 
typedef make_const< pointer >::type const_pointer
 cell const pointer type More...
 
typedef base_type::iterator iterator
 iterator type More...
 
typedef base_type::const_iterator const_iterator
 const iterator type More...
 
typedef base_type::reverse_iterator reverse_iterator
 reverse iterator type More...
 
typedef
base_type::const_reverse_iterator 
const_reverse_iterator
 const reverse iterator type More...
 
typedef
impl::array_kernel_argument< T,
N > 
kernel_argument
 kernel argument type More...
 
typedef const
impl::array_kernel_argument< T,
N > 
const_kernel_argument
 const kernel argument type More...
 

Public Member Functions

__HOST__ array ()
 Constructs a fixed-size array with N elements. More...
 
__HOST__ array (const array &src)
 Copy constructor. More...
 
__HOST__ arrayoperator= (const array &other)
 Assignment operator. More...
 
__DEVICE__ reference at (size_type index)
 Returns a reference to the element at specified location index, with bounds checking. More...
 
__DEVICE__ const_reference at (size_type index) const
 Returns a reference to the element at specified location index, with bounds checking. More...
 
__DEVICE__ reference operator[] (size_type index)
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ const_reference operator[] (size_type index) const
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ reference operator() (const size_type index)
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ const_reference operator() (const size_type index) const
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ reference front ()
 Returns a reference to the first element in the container. More...
 
__DEVICE__ reference back ()
 Returns a reference to the last element in the container. More...
 
__DEVICE__ const_reference front () const
 Returns a reference to the first element in the container. More...
 
__DEVICE__ const_reference back () const
 Returns a reference to the last element in the container. More...
 
__HOST__ __DEVICE__ pointer data () __NOEXCEPT__
 Returns pointer to the underlying array serving as element storage. More...
 
__HOST__ __DEVICE__ const_pointer data () const __NOEXCEPT__
 Returns pointer to the underlying array serving as element storage. More...
 
__HOST__ __DEVICE__ iterator begin () __NOEXCEPT__
 Returns an iterator to the first element of the container. More...
 
__HOST__ __DEVICE__ iterator end () __NOEXCEPT__
 Returns an iterator to the element following the last element of the container. More...
 
__HOST__ __DEVICE__ const_iterator begin () const __NOEXCEPT__
 Returns a const_iterator to the first element of the container. More...
 
__HOST__ __DEVICE__ const_iterator end () const __NOEXCEPT__
 Returns a const_iterator to the element following the last element of the container. More...
 
__HOST__ __DEVICE__
reverse_iterator 
rbegin () __NOEXCEPT__
 Returns a reverse iterator to the first element of the reversed container. More...
 
__HOST__ __DEVICE__
reverse_iterator 
rend () __NOEXCEPT__
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
__HOST__ __DEVICE__
const_reverse_iterator 
rbegin () const __NOEXCEPT__
 Returns a const_reverse_iterator to the first element of the reversed container. More...
 
__HOST__ __DEVICE__
const_reverse_iterator 
rend () const __NOEXCEPT__
 Returns a const_reverse_iterator to the element following the last element of the reversed container. More...
 
__HOST__ __DEVICE__
__CONSTEXPR__ bool 
empty () const __NOEXCEPT__
 Checks if the container has no elements. More...
 
__HOST__ __DEVICE__
__CONSTEXPR__ size_type 
size () const __NOEXCEPT__
 Returns the number of elements in the container. More...
 
__HOST__ __CONSTEXPR__ size_type max_size () const __NOEXCEPT__
 Returns the maximum number of elements the container is able to hold. More...
 
__HOST__ __DEVICE__ void fill (const value_type &value)
 Assigns a given value to all elements in the container. More...
 
__HOST__ __DEVICE__ void swap (array &other)
 Exchanges the contents of the container with those of the other. More...
 
__HOST__ __DEVICE__ bool operator== (const array &other) const
 Checks if the contents of two arrays are equal. More...
 
__HOST__ __DEVICE__ bool operator!= (const array &other) const
 Checks if the contents of two arrays are not equal. More...
 
__HOST__ __DEVICE__ bool operator< (const array &other) const
 Compares the contents of two arrays lexicographically. More...
 
__HOST__ __DEVICE__ bool operator> (const array &other) const
 Compares the contents of two arrays lexicographically. More...
 
__HOST__ __DEVICE__ bool operator<= (const array &other) const
 Compares the contents of two arrays lexicographically. More...
 
__HOST__ __DEVICE__ bool operator>= (const array &other) const
 Compares the contents of two arrays lexicographically. More...
 

Friends

template<typename U , std::size_t M, class Q >
class array
 

Detailed Description

template<typename T, std::size_t N, class P = shared_ptr<T>>
class ecuda::array< T, N, P >

A fixed-size array stored in device memory.

Creates a fixed size array in GPU memory. Redeclares most of the STL methods on the equivalent C++11 std::array (although this implementation works with C98 compilers).

Methods are prefaced with appropriate keywords to declare them as host and/or device capable. In general: operations requiring memory allocation/deallocation are host only, operations to access the values of specific elements are device only, and copy operations on ranges of data and accessors of general information can be performed on both the host and device.

Definition at line 80 of file array.hpp.

Member Typedef Documentation

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::const_iterator ecuda::array< T, N, P >::const_iterator

const iterator type

Definition at line 95 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef const impl::array_kernel_argument<T,N> ecuda::array< T, N, P >::const_kernel_argument

const kernel argument type

Definition at line 100 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef make_const<pointer>::type ecuda::array< T, N, P >::const_pointer

cell const pointer type

Definition at line 92 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::const_reference ecuda::array< T, N, P >::const_reference

cell const reference type

Definition at line 90 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::const_reverse_iterator ecuda::array< T, N, P >::const_reverse_iterator

const reverse iterator type

Definition at line 97 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::difference_type ecuda::array< T, N, P >::difference_type

signed integral type

Definition at line 88 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::iterator ecuda::array< T, N, P >::iterator

iterator type

Definition at line 94 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef impl::array_kernel_argument<T,N> ecuda::array< T, N, P >::kernel_argument

kernel argument type

Definition at line 99 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::pointer ecuda::array< T, N, P >::pointer

cell pointer type

Definition at line 91 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::reference ecuda::array< T, N, P >::reference

cell reference type

Definition at line 89 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::reverse_iterator ecuda::array< T, N, P >::reverse_iterator

reverse iterator type

Definition at line 96 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::size_type ecuda::array< T, N, P >::size_type

unsigned integral type

Definition at line 87 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
typedef base_type::value_type ecuda::array< T, N, P >::value_type

cell data type

Definition at line 86 of file array.hpp.

Constructor & Destructor Documentation

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ ecuda::array< T, N, P >::array ( )
inline

Constructs a fixed-size array with N elements.

Each element is a default-initialized value of T.

Definition at line 126 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ ecuda::array< T, N, P >::array ( const array< T, N, P > &  src)
inline

Copy constructor.

Constructs an array with a copy of the contents of src.

Parameters
srcanother array object of the same type and size, whose contents are copied.

Definition at line 138 of file array.hpp.

Member Function Documentation

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::array< T, N, P >::at ( size_type  index)
inline

Returns a reference to the element at specified location index, with bounds checking.

If index is not within the range of the container, the current kernel will exit and cudaGetLastError will return cudaErrorUnknown.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 202 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::array< T, N, P >::at ( size_type  index) const
inline

Returns a reference to the element at specified location index, with bounds checking.

If index is not within the range of the container, the current kernel will exit and cudaGetLastError will return cudaErrorUnknown.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 227 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::array< T, N, P >::back ( )
inline

Returns a reference to the last element in the container.

Calling back on an empty container is undefined.

Returns
Reference to the last element.

Definition at line 295 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::array< T, N, P >::back ( ) const
inline

Returns a reference to the last element in the container.

Calling back on an empty container is undefined.

Returns
Reference to the last element.

Definition at line 312 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ iterator ecuda::array< T, N, P >::begin ( )
inline

Returns an iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

Returns
Iterator to the first element.

Definition at line 341 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_iterator ecuda::array< T, N, P >::begin ( ) const
inline

Returns a const_iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

Returns
Iterator to the first element.

Definition at line 359 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ pointer ecuda::array< T, N, P >::data ( )
inline

Returns pointer to the underlying array serving as element storage.

The pointer is such that range [data(); data()+size()) is always a valid range, even if the container is empty.

Returns
Pointer to the underlying element storage.

Definition at line 322 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_pointer ecuda::array< T, N, P >::data ( ) const
inline

Returns pointer to the underlying array serving as element storage.

The pointer is such that range [data(); data()+size()) is always a valid range, even if the container is empty.

Returns
Pointer to the underlying element storage.

Definition at line 332 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ __CONSTEXPR__ bool ecuda::array< T, N, P >::empty ( ) const
inline

Checks if the container has no elements.

Returns
true if the container is empty, false otherwise.

Definition at line 454 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ iterator ecuda::array< T, N, P >::end ( )
inline

Returns an iterator to the element following the last element of the container.

The element acts as a placeholder; attempting to access it results in undefined behaviour.

Returns
Iterator to the element following the last element.

Definition at line 350 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_iterator ecuda::array< T, N, P >::end ( ) const
inline

Returns a const_iterator to the element following the last element of the container.

The element acts as a placeholder; attempting to access it results in undefined behaviour.

Returns
Iterator to the element following the last element.

Definition at line 368 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::array< T, N, P >::fill ( const value_type value)
inline

Assigns a given value to all elements in the container.

Parameters
valuethe value to assign to the elements

Definition at line 478 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::array< T, N, P >::front ( )
inline

Returns a reference to the first element in the container.

Calling front on an empty container is undefined.

Returns
Reference to the first element.

Definition at line 286 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::array< T, N, P >::front ( ) const
inline

Returns a reference to the first element in the container.

Calling front on an empty container is undefined.

Returns
Reference to the first element.

Definition at line 303 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __CONSTEXPR__ size_type ecuda::array< T, N, P >::max_size ( ) const
inline

Returns the maximum number of elements the container is able to hold.

The value can be defined according to system or library implementation limitations.

Returns
Maximum number of elements.

Definition at line 470 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::array< T, N, P >::operator!= ( const array< T, N, P > &  other) const
inline

Checks if the contents of two arrays are not equal.

That is, whether any element in the this array does not compare equal with the element in another array at the same position.

Parameters
othercontainer to compare contents with
Returns
true if the contents are not equal, false otherwise

Definition at line 515 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::array< T, N, P >::operator() ( const size_type  index)
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

This is identical to operator[] but is present for consistency with higher-dimensional containers.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 267 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::array< T, N, P >::operator() ( const size_type  index) const
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

This is identical to operator[] but is present for consistency with higher-dimensional containers.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 277 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::array< T, N, P >::operator< ( const array< T, N, P > &  other) const
inline

Compares the contents of two arrays lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this array are lexicographically less than the other array, false otherwise

Definition at line 523 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::array< T, N, P >::operator<= ( const array< T, N, P > &  other) const
inline

Compares the contents of two arrays lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this array are lexicographically less than or equal to the other array, false otherwise

Definition at line 539 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ array& ecuda::array< T, N, P >::operator= ( const array< T, N, P > &  other)
inline

Assignment operator.

Assigns new contents to the array, replacing its current contents.

Parameters
otheranother array object of the same type and size, whose contents are assigned.

Definition at line 163 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::array< T, N, P >::operator== ( const array< T, N, P > &  other) const
inline

Checks if the contents of two arrays are equal.

That is, whether each element in the this array compares equal with the element in another array at the same position.

Parameters
othercontainer to compare contents with
Returns
true if the contents are equal, false otherwise

Definition at line 504 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::array< T, N, P >::operator> ( const array< T, N, P > &  other) const
inline

Compares the contents of two arrays lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this array are lexicographically greater than the other array, false otherwise

Definition at line 531 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::array< T, N, P >::operator>= ( const array< T, N, P > &  other) const
inline

Compares the contents of two arrays lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this array are lexicographically greater than or equal to the other array, false otherwise

Definition at line 547 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::array< T, N, P >::operator[] ( size_type  index)
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 249 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::array< T, N, P >::operator[] ( size_type  index) const
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 257 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ reverse_iterator ecuda::array< T, N, P >::rbegin ( )
inline

Returns a reverse iterator to the first element of the reversed container.

It corresponds to the last element of the non-reversed container.

Returns
Reverse iterator to the first element.

Definition at line 377 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_reverse_iterator ecuda::array< T, N, P >::rbegin ( ) const
inline

Returns a const_reverse_iterator to the first element of the reversed container.

It corresponds to the last element of the non-reversed container.

Returns
Reverse iterator to the first element.

Definition at line 396 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ reverse_iterator ecuda::array< T, N, P >::rend ( )
inline

Returns a reverse iterator to the element following the last element of the reversed container.

It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behaviour.

Returns
Reverse iterator to the element following the last element.

Definition at line 387 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_reverse_iterator ecuda::array< T, N, P >::rend ( ) const
inline

Returns a const_reverse_iterator to the element following the last element of the reversed container.

It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behaviour.

Returns
Reverse iterator to the element following the last element.

Definition at line 406 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ __CONSTEXPR__ size_type ecuda::array< T, N, P >::size ( ) const
inline

Returns the number of elements in the container.

Returns
The number of elements in the container.

Definition at line 461 of file array.hpp.

template<typename T, std::size_t N, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::array< T, N, P >::swap ( array< T, N, P > &  other)
inline

Exchanges the contents of the container with those of the other.

Does not cause iterators and references to associate with the other container.

Parameters
othercontainer to exchange the contents with

Definition at line 487 of file array.hpp.

Friends And Related Function Documentation

template<typename T, std::size_t N, class P = shared_ptr<T>>
template<typename U , std::size_t M, class Q >
friend class array
friend

Definition at line 102 of file array.hpp.


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