ViennaCL - The Vienna Computing Library
1.5.0
|
A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!! More...
#include <vector.hpp>
Public Types | |
typedef base_type::handle_type | handle_type |
typedef base_type::difference_type | difference_type |
Public Member Functions | |
vector_iterator () | |
vector_iterator (handle_type &elements, vcl_size_t index, vcl_size_t start=0, vcl_ptrdiff_t stride=1) | |
vector_iterator (vector_base< SCALARTYPE > &vec, vcl_size_t index, vcl_size_t start=0, vcl_ptrdiff_t stride=1) | |
Constructor. | |
base_type::value_type | operator* (void) |
difference_type | operator- (self_type const &other) const |
self_type | operator+ (difference_type diff) const |
handle_type & | handle () |
handle_type const & | handle () const |
A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!!
Every dereference operation initiates a transfer from the GPU to the CPU. The overhead of such a transfer is around 50us, so 20.000 dereferences take one second. This is four orders of magnitude slower than similar dereferences on the CPU. However, increments and comparisons of iterators is as fast as for CPU types. If you need a fast iterator, copy the whole vector to the CPU first and iterate over the CPU object, e.g. std::vector<float> temp; copy(gpu_vector, temp); for (std::vector<float>::const_iterator iter = temp.begin(); iter != temp.end(); ++iter) { //do something } copy(temp, gpu_vector); Note that you may obtain inconsistent data if you manipulate entries of gpu_vector in the meanwhile.
SCALARTYPE | The underlying floating point type (either float or double) |
ALIGNMENT | Alignment of the underlying vector, |
Reimplemented from const_vector_iterator< SCALARTYPE, ALIGNMENT >.
typedef base_type::handle_type handle_type |
Reimplemented from const_vector_iterator< SCALARTYPE, ALIGNMENT >.
vector_iterator | ( | ) | [inline] |
vector_iterator | ( | handle_type & | elements, |
vcl_size_t | index, | ||
vcl_size_t | start = 0 , |
||
vcl_ptrdiff_t | stride = 1 |
||
) | [inline] |
vector_iterator | ( | vector_base< SCALARTYPE > & | vec, |
vcl_size_t | index, | ||
vcl_size_t | start = 0 , |
||
vcl_ptrdiff_t | stride = 1 |
||
) | [inline] |
Constructor.
vec | The vector over which to iterate |
index | The starting index of the iterator |
start | Offset from the beginning of the underlying vector (for ranges and slices) |
stride | Stride for slices |
handle_type& handle | ( | ) | [inline] |
handle_type const& handle | ( | ) | const [inline] |
Reimplemented from const_vector_iterator< SCALARTYPE, ALIGNMENT >.
base_type::value_type operator* | ( | void | ) | [inline] |
self_type operator+ | ( | difference_type | diff | ) | const [inline] |
Reimplemented from const_vector_iterator< SCALARTYPE, ALIGNMENT >.
difference_type operator- | ( | self_type const & | other | ) | const [inline] |
Reimplemented from const_vector_iterator< SCALARTYPE, ALIGNMENT >.