SOFA API  b3f2f2a4
Open source framework for multi-physics simuation
sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager > Class Template Reference

#include <vector_device.h>

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...
 
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 buffer is registered with CUDA. More...
 
buffer_id_type bufferObject
 Optionnal associated buffer ID. More...
 

Static Protected Attributes

static int cptid = 0
 

Public Member Functions

 vector_device ()
 
 vector_device (Size n)
 
 vector_device (const vector_device< T, MemoryManager, DataTypeInfoManager > &v)
 
bool isHostValid () const
 
bool isDeviceValid (unsigned gpu) const
 
void clear ()
 
void operator= (const vector_device< T, MemoryManager, DataTypeInfoManager > &v)
 
 ~vector_device ()
 
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_device< T, MemoryManager, DataTypeInfoManager > &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)
 
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 T & operator[] (Size i) const
 
T & operator[] (Size i)
 
const T * data () const
 
T * data ()
 
const T & getCached (Size i) const
 
const T & getSingle (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)
 

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_device< T, MemoryManager, DataTypeInfoManager > &vec)
 Output stream. More...
 
std::istream & operator>> (std::istream &in, vector_device< T, MemoryManager, DataTypeInfoManager > &vec)
 Input stream. More...
 

Attribute details

◆ allocSize

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::allocSize
protected

Allocated size on host.

◆ bufferIsRegistered

template<class T , class MemoryManager , class DataTypeInfoManager >
bool sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::bufferIsRegistered
mutableprotected

True if the buffer is registered with CUDA.

◆ bufferObject

template<class T , class MemoryManager , class DataTypeInfoManager >
buffer_id_type sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::bufferObject
protected

Optionnal associated buffer ID.

◆ clearSize

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::clearSize
mutableprotected

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

◆ cptid

template<class T , class MemoryManager , class DataTypeInfoManager >
int sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::cptid = 0
inlinestaticprotected

◆ deviceAllocSize

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::deviceAllocSize[MemoryManager::MAX_DEVICES]
mutableprotected

Allocated size on each device.

◆ deviceIsValid

template<class T , class MemoryManager , class DataTypeInfoManager >
int sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::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)

◆ devicePointer

template<class T , class MemoryManager , class DataTypeInfoManager >
device_pointer sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::devicePointer[MemoryManager::MAX_DEVICES]
mutableprotected

Pointer to the data on the GPU side.

◆ deviceVectorSize

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::deviceVectorSize[MemoryManager::MAX_DEVICES]
mutableprotected

Initialized size on each device.

◆ hostIsValid

template<class T , class MemoryManager , class DataTypeInfoManager >
bool sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::hostIsValid
mutableprotected

True if the data on the CPU is currently valid.

◆ hostPointer

template<class T , class MemoryManager , class DataTypeInfoManager >
T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::hostPointer
protected

Pointer to the data on the CPU side.

◆ vectorSize

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::vectorSize
protected

Current size of the vector.

Constructor details

◆ vector_device() [1/3]

template<class T , class MemoryManager , class DataTypeInfoManager >
sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::vector_device ( )
inline

◆ vector_device() [2/3]

template<class T , class MemoryManager , class DataTypeInfoManager >
sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::vector_device ( Size  n)
inline

◆ vector_device() [3/3]

template<class T , class MemoryManager , class DataTypeInfoManager >
sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::vector_device ( const vector_device< T, MemoryManager, DataTypeInfoManager > &  v)
inline

◆ ~vector_device()

template<class T , class MemoryManager , class DataTypeInfoManager >
sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::~vector_device ( )
inline

Function details

◆ allocate()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::allocate ( int  d) const
inlineprotected

◆ begin() [1/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
iterator sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::begin ( )
inline

◆ begin() [2/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
const_iterator sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::begin ( ) const
inline

◆ bufferRead()

template<class T , class MemoryManager , class DataTypeInfoManager >
buffer_id_type sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::bufferRead ( bool  create = false)
inline

Get the Buffer Object ID for reading.

◆ bufferWrite()

template<class T , class MemoryManager , class DataTypeInfoManager >
buffer_id_type sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::bufferWrite ( bool  create = false)
inline

Get the Buffer Object ID for writing.

◆ capacity()

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::capacity ( ) const
inline

◆ checkIndex()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::checkIndex ( Size  i) const
inlineprotected

◆ clear()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::clear ( )
inline

◆ copyToDevice()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::copyToDevice ( int  d = 0) const
inlineprotected

◆ copyToHost()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::copyToHost ( ) const
inlineprotected

◆ copyToHostSingle()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::copyToHostSingle ( Size  i) const
inlineprotected

◆ createBuffer()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::createBuffer ( )
inlineprotected

◆ data() [1/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::data ( )
inline

◆ data() [2/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
const T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::data ( ) const
inline

◆ deviceRead()

template<class T , class MemoryManager , class DataTypeInfoManager >
const device_pointer sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::deviceRead ( int  gpu = MemoryManager::getBufferDevice()) const
inline

◆ deviceReadAt()

template<class T , class MemoryManager , class DataTypeInfoManager >
const device_pointer sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::deviceReadAt ( int  i,
int  gpu = MemoryManager::getBufferDevice() 
) const
inline

◆ deviceWrite()

template<class T , class MemoryManager , class DataTypeInfoManager >
device_pointer sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::deviceWrite ( int  gpu = MemoryManager::getBufferDevice())
inline

◆ deviceWriteAt()

template<class T , class MemoryManager , class DataTypeInfoManager >
device_pointer sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::deviceWriteAt ( int  i,
int  gpu = MemoryManager::getBufferDevice() 
)
inline

◆ empty()

template<class T , class MemoryManager , class DataTypeInfoManager >
bool sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::empty ( ) const
inline

◆ end() [1/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
iterator sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::end ( )
inline

◆ end() [2/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
const_iterator sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::end ( ) const
inline

◆ erase()

template<class T , class MemoryManager , class DataTypeInfoManager >
iterator sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::erase ( iterator  position)
inline

◆ fastResize()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::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

◆ getCached()

template<class T , class MemoryManager , class DataTypeInfoManager >
const T& sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::getCached ( Size  i) const
inline

◆ getSingle()

template<class T , class MemoryManager , class DataTypeInfoManager >
const T& sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::getSingle ( Size  i) const
inline

◆ hostRead()

template<class T , class MemoryManager , class DataTypeInfoManager >
const T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::hostRead ( ) const
inline

◆ hostReadAt()

template<class T , class MemoryManager , class DataTypeInfoManager >
const T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::hostReadAt ( int  i) const
inline

◆ hostWrite()

template<class T , class MemoryManager , class DataTypeInfoManager >
T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::hostWrite ( )
inline

◆ hostWriteAt()

template<class T , class MemoryManager , class DataTypeInfoManager >
T* sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::hostWriteAt ( int  i)
inline

◆ insert()

template<class T , class MemoryManager , class DataTypeInfoManager >
iterator sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::insert ( iterator  position,
const T &  x 
)
inline

◆ invalidateDevice()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::invalidateDevice ( )
inline

◆ invalidateHost()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::invalidateHost ( )
inline

◆ isDeviceValid()

template<class T , class MemoryManager , class DataTypeInfoManager >
bool sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::isDeviceValid ( unsigned  gpu) const
inline

◆ isHostValid()

template<class T , class MemoryManager , class DataTypeInfoManager >
bool sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::isHostValid ( ) const
inline

◆ mapBuffer()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::mapBuffer ( ) const
inlineprotected

◆ memsetDevice()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::memsetDevice ( int  v = 0)
inline

◆ memsetHost()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::memsetHost ( int  v = 0)
inline

◆ operator=()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::operator= ( const vector_device< T, MemoryManager, DataTypeInfoManager > &  v)
inline

◆ operator[]() [1/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
T& sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::operator[] ( Size  i)
inline

◆ operator[]() [2/2]

template<class T , class MemoryManager , class DataTypeInfoManager >
const T& sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::operator[] ( Size  i) const
inline

◆ pop_back()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::pop_back ( )
inline

◆ push_back()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::push_back ( const T &  t)
inline

◆ recreate()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::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

◆ registerBuffer()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::registerBuffer ( ) const
inlineprotected

◆ reserve()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::reserve ( Size  s,
Size  WARP_SIZE = MemoryManager::BSIZE 
)
inline

◆ resize()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::resize ( Size  s,
Size  WARP_SIZE = MemoryManager::BSIZE 
)
inline

◆ size()

template<class T , class MemoryManager , class DataTypeInfoManager >
Size sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::size ( void  ) const
inline

◆ swap()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::swap ( vector_device< T, MemoryManager, DataTypeInfoManager > &  v)
inline

◆ unmapBuffer()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::unmapBuffer ( ) const
inlineprotected

◆ unregisterBuffer()

template<class T , class MemoryManager , class DataTypeInfoManager >
void sofa::type::vector_device< T, MemoryManager, DataTypeInfoManager >::unregisterBuffer ( ) const
inlineprotected

Enum details

◆ anonymous enum

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

Related details

◆ operator<<

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

Output stream.

◆ operator>>

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

Input stream.