Extended CUDA Library (ecuda)
2.0
|
A resizable vector stored in device memory. More...
#include <vector.hpp>
Public Types | |
typedef base_type::value_type | value_type |
cell data type More... | |
typedef Alloc | allocator_type |
allocator 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 Alloc::reference | reference |
cell reference type More... | |
typedef Alloc::const_reference | const_reference |
cell const reference type More... | |
typedef Alloc::pointer | pointer |
cell pointer type More... | |
typedef Alloc::const_pointer | 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::vector_kernel_argument < T, Alloc > | kernel_argument |
kernel argument type More... | |
typedef const impl::vector_kernel_argument < T, Alloc > | const_kernel_argument |
const kernel argument type More... | |
Public Member Functions | |
__HOST__ | vector (const allocator_type &allocator=allocator_type()) |
Default constructor. Constructs empty container. More... | |
__HOST__ | vector (size_type n, const value_type &value, const allocator_type &allocator=allocator_type()) |
Constructs the container with n copies of elements with value value. More... | |
__HOST__ | vector (size_type n) |
Constructs the container with n default-inserted instances of T. No copies are made. More... | |
template<class Iterator > | |
__HOST__ | vector (Iterator first, Iterator last, const allocator_type &allocator=allocator_type()) |
Constructs the container with the contents of the range [begin,end). More... | |
__HOST__ | vector (const vector &src) |
Copy constructor. More... | |
__HOST__ vector & | operator= (const vector &src) |
__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 an iterator to the first element of the container. More... | |
__HOST__ __DEVICE__ const_iterator | end () const __NOEXCEPT__ |
Returns an 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 reverse iterator to the first element of the reversed container. More... | |
__HOST__ __DEVICE__ const_reverse_iterator | rend () const __NOEXCEPT__ |
Returns a reverse iterator to the element following the last element of the reversed container. More... | |
__HOST__ __DEVICE__ size_type | size () const __NOEXCEPT__ |
Returns the number of elements in the container. More... | |
__HOST__ __DEVICE__ __CONSTEXPR__ size_type | max_size () const __NOEXCEPT__ |
Returns the maximum number of elements the container is able to hold due to system or library implementation limitations. More... | |
__HOST__ void | resize (size_type newSize, const value_type &value=value_type()) |
Resizes the container to contain newSize elements. More... | |
__HOST__ __DEVICE__ size_type | capacity () const __NOEXCEPT__ |
Returns the number of elements that the container has currently allocated space for. More... | |
__HOST__ __DEVICE__ bool | empty () const __NOEXCEPT__ |
Checks if the container has no elements. More... | |
__HOST__ void | reserve (size_type newCapacity) |
Increase the capacity of the container to a value that's greater or equal to newCapacity. 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[] (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 | 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__ void | assign (size_type newSize, const value_type &value=value_type()) |
Replaces the contents of the container. More... | |
template<class Iterator > | |
__HOST__ void | assign (Iterator first, Iterator last) |
Replaces the contents of the container with copies of those in the range [first,last). More... | |
__HOST__ void | push_back (const value_type &value) |
Appends the given element value to the end of the container. More... | |
__HOST__ __DEVICE__ void | pop_back () |
Removes the last element of the container. More... | |
__HOST__ iterator | insert (const_iterator position, const value_type &value) |
Inserts value before position. More... | |
__HOST__ iterator | insert (const_iterator position, const size_type count, const value_type &value) |
Inserts count copies of the value before position. More... | |
template<class InputIterator > | |
__HOST__ void | insert (const_iterator position, InputIterator first, InputIterator last) |
Inserts elements from range [first,last) before position. More... | |
__HOST__ iterator | erase (const_iterator position) |
Removes the element at position. More... | |
__HOST__ iterator | erase (const_iterator first, const_iterator last) |
Removes the elements in the range [first,last). More... | |
__HOST__ __DEVICE__ void | swap (vector &other) |
Exchanges the contents of the container with those of the other. More... | |
__HOST__ __DEVICE__ void | clear () |
Removes all elements from the container. More... | |
__HOST__ allocator_type | get_allocator () const |
Returns the allocator associated with the container. More... | |
__HOST__ void | shrink_to_fit () |
Requests the removal of unused capacity. More... | |
__HOST__ __DEVICE__ bool | operator== (const vector &other) const |
Checks if the contents of two vectors are equal. More... | |
__HOST__ __DEVICE__ bool | operator!= (const vector &other) const |
Checks if the contents of two arrays are not equal. More... | |
__HOST__ __DEVICE__ bool | operator< (const vector &other) const |
Compares the contents of two vectors lexicographically. More... | |
__HOST__ __DEVICE__ bool | operator> (const vector &other) const |
Compares the contents of two vectors lexicographically. More... | |
__HOST__ __DEVICE__ bool | operator<= (const vector &other) const |
Compares the contents of two vectors lexicographically. More... | |
__HOST__ __DEVICE__ bool | operator>= (const vector &other) const |
Compares the contents of two vectors lexicographically. More... | |
Friends | |
template<typename U , class Alloc2 , class Q > | |
class | vector |
A resizable vector stored in device memory.
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.
Any growth of the vector follows a doubling pattern. The existing memory allocation size is doubled until the requested amount of memory is met or exceeded. In practice, vector growth, element insertions and so on, will be far faster with host memory and so it is preferred to do these kinds of operations in host code and then copy the final result into device memory.
Definition at line 96 of file vector.hpp.
typedef Alloc ecuda::vector< T, Alloc, P >::allocator_type |
allocator type
Definition at line 103 of file vector.hpp.
typedef base_type::const_iterator ecuda::vector< T, Alloc, P >::const_iterator |
const iterator type
Definition at line 119 of file vector.hpp.
typedef const impl::vector_kernel_argument<T,Alloc> ecuda::vector< T, Alloc, P >::const_kernel_argument |
const kernel argument type
Definition at line 124 of file vector.hpp.
typedef Alloc::const_pointer ecuda::vector< T, Alloc, P >::const_pointer |
cell const pointer type
Definition at line 115 of file vector.hpp.
typedef Alloc::const_reference ecuda::vector< T, Alloc, P >::const_reference |
cell const reference type
Definition at line 113 of file vector.hpp.
typedef base_type::const_reverse_iterator ecuda::vector< T, Alloc, P >::const_reverse_iterator |
const reverse iterator type
Definition at line 121 of file vector.hpp.
typedef base_type::difference_type ecuda::vector< T, Alloc, P >::difference_type |
signed integral type
Definition at line 105 of file vector.hpp.
typedef base_type::iterator ecuda::vector< T, Alloc, P >::iterator |
iterator type
Definition at line 118 of file vector.hpp.
typedef impl::vector_kernel_argument<T,Alloc> ecuda::vector< T, Alloc, P >::kernel_argument |
kernel argument type
Definition at line 123 of file vector.hpp.
typedef Alloc::pointer ecuda::vector< T, Alloc, P >::pointer |
cell pointer type
Definition at line 114 of file vector.hpp.
typedef Alloc::reference ecuda::vector< T, Alloc, P >::reference |
cell reference type
Definition at line 112 of file vector.hpp.
typedef base_type::reverse_iterator ecuda::vector< T, Alloc, P >::reverse_iterator |
reverse iterator type
Definition at line 120 of file vector.hpp.
typedef base_type::size_type ecuda::vector< T, Alloc, P >::size_type |
unsigned integral type
Definition at line 104 of file vector.hpp.
typedef base_type::value_type ecuda::vector< T, Alloc, P >::value_type |
cell data type
Definition at line 102 of file vector.hpp.
|
inlineexplicit |
Default constructor. Constructs empty container.
allocator | allocator to use for all memory allocations of this container |
Definition at line 176 of file vector.hpp.
|
inlineexplicit |
Constructs the container with n copies of elements with value value.
n | the size of the container |
value | the value to initialize elements of the container with |
allocator | allocator to use for all memory allocations of this container |
Definition at line 184 of file vector.hpp.
|
inlineexplicit |
Constructs the container with n default-inserted instances of T. No copies are made.
n | the size of the container |
Definition at line 193 of file vector.hpp.
|
inline |
Constructs the container with the contents of the range [begin,end).
first,last | the range to copy the elements from |
allocator | allocator to use for all memory allocations of this container |
Definition at line 204 of file vector.hpp.
|
inline |
Copy constructor.
Constructs a vector with a copy of the contents of src.
src | Another vector object of the same type and size, whose contents are copied. |
Definition at line 217 of file vector.hpp.
|
inline |
Replaces the contents of the container.
newSize | the new size of the container |
value | the value to initialize elements of the container with |
Definition at line 558 of file vector.hpp.
|
inline |
Replaces the contents of the container with copies of those in the range [first,last).
first,last | the range to copy the elements from |
Definition at line 570 of file vector.hpp.
|
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.
index | position of the element to return |
Definition at line 420 of file vector.hpp.
|
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.
index | position of the element to return |
Definition at line 445 of file vector.hpp.
|
inline |
Returns a reference to the last element in the container.
Calling back on an empty container is undefined.
Definition at line 513 of file vector.hpp.
|
inline |
Returns a reference to the last element in the container.
Calling back on an empty container is undefined.
Definition at line 531 of file vector.hpp.
|
inline |
Returns an iterator to the first element of the container.
If the container is empty, the returned iterator will be equal to end().
Definition at line 277 of file vector.hpp.
|
inline |
Returns an iterator to the first element of the container.
If the container is empty, the returned iterator will be equal to end().
Definition at line 295 of file vector.hpp.
|
inline |
Returns the number of elements that the container has currently allocated space for.
Definition at line 389 of file vector.hpp.
|
inline |
Removes all elements from the container.
Invalidates all references, pointers, or iterators referring to contained elements. May invalidate any past-the-end iterators. Leaves the capacity() of the vector unchanged.
Although this can be called from both the host and device, a call from the device only clears the contents of the container in the calling thread only.
Definition at line 781 of file vector.hpp.
|
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.
Definition at line 541 of file vector.hpp.
|
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.
Definition at line 551 of file vector.hpp.
|
inline |
Checks if the container has no elements.
Definition at line 396 of file vector.hpp.
|
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.
Definition at line 286 of file vector.hpp.
|
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.
Definition at line 304 of file vector.hpp.
|
inline |
Removes the element at position.
Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator position must be valid and dereferencable. Thus the end() iterator (which is valid, but not dereferencable) cannot be used as a value for position.
position | iterator to the element to remove |
Definition at line 726 of file vector.hpp.
|
inline |
Removes the elements in the range [first,last).
Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator position must be valid and dereferencable. Thus the end() iterator (which is valid, but not dereferencable) cannot be used as a value for position. The iterator first does not need to be dereferencable if first==last: erasing an empty range is a no-op.
first,last | range of elements to remove |
Definition at line 747 of file vector.hpp.
|
inline |
Returns a reference to the first element in the container.
Calling front on an empty container is undefined.
Definition at line 504 of file vector.hpp.
|
inline |
Returns a reference to the first element in the container.
Calling front on an empty container is undefined.
Definition at line 522 of file vector.hpp.
|
inline |
Returns the allocator associated with the container.
Definition at line 787 of file vector.hpp.
|
inline |
Inserts value before position.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
position | iterator before which the content will be inserted. position may be the end() iterator |
value | element value to insert |
Definition at line 628 of file vector.hpp.
|
inline |
Inserts count copies of the value before position.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
position | iterator before which the content will be inserted. position may be the end() iterator |
count | number of copies of value to insert |
value | element value to insert |
Definition at line 655 of file vector.hpp.
|
inline |
Inserts elements from range [first,last) before position.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
position | iterator before which the content will be inserted. position may be the end() iterator |
first,last | the range of elements to insert, can't be iterators into container for which insert is called |
Definition at line 680 of file vector.hpp.
|
inline |
Returns the maximum number of elements the container is able to hold due to system or library implementation limitations.
Definition at line 364 of file vector.hpp.
|
inline |
Checks if the contents of two arrays are not equal.
That is, whether size() != other.size() or whether any element in the this vector does not compare equal to the element in the other vector at the same position.
other | container to compare contents with |
Definition at line 836 of file vector.hpp.
|
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.
index | position of the element to return |
Definition at line 485 of file vector.hpp.
|
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.
index | position of the element to return |
Definition at line 495 of file vector.hpp.
|
inline |
Compares the contents of two vectors lexicographically.
other | container to compare contents with |
Definition at line 844 of file vector.hpp.
|
inline |
Compares the contents of two vectors lexicographically.
other | container to compare contents with |
Definition at line 880 of file vector.hpp.
|
inline |
Definition at line 227 of file vector.hpp.
|
inline |
Checks if the contents of two vectors are equal.
That is, whether size() == other.size() and each element in the this vector compares equal with the element in the other vector at the same position.
other | container to compare contents with |
Definition at line 814 of file vector.hpp.
|
inline |
Compares the contents of two vectors lexicographically.
other | container to compare contents with |
Definition at line 862 of file vector.hpp.
|
inline |
Compares the contents of two vectors lexicographically.
other | container to compare contents with |
Definition at line 888 of file vector.hpp.
|
inline |
Returns a reference to the element at specified location index. No bounds checking is performed.
index | position of the element to return |
Definition at line 467 of file vector.hpp.
|
inline |
Returns a reference to the element at specified location index. No bounds checking is performed.
index | position of the element to return |
Definition at line 475 of file vector.hpp.
|
inline |
Removes the last element of the container.
Calling pop_back on an empty container is undefined. No iterators or references expect for back() and end() are invalidated.
Although this can be called from both the host and device, a call from the device removes the last element of the container in the calling thread only.
Definition at line 614 of file vector.hpp.
|
inline |
Appends the given element value to the end of the container.
value | the value of the element to append |
Definition at line 598 of file vector.hpp.
|
inline |
Returns a reverse iterator to the first element of the reversed container.
It corresponds to the last element of the non-reversed container.
Definition at line 313 of file vector.hpp.
|
inline |
Returns a reverse iterator to the first element of the reversed container.
It corresponds to the last element of the non-reversed container.
Definition at line 332 of file vector.hpp.
|
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.
Definition at line 323 of file vector.hpp.
|
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.
Definition at line 342 of file vector.hpp.
|
inline |
Increase the capacity of the container to a value that's greater or equal to newCapacity.
If newCapacity is greater than the current capacity(), new storage is allocated, otherwise the method does nothing.
If newCapacity is greater than capacity(), all iterators and references, including the past-the-end iterator, are invalidated. Otherwise, no iterators or references are invalidated.
newCapacity | new capacity of the container |
Definition at line 409 of file vector.hpp.
|
inline |
Resizes the container to contain newSize elements.
If the current size is greater than newSize, the container is reduced to its first newSize elements as if by repeatedly calling pop_back().
newSize | new size of the container |
value | the value to initialize the new elements with |
Definition at line 375 of file vector.hpp.
|
inline |
Requests the removal of unused capacity.
The STL specification describes this as a non-binding request to reduce capacity() to size() and it depends on the implementation if the request is fulfilled. In this implementation, the request is always fulfilled. All iterators, including the past the end iterator, are potentially invalidated.
Definition at line 797 of file vector.hpp.
|
inline |
Returns the number of elements in the container.
Definition at line 356 of file vector.hpp.
|
inline |
Exchanges the contents of the container with those of the other.
Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated.
Although this can be called from both the host and device, a call from the device only swaps the contents of the containers in the calling thread only.
other | container to exchange the contents with |
Definition at line 766 of file vector.hpp.
|
friend |
Definition at line 130 of file vector.hpp.