39 #ifndef ECUDA_ARRAY_HPP
40 #define ECUDA_ARRAY_HPP
45 #ifdef ECUDA_CPP11_AVAILABLE
46 #include <initializer_list>
63 template<
typename T,std::
size_t N>
class array_kernel_argument;
79 template<
typename T, std::
size_t N,
class P=shared_ptr<T> >
80 class array :
private model::device_fixed_sequence< T, N, P > {
83 typedef model::device_fixed_sequence< T, N, P > base_type;
91 typedef typename base_type::pointer
pointer;
102 template<
typename U,std::
size_t M,
class Q>
friend class array;
116 base_type::get_pointer() = unmanaged_cast(other.get_pointer());
143 #ifdef ECUDA_CPP11_AVAILABLE
147 #ifdef ECUDA_CONSTEXPR_KEYWORD_ENABLED
148 static_assert( il.size() <= N,
EXCEPTION_MSG(
"size of initializer list must not be greater than the array size") );
150 if( il.size() > N )
throw std::invalid_argument(
EXCEPTION_MSG(
"size of initializer list must not be greater than the array size") );
169 #ifdef ECUDA_CPP11_AVAILABLE
188 base_type::operator=(std::move(src));
204 if( !(index <
size()) ) {
206 throw std::out_of_range(
EXCEPTION_MSG(
"ecuda::array::at() index parameter is out of range") );
215 return base_type::operator[](index);
229 if( !(index <
size()) ) {
231 throw std::out_of_range(
EXCEPTION_MSG(
"ecuda::array::at() index parameter is out of range") );
240 return base_type::operator[](index);
408 #ifdef ECUDA_CPP11_AVAILABLE
488 #if defined(ECUDA_CPP11_AVAILABLE) && defined(ECUDA_NOEXCEPT_KEYWORD_ENABLED)
489 noexcept(noexcept(
swap(std::declval<T&>(),std::declval<T&>())))
563 template<
typename T,std::
size_t N>
564 class array_kernel_argument :
public array<T,N,typename ecuda::add_pointer<T>::type>
568 typedef array<T,N,typename ecuda::add_pointer<T>::type> base_type;
572 __HOST__ array_kernel_argument(
const array<T,N,P>& src ) : base_type( src, ecuda::true_type() ) {}
574 __HOST__ __DEVICE__ array_kernel_argument(
const array_kernel_argument& src ) : base_type( src, ecuda::true_type() ) {}
577 __HOST__ array_kernel_argument& operator=(
const array<T,N,P>& src )
579 base_type::shallow_assign(src);
583 #ifdef ECUDA_CPP11_AVAILABLE
584 array_kernel_argument( array_kernel_argument&& src ) : base_type(std::move(src)) {}
586 array_kernel_argument& operator=( array_kernel_argument&& src )
588 base_type::operator=(std::move(src));
__HOST__ __DEVICE__ iterator begin() __NOEXCEPT__
Returns an iterator to the first element of the container.
__HOST__ __DEVICE__ const_iterator begin() const __NOEXCEPT__
Returns a const_iterator to the first element of the container.
A smart pointer that retains shared ownership of an object in device memory.
__HOST__ __DEVICE__ OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result)
Replacement for std::copy.
base_type::reference reference
cell reference type
__DEVICE__ reference back()
Returns a reference to the last element in the container.
__HOST__ __DEVICE__ iterator end() __NOEXCEPT__
Returns an iterator to the element following the last element of the container.
__DEVICE__ const_reference front() const
Returns a reference to the first element in the container.
__DEVICE__ const_reference operator()(const size_type index) const
Returns a reference to the element at specified location index. No bounds checking is performed...
__HOST__ array()
Constructs a fixed-size array with N elements.
__HOST__ __DEVICE__ bool operator!=(const array &other) const
Checks if the contents of two arrays are not equal.
base_type::iterator iterator
iterator type
__HOST__ __DEVICE__ const_reverse_iterator rbegin() const __NOEXCEPT__
Returns a const_reverse_iterator to the first element of the reversed container.
__HOST__ __DEVICE__ const_pointer data() const __NOEXCEPT__
Returns pointer to the underlying array serving as element storage.
base_type::value_type value_type
cell data type
base_type::size_type size_type
unsigned integral type
impl::array_kernel_argument< T, N > kernel_argument
kernel argument type
__HOST__ __DEVICE__ const_iterator end() const __NOEXCEPT__
Returns a const_iterator to the element following the last element of the container.
base_type::const_iterator const_iterator
const iterator type
__DEVICE__ reference at(size_type index)
Returns a reference to the element at specified location index, with bounds checking.
__DEVICE__ const_reference back() const
Returns a reference to the last element in the container.
base_type::difference_type difference_type
signed integral type
__HOST__ __DEVICE__ void swap(T &a, T &b) __NOEXCEPT__
base_type::const_reverse_iterator const_reverse_iterator
const reverse iterator type
__HOST__ __DEVICE__ reverse_iterator rbegin() __NOEXCEPT__
Returns a reverse iterator to the first element of the reversed container.
base_type::pointer pointer
cell pointer type
__HOST__ __DEVICE__ __CONSTEXPR__ bool empty() const __NOEXCEPT__
Checks if the container has no elements.
__HOST__ __CONSTEXPR__ size_type max_size() const __NOEXCEPT__
Returns the maximum number of elements the container is able to hold.
base_type::reverse_iterator reverse_iterator
reverse iterator type
make_const< pointer >::type const_pointer
cell const pointer type
__HOST__ __DEVICE__ reverse_iterator rend() __NOEXCEPT__
Returns a reverse iterator to the element following the last element of the reversed container...
base_type::const_reference const_reference
cell const reference type
Allocator for device memory.
__HOST__ __DEVICE__ void swap(array &other)
Exchanges the contents of the container with those of the other.
__HOST__ __DEVICE__ bool operator>(const array &other) const
Compares the contents of two arrays lexicographically.
__HOST__ __DEVICE__ pointer data() __NOEXCEPT__
Returns pointer to the underlying array serving as element storage.
__HOST__ __DEVICE__ __CONSTEXPR__ size_type size() const __NOEXCEPT__
Returns the number of elements in the container.
__HOST__ __DEVICE__ bool operator>=(const array &other) const
Compares the contents of two arrays lexicographically.
__DEVICE__ reference front()
Returns a reference to the first element in the container.
const impl::array_kernel_argument< T, N > const_kernel_argument
const kernel argument type
__DEVICE__ reference operator()(const size_type index)
Returns a reference to the element at specified location index. No bounds checking is performed...
__DEVICE__ const_reference operator[](size_type index) const
Returns a reference to the element at specified location index. No bounds checking is performed...
__HOST__ __DEVICE__ bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Replacement for std::equal.
__DEVICE__ void threadfence()
__HOST__ __DEVICE__ const T & max(const T &a, const T &b)
__HOST__ array(const array &src)
Copy constructor.
__HOST__ __DEVICE__ bool operator<=(const array &other) const
Compares the contents of two arrays lexicographically.
__HOST__ __DEVICE__ bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
A fixed-size array stored in device memory.
__DEVICE__ const_reference at(size_type index) const
Returns a reference to the element at specified location index, with bounds checking.
__HOST__ array & operator=(const array &other)
Assignment operator.
__DEVICE__ reference operator[](size_type index)
Returns a reference to the element at specified location index. No bounds checking is performed...
__HOST__ __DEVICE__ const_reverse_iterator rend() const __NOEXCEPT__
Returns a const_reverse_iterator to the element following the last element of the reversed container...
__HOST__ __DEVICE__ bool operator==(const array &other) const
Checks if the contents of two arrays are equal.
__HOST__ __DEVICE__ bool operator<(const array &other) const
Compares the contents of two arrays lexicographically.
__HOST__ __DEVICE__ void fill(const value_type &value)
Assigns a given value to all elements in the container.
__HOST__ __DEVICE__ void fill(ForwardIterator first, ForwardIterator last, const T &val)