SOFA API  1e111313
Open source framework for multi-physics simuation
sofa::helper::vector< T, MemoryManager > Class Template Reference

#include <vector_device.h>

Inheritance diagram for sofa::helper::vector< T, MemoryManager >:

Classes

struct  rebind
 

Protected Attributes

Size vectorSize
 Current size of the vector. More...
 
Size allocSize
 Allocated size on host. More...
 
Size deviceVectorSize [MemoryManager::MAX_DEVICES]
 Initialized size on each device. More...
 
Size deviceAllocSize [MemoryManager::MAX_DEVICES]
 Allocated size on each device. More...
 
device_pointer devicePointer [MemoryManager::MAX_DEVICES]
 Pointer to the data on the GPU side. More...
 
Size clearSize
 when initializing missing device data, up to where entries should be set to zero ? More...
 
ThostPointer
 Pointer to the data on the CPU side. More...
 
int deviceIsValid
 True if the data on the GPU is currently valid (up to the given deviceVectorSize of each device, i.e. additionnal space may need to be allocated and/or initialized) More...
 
bool hostIsValid
 True if the data on the CPU is currently valid. More...
 
bool bufferIsRegistered
 True if the buffer is registered with CUDA. More...
 
buffer_id_type bufferObject
 Optionnal associated buffer ID. More...
 

Public Member Functions

 vector ()
 
 vector (Size n)
 
 vector (const vector< T, MemoryManager > &v)
 
bool isHostValid () const
 
bool isDeviceValid (unsigned gpu) const
 
void clear ()
 
void operator= (const vector< T, MemoryManager > &v)
 
 ~vector ()
 
Size size () const
 
Size capacity () const
 
bool empty () const
 
void reserve (Size s, Size WARP_SIZE=MemoryManager::BSIZE)
 
void fastResize (Size s, Size WARP_SIZE=MemoryManager::BSIZE)
 resize the vector without calling constructors or destructors, and without synchronizing the device and host copy More...
 
void recreate (Size s, Size WARP_SIZE=MemoryManager::BSIZE)
 resize the vector discarding any old values, without calling constructors or destructors, and without synchronizing the device and host copy More...
 
void invalidateDevice ()
 
void invalidateHost ()
 
void memsetDevice (int v=0)
 
void memsetHost (int v=0)
 
void resize (Size s, Size WARP_SIZE=MemoryManager::BSIZE)
 
void swap (vector< T, MemoryManager > &v)
 
const device_pointer deviceReadAt (int i, int gpu=MemoryManager::getBufferDevice()) const
 
const device_pointer deviceRead (int gpu=MemoryManager::getBufferDevice()) const
 
device_pointer deviceWriteAt (int i, int gpu=MemoryManager::getBufferDevice())
 
device_pointer deviceWrite (int gpu=MemoryManager::getBufferDevice())
 
const ThostRead () const
 
ThostWrite ()
 
const ThostReadAt (int i) const
 
ThostWriteAt (int i)
 
buffer_id_type bufferRead (bool create=false)
 Get the Buffer Object ID for reading. More...
 
buffer_id_type bufferWrite (bool create=false)
 Get the Buffer Object ID for writing. More...
 
void push_back (const T &t)
 
void pop_back ()
 
const Toperator[] (Size i) const
 
Toperator[] (Size i)
 
const Tdata () const
 
Tdata ()
 
const TgetCached (Size i) const
 
const TgetSingle (Size i) const
 
const_iterator begin () const
 
const_iterator end () const
 
iterator begin ()
 
iterator end ()
 
iterator erase (iterator position)
 
iterator insert (iterator position, const T &x)
 
template<>
std::istream & read (std::istream &in)
 
template<>
std::istream & read (std::istream &in)
 
template<>
std::ostream & write (std::ostream &os) const
 
template<>
std::istream & read (std::istream &in)
 

Protected Member Functions

void allocate (int d) const
 
void copyToHost () const
 
void copyToDevice (int d=0) const
 
void copyToHostSingle (Size i) const
 
void checkIndex (Size i) const
 
void registerBuffer () const
 
void mapBuffer () const
 
void unmapBuffer () const
 
void unregisterBuffer () const
 
void createBuffer ()
 

Friends

std::ostream & operator<< (std::ostream &os, const vector< T, MemoryManager > &vec)
 Output stream. More...
 
std::istream & operator>> (std::istream &in, vector< T, MemoryManager > &vec)
 Input stream. More...
 

Attribute details

template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::allocSize
protected

Allocated size on host.

template<class T, class MemoryManager>
bool sofa::helper::vector< T, MemoryManager >::bufferIsRegistered
mutableprotected

True if the buffer is registered with CUDA.

template<class T, class MemoryManager>
buffer_id_type sofa::helper::vector< T, MemoryManager >::bufferObject
protected

Optionnal associated buffer ID.

template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::clearSize
mutableprotected

when initializing missing device data, up to where entries should be set to zero ?

template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::deviceAllocSize[MemoryManager::MAX_DEVICES]
mutableprotected

Allocated size on each device.

template<class T, class MemoryManager>
int sofa::helper::vector< T, MemoryManager >::deviceIsValid
mutableprotected

True if the data on the GPU is currently valid (up to the given deviceVectorSize of each device, i.e. additionnal space may need to be allocated and/or initialized)

template<class T, class MemoryManager>
device_pointer sofa::helper::vector< T, MemoryManager >::devicePointer[MemoryManager::MAX_DEVICES]
mutableprotected

Pointer to the data on the GPU side.

template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::deviceVectorSize[MemoryManager::MAX_DEVICES]
mutableprotected

Initialized size on each device.

template<class T, class MemoryManager>
bool sofa::helper::vector< T, MemoryManager >::hostIsValid
mutableprotected

True if the data on the CPU is currently valid.

template<class T, class MemoryManager>
T* sofa::helper::vector< T, MemoryManager >::hostPointer
protected

Pointer to the data on the CPU side.

template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::vectorSize
protected

Current size of the vector.

Constructor details

template<class T, class MemoryManager>
sofa::helper::vector< T, MemoryManager >::vector ( )
inline
template<class T, class MemoryManager>
sofa::helper::vector< T, MemoryManager >::vector ( Size  n)
inline
template<class T, class MemoryManager>
sofa::helper::vector< T, MemoryManager >::vector ( const vector< T, MemoryManager > &  v)
inline
template<class T, class MemoryManager>
sofa::helper::vector< T, MemoryManager >::~vector ( )
inline

Function details

template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::allocate ( int  d) const
inlineprotected
template<class T, class MemoryManager>
const_iterator sofa::helper::vector< T, MemoryManager >::begin ( ) const
inline
template<class T, class MemoryManager>
iterator sofa::helper::vector< T, MemoryManager >::begin ( )
inline
template<class T, class MemoryManager>
buffer_id_type sofa::helper::vector< T, MemoryManager >::bufferRead ( bool  create = false)
inline

Get the Buffer Object ID for reading.

template<class T, class MemoryManager>
buffer_id_type sofa::helper::vector< T, MemoryManager >::bufferWrite ( bool  create = false)
inline

Get the Buffer Object ID for writing.

template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::capacity ( ) const
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::checkIndex ( Size  i) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::clear ( )
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::copyToDevice ( int  d = 0) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::copyToHost ( ) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::copyToHostSingle ( Size  i) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::createBuffer ( )
inlineprotected
template<class T, class MemoryManager>
const T* sofa::helper::vector< T, MemoryManager >::data ( ) const
inline
template<class T, class MemoryManager>
T* sofa::helper::vector< T, MemoryManager >::data ( )
inline
template<class T, class MemoryManager>
const device_pointer sofa::helper::vector< T, MemoryManager >::deviceRead ( int  gpu = MemoryManager::getBufferDevice()) const
inline
template<class T, class MemoryManager>
const device_pointer sofa::helper::vector< T, MemoryManager >::deviceReadAt ( int  i,
int  gpu = MemoryManager::getBufferDevice() 
) const
inline
template<class T, class MemoryManager>
device_pointer sofa::helper::vector< T, MemoryManager >::deviceWrite ( int  gpu = MemoryManager::getBufferDevice())
inline
template<class T, class MemoryManager>
device_pointer sofa::helper::vector< T, MemoryManager >::deviceWriteAt ( int  i,
int  gpu = MemoryManager::getBufferDevice() 
)
inline
template<class T, class MemoryManager>
bool sofa::helper::vector< T, MemoryManager >::empty ( ) const
inline
template<class T, class MemoryManager>
const_iterator sofa::helper::vector< T, MemoryManager >::end ( ) const
inline
template<class T, class MemoryManager>
iterator sofa::helper::vector< T, MemoryManager >::end ( )
inline
template<class T, class MemoryManager>
iterator sofa::helper::vector< T, MemoryManager >::erase ( iterator  position)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::fastResize ( Size  s,
Size  WARP_SIZE = MemoryManager::BSIZE 
)
inline

resize the vector without calling constructors or destructors, and without synchronizing the device and host copy

template<class T, class MemoryManager>
const T& sofa::helper::vector< T, MemoryManager >::getCached ( Size  i) const
inline
template<class T, class MemoryManager>
const T& sofa::helper::vector< T, MemoryManager >::getSingle ( Size  i) const
inline
template<class T, class MemoryManager>
const T* sofa::helper::vector< T, MemoryManager >::hostRead ( ) const
inline
template<class T, class MemoryManager>
const T* sofa::helper::vector< T, MemoryManager >::hostReadAt ( int  i) const
inline
template<class T, class MemoryManager>
T* sofa::helper::vector< T, MemoryManager >::hostWrite ( )
inline
template<class T, class MemoryManager>
T* sofa::helper::vector< T, MemoryManager >::hostWriteAt ( int  i)
inline
template<class T, class MemoryManager>
iterator sofa::helper::vector< T, MemoryManager >::insert ( iterator  position,
const T x 
)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::invalidateDevice ( )
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::invalidateHost ( )
inline
template<class T, class MemoryManager>
bool sofa::helper::vector< T, MemoryManager >::isDeviceValid ( unsigned  gpu) const
inline
template<class T, class MemoryManager>
bool sofa::helper::vector< T, MemoryManager >::isHostValid ( ) const
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::mapBuffer ( ) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::memsetDevice ( int  v = 0)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::memsetHost ( int  v = 0)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::operator= ( const vector< T, MemoryManager > &  v)
inline
template<class T, class MemoryManager>
const T& sofa::helper::vector< T, MemoryManager >::operator[] ( Size  i) const
inline
template<class T, class MemoryManager>
T& sofa::helper::vector< T, MemoryManager >::operator[] ( Size  i)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::pop_back ( )
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::push_back ( const T t)
inline
template<>
std::istream & sofa::helper::vector< int >::read ( std::istream &  in)
inline

Input stream Specialization for reading vectors of int and unsigned int using "A-B" notation for all integers between A and B, optionnally specifying a step using "A-B-step" notation.

template<>
std::istream & sofa::helper::vector< unsigned int >::read ( std::istream &  in)
inline

Input stream Specialization for reading vectors of int and unsigned int using "A-B" notation for all integers between A and B

template<>
std::istream & sofa::helper::vector< unsigned char >::read ( std::istream &  in)
inline

Input stream Specialization for reading vectors of unsigned char

template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::recreate ( Size  s,
Size  WARP_SIZE = MemoryManager::BSIZE 
)
inline

resize the vector discarding any old values, without calling constructors or destructors, and without synchronizing the device and host copy

template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::registerBuffer ( ) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::reserve ( Size  s,
Size  WARP_SIZE = MemoryManager::BSIZE 
)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::resize ( Size  s,
Size  WARP_SIZE = MemoryManager::BSIZE 
)
inline
template<class T, class MemoryManager>
Size sofa::helper::vector< T, MemoryManager >::size ( void  ) const
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::swap ( vector< T, MemoryManager > &  v)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::unmapBuffer ( ) const
inlineprotected
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::unregisterBuffer ( ) const
inlineprotected
template<>
std::ostream & sofa::helper::vector< unsigned char >::write ( std::ostream &  os) const
inline

Output stream Specialization for writing vectors of unsigned char

Enum details

template<class T, class MemoryManager>
anonymous enum
protected
Enumerator
ALL_DEVICE_VALID 

Related details

template<class T, class MemoryManager>
std::ostream& operator<< ( std::ostream &  os,
const vector< T, MemoryManager > &  vec 
)
friend

Output stream.

template<class T, class MemoryManager>
std::istream& operator>> ( std::istream &  in,
vector< T, MemoryManager > &  vec 
)
friend

Input stream.