SOFA API  63d8fd06
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_type vectorSize
 Current size of the vector. More...
 
size_type allocSize
 Allocated size on host. More...
 
size_type deviceVectorSize [MemoryManager::MAX_DEVICES]
 Initialized size on each device. More...
 
size_type 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_type clearSize
 when initializing missing device data, up to where entries should be set to zero ? More...
 
T * hostPointer
 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 OpenGL buffer is registered with CUDA. More...
 
GLuint bufferObject
 Optionnal associated OpenGL buffer ID. More...
 

Public Member Functions

 vector ()
 
 vector (size_type 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_type size () const
 
size_type capacity () const
 
bool empty () const
 
void reserve (size_type s, size_type WARP_SIZE=MemoryManager::BSIZE)
 
void fastResize (size_type s, size_type WARP_SIZE=MemoryManager::BSIZE)
 resize the vector without calling constructors or destructors, and without synchronizing the device and host copy More...
 
void recreate (size_type s, size_type 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_type s, size_type 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 T * hostRead () const
 
T * hostWrite ()
 
const T * hostReadAt (int i) const
 
T * hostWriteAt (int i)
 
GLuint bufferRead (bool create=false)
 Get the OpenGL Buffer Object ID for reading. More...
 
GLuint bufferWrite (bool create=false)
 Get the OpenGL Buffer Object ID for writing. More...
 
void push_back (const T &t)
 
void pop_back ()
 
const T & operator[] (size_type i) const
 
T & operator[] (size_type i)
 
const T * data () const
 
T * data ()
 
const T & getCached (size_type i) const
 
const T & getSingle (size_type 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_type i) const
 
void checkIndex (size_type 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_type 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 OpenGL buffer is registered with CUDA.

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

Optionnal associated OpenGL buffer ID.

template<class T, class MemoryManager>
size_type 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_type 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_type 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_type 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_type  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>
GLuint sofa::helper::vector< T, MemoryManager >::bufferRead ( bool  create = false)
inline

Get the OpenGL Buffer Object ID for reading.

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

Get the OpenGL Buffer Object ID for writing.

template<class T, class MemoryManager>
size_type sofa::helper::vector< T, MemoryManager >::capacity ( ) const
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::checkIndex ( size_type  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_type  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_type  s,
size_type  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_type  i) const
inline
template<class T, class MemoryManager>
const T& sofa::helper::vector< T, MemoryManager >::getSingle ( size_type  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_type  i) const
inline
template<class T, class MemoryManager>
T& sofa::helper::vector< T, MemoryManager >::operator[] ( size_type  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_type  s,
size_type  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_type  s,
size_type  WARP_SIZE = MemoryManager::BSIZE 
)
inline
template<class T, class MemoryManager>
void sofa::helper::vector< T, MemoryManager >::resize ( size_type  s,
size_type  WARP_SIZE = MemoryManager::BSIZE 
)
inline
template<class T, class MemoryManager>
size_type 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.