CUV  0.9.201304091348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Friends | List of all members
cuv::pitched_memory< V, M > Class Template Reference

represents 2D non-contiguous ("pitched") memory More...

#include <tensor.hpp>

Inheritance diagram for cuv::pitched_memory< V, M >:
Inheritance graph
[legend]
Collaboration diagram for cuv::pitched_memory< V, M >:
Collaboration graph
[legend]

Public Types

typedef super::value_type value_type
 type of contained values
typedef super::const_value_type const_value_type
 const version of value_type
typedef super::memory_space_type memory_space_type
 host or dev memory_space
typedef super::index_type index_type
 how to index values
typedef super::size_type size_type
 type of shapes
typedef super::reference_type reference_type
 type of reference you get using operator[]
typedef super::const_reference_type const_reference_type
 type of reference you get using operator[]
- Public Types inherited from cuv::memory< V, M >
typedef const V const_value_type
 const version of value_type
typedef M memory_space_type
 host or dev memory_space
typedef unsigned int size_type
 type of shapes
typedef int index_type
 how to index values
typedef reference< V, M,
index_type
reference_type
 type of reference you get using operator[]
typedef const reference< V, M,
index_type
const_reference_type
 type of reference you get using operator[]
typedef value_typepointer_type
typedef const_value_typeconst_pointer_type

Public Member Functions

size_type rows () const
size_type cols () const
size_type pitch () const
size_type size () const
size_type memsize () const
 pitched_memory ()
 default constructor: does nothing
 pitched_memory (index_type i, index_type j)
 constructor: reserves space for at least i*j elements
void alloc ()
 allocate space according to size()
void dealloc ()
 Deallocate memory.
value_typerelease ()
 releases ownership of pointer (for storage in memory class)
void set_size (size_type rows, size_type cols)
 set the size (reallocating, if necessary)
my_typeoperator= (const my_type &o)
 Copy pitched_memory.
template<class OM >
my_typeoperator= (const pitched_memory< value_type, OM > &o)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
reference_type operator[] (const index_type &idx)
const_reference_type operator[] (const index_type &idx) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
reference_type operator() (const index_type &i, const index_type &j)
 get a reference to a datum in memory
const_reference_type operator() (const index_type &i, const index_type &j) const
void set_strides (linear_memory< index_type, host_memory_space > &strides, const linear_memory< size_type, host_memory_space > &shape, row_major)
 set strides for this memory
void set_strides (linear_memory< index_type, host_memory_space > &strides, const linear_memory< size_type, host_memory_space > &shape, column_major)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. column major version.
- Public Member Functions inherited from cuv::memory< V, M >
pointer_type ptr ()
const_pointer_type ptr () const
void reset (pointer_type p, size_type s)
 reset information (use with care, for deserialization)
 memory ()
 default constructor (just sets ptr to NULL)
 memory (value_type *ptr, size_type size)
 construct with pointer (takes /ownership/ of this pointer and deletes it when destroyed!)
 ~memory ()
 destructor (deallocates the memory)

Friends

class boost::serialization::access

Additional Inherited Members

- Static Public Member Functions inherited from cuv::memory< V, M >
typedef unconst< V >::type value_type
 type of contained values
- Protected Attributes inherited from cuv::memory< V, M >
pointer_type m_ptr
 points to allocated memory
size_type m_size
 size (for serialization)

Detailed Description

template<class V, class M>
class cuv::pitched_memory< V, M >

represents 2D non-contiguous ("pitched") memory

Definition at line 556 of file tensor.hpp.

Constructor & Destructor Documentation

template<class V, class M>
cuv::pitched_memory< V, M >::pitched_memory ( index_type  i,
index_type  j 
)
inline

constructor: reserves space for at least i*j elements

Parameters
inumber of rows
jminimum number of elements per row

Definition at line 601 of file tensor.hpp.

Member Function Documentation

template<class V, class M>
size_type cuv::pitched_memory< V, M >::cols ( ) const
inline
Returns
the number of cols

Definition at line 583 of file tensor.hpp.

template<class V, class M>
size_type cuv::pitched_memory< V, M >::memsize ( ) const
inline
Returns
number of stored bytes

Reimplemented from cuv::memory< V, M >.

Definition at line 592 of file tensor.hpp.

template<class V, class M>
reference_type cuv::pitched_memory< V, M >::operator() ( const index_type i,
const index_type j 
)
inline

get a reference to a datum in memory

Parameters
ifirst (slow-changing) dimension index
jsecond (fast-changing) dimension index
Returns
reference to datum at index i,j

Definition at line 737 of file tensor.hpp.

template<class V, class M>
const_reference_type cuv::pitched_memory< V, M >::operator() ( const index_type i,
const index_type j 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 746 of file tensor.hpp.

template<class V, class M>
my_type& cuv::pitched_memory< V, M >::operator= ( const my_type o)
inline

Copy pitched_memory.

Parameters
oSource pitched_memory
Returns
*this

Definition at line 657 of file tensor.hpp.

template<class V, class M>
template<class OM >
my_type& cuv::pitched_memory< V, M >::operator= ( const pitched_memory< value_type, OM > &  o)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Copy pitched_memory from other memory type.

Parameters
oSource pitched_memory
Returns
*this

Definition at line 687 of file tensor.hpp.

template<class V, class M>
reference_type cuv::pitched_memory< V, M >::operator[] ( const index_type idx)
inline
Returns
a scalar reference to memory at a position as if this were pitched memory
Parameters
idxposition

Definition at line 707 of file tensor.hpp.

template<class V, class M>
const_reference_type cuv::pitched_memory< V, M >::operator[] ( const index_type idx) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns
a scalar reference to memory at a position
Parameters
idxposition

Definition at line 724 of file tensor.hpp.

template<class V, class M>
size_type cuv::pitched_memory< V, M >::pitch ( ) const
inline
Returns
the number of allocated cols

Definition at line 586 of file tensor.hpp.

template<class V, class M>
size_type cuv::pitched_memory< V, M >::rows ( ) const
inline
Returns
the number of rows

Definition at line 580 of file tensor.hpp.

template<class V, class M>
void cuv::pitched_memory< V, M >::set_size ( size_type  rows,
size_type  cols 
)
inline

set the size (reallocating, if necessary)

Parameters
rowsnumber of desired rows
colsnumber of desired columns

Definition at line 633 of file tensor.hpp.

template<class V, class M>
void cuv::pitched_memory< V, M >::set_strides ( linear_memory< index_type, host_memory_space > &  strides,
const linear_memory< size_type, host_memory_space > &  shape,
row_major   
)
inline

set strides for this memory

determines the strides for a given shape, with special consideration to pitched dimension

Parameters
stridesoutput vector
shapeshape of the vector

row major version

Definition at line 761 of file tensor.hpp.

template<class V, class M>
size_type cuv::pitched_memory< V, M >::size ( ) const
inline
Returns
number of stored elements

Reimplemented from cuv::memory< V, M >.

Definition at line 589 of file tensor.hpp.


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