ViennaCL - The Vienna Computing Library  1.2.0
Public Member Functions
vector_iterator< SCALARTYPE, ALIGNMENT > Class Template Reference

A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!! More...

#include <vector.hpp>

Inheritance diagram for vector_iterator< SCALARTYPE, ALIGNMENT >:
const_vector_iterator< SCALARTYPE, ALIGNMENT >

Public Member Functions

 vector_iterator ()
 vector_iterator (viennacl::ocl::handle< cl_mem > const &elements, std::size_t index)
 vector_iterator (vector< SCALARTYPE, ALIGNMENT > &vec, cl_uint index)
 Constructor.
 vector_iterator (base_type const &b)
base_type::value_type operator* (void)
viennacl::ocl::handle< cl_mem > handle ()
 operator base_type () const
- Public Member Functions inherited from const_vector_iterator< SCALARTYPE, ALIGNMENT >
 const_vector_iterator ()
 const_vector_iterator (vector< SCALARTYPE, ALIGNMENT > const &vec, cl_uint index)
 Constructor.
 const_vector_iterator (viennacl::ocl::handle< cl_mem > const &elements, cl_uint index)
value_type operator* (void) const
self_type operator++ (void)
self_type operator++ (int)
bool operator== (self_type const &other) const
bool operator!= (self_type const &other) const
difference_type operator- (self_type const &other) const
self_type operator+ (difference_type diff) const
std::size_t index () const
viennacl::ocl::handle< cl_mem >
const & 
handle () const

Additional Inherited Members

- Public Types inherited from const_vector_iterator< SCALARTYPE, ALIGNMENT >
typedef scalar< SCALARTYPE > value_type
typedef long difference_type
- Protected Attributes inherited from const_vector_iterator< SCALARTYPE, ALIGNMENT >
viennacl::ocl::handle< cl_mem > elements_
 The index of the entry the iterator is currently pointing to.
std::size_t index_

Detailed Description

template<class SCALARTYPE, unsigned int ALIGNMENT>
class viennacl::vector_iterator< SCALARTYPE, ALIGNMENT >

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.

Template Parameters
SCALARTYPEThe underlying floating point type (either float or double)
ALIGNMENTAlignment of the underlying vector,
See Also
vector

Constructor & Destructor Documentation

vector_iterator ( )
inline
vector_iterator ( viennacl::ocl::handle< cl_mem > const &  elements,
std::size_t  index 
)
inline
vector_iterator ( vector< SCALARTYPE, ALIGNMENT > &  vec,
cl_uint  index 
)
inline

Constructor.

Parameters
vecThe vector over which to iterate
indexThe starting index of the iterator
vector_iterator ( base_type const &  b)
inline

Member Function Documentation

viennacl::ocl::handle<cl_mem> handle ( )
inline
operator base_type ( ) const
inline
base_type::value_type operator* ( void  )
inline

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