OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > Class Template Reference

Implementation of 1-D std::vector like structure. More...

Detailed Description

template<typename T>
class vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >

Implementation of 1-D std::vector like structure.

this implementation is just a wrapper for the std::vector in the case of data where the members cannot be parsed see openFPM_data wiki for more information

Create add and access the elements

Parameters
Tbase type

Definition at line 25 of file map_vector_std_cuda.hpp.

#include <map_vector_std_cuda.hpp>

Data Structures

struct  layout_base__
 

Public Types

typedef int yes_i_am_vector
 it define that it is a vector
 
typedef memory_traits_inte< T > layout_base_
 
typedef vector_key_iterator iterator_key
 iterator for the vector
 
typedef T value_type
 Type of the value the vector is storing.
 
typedef void base_to_copy
 
typedef grow_policy_double grow_policy
 growing policy of this vector
 

Public Member Functions

size_t size () const
 return the size of the vector
 
void resize (size_t slot)
 
void clear ()
 Remove all the element from the vector.
 
void add (const T &v)
 It insert a new object on the vector, eventually it reallocate the grid.
 
void add (T &&v)
 It insert a new object on the vector, eventually it reallocate the grid.
 
void add ()
 Add an empty object (it call the default constructor () ) at the end of the vector.
 
T & last ()
 Get the last element.
 
const T & last () const
 Get the last element.
 
void swap (vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&v)
 swap the memory between the two vector
 
T & at (int i)
 
T & operator[] (int id)
 Get an element of the vector.
 
T & get (int id)
 Get an element of the vector.
 
const T & get (int id) const
 Get an element of the vector.
 
T & get (size_t id)
 Get an element of the vector.
 
const T & get (size_t id) const
 Get an element of the vector.
 
void reserve (size_t ns)
 reserve a memory space in advance to avoid reallocation
 
 vector () noexcept
 Constructor, vector of size 0.
 
 vector (size_t sz) noexcept
 Constructor, vector of size sz.
 
 vector (const vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &v) noexcept
 Constructor from another vector.
 
 vector (const std::initializer_list< T > &v)
 Initializer from constructor.
 
 vector (vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&v) noexcept
 Constructor from another vector.
 
template<class InputIt >
 vector (InputIt first, InputIt last)
 Constructor from iterators.
 
 ~vector () noexcept
 destructor
 
void swap (vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &v)
 
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > & operator= (const vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &v)
 Operator= copy the vector into another.
 
vector_key_iterator getIterator () const
 Get an iterator over all the elements of the vector.
 
vector_key_iterator getIteratorTo (size_t k) const
 Get iterator until a specified element.
 
void * getPointer ()
 Return the pointer to the chunk of memory.
 
const void * getPointer () const
 Return the pointer to the chunk of memory.
 
template<unsigned int ... prp>
void hostToDevice ()
 Do nothing.
 
template<unsigned int ... prp>
void deviceToHost ()
 Do nothing.
 
template<unsigned int ... prp>
void deviceToHost (size_t start, size_t stop)
 Do nothing.
 
template<unsigned int ... prp>
void hostToDevice (size_t start, size_t stop)
 Do nothing.
 
vector_custd_ker< typename apply_transform< memory_traits_inte, aggregate< T > >::type, memory_traits_intetoKernel ()
 Convert the grid into a data-structure compatible for computing into GPU.
 
size_t getLastError ()
 Return the last error.
 
void vector_overflow (size_t v1) const
 check that the id does not overflow the buffer
 

Static Public Member Functions

static bool noPointers ()
 This class has pointer inside.
 

Private Types

typedef memory_traits_inte< aggregate< T > >::type layout
 

Private Attributes

vector< aggregate< T >, CudaMemory, memory_traits_inte, grow_policy_double > base
 1-D static grid
 
size_t err_code = 0
 Error code.
 

Member Typedef Documentation

◆ base_to_copy

template<typename T >
typedef void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::base_to_copy

Definition at line 48 of file map_vector_std_cuda.hpp.

◆ grow_policy

template<typename T >
typedef grow_policy_double vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::grow_policy

growing policy of this vector

Definition at line 51 of file map_vector_std_cuda.hpp.

◆ iterator_key

template<typename T >
typedef vector_key_iterator vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::iterator_key

iterator for the vector

Definition at line 44 of file map_vector_std_cuda.hpp.

◆ layout

template<typename T >
typedef memory_traits_inte<aggregate<T>>::type vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::layout
private

Definition at line 28 of file map_vector_std_cuda.hpp.

◆ layout_base_

template<typename T >
typedef memory_traits_inte<T> vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::layout_base_

Definition at line 41 of file map_vector_std_cuda.hpp.

◆ value_type

template<typename T >
typedef T vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::value_type

Type of the value the vector is storing.

Definition at line 46 of file map_vector_std_cuda.hpp.

◆ yes_i_am_vector

template<typename T >
typedef int vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::yes_i_am_vector

it define that it is a vector

Definition at line 39 of file map_vector_std_cuda.hpp.

Constructor & Destructor Documentation

◆ vector() [1/6]

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector ( )
inlinenoexcept

Constructor, vector of size 0.

Definition at line 256 of file map_vector_std_cuda.hpp.

◆ vector() [2/6]

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector ( size_t  sz)
inlinenoexcept

Constructor, vector of size sz.

Definition at line 262 of file map_vector_std_cuda.hpp.

◆ vector() [3/6]

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector ( const vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &  v)
inlinenoexcept

Constructor from another vector.

Definition at line 268 of file map_vector_std_cuda.hpp.

◆ vector() [4/6]

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector ( const std::initializer_list< T > &  v)
inline

Initializer from constructor.

Parameters
vInitializer list

Definition at line 279 of file map_vector_std_cuda.hpp.

◆ vector() [5/6]

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector ( vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&  v)
inlinenoexcept

Constructor from another vector.

Definition at line 288 of file map_vector_std_cuda.hpp.

◆ vector() [6/6]

template<typename T >
template<class InputIt >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector ( InputIt  first,
InputIt  last 
)
inline

Constructor from iterators.

Definition at line 296 of file map_vector_std_cuda.hpp.

◆ ~vector()

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::~vector ( )
inlinenoexcept

destructor

Definition at line 305 of file map_vector_std_cuda.hpp.

Member Function Documentation

◆ add() [1/3]

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::add ( )
inline

Add an empty object (it call the default constructor () ) at the end of the vector.

Definition at line 117 of file map_vector_std_cuda.hpp.

◆ add() [2/3]

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::add ( const T &  v)
inline

It insert a new object on the vector, eventually it reallocate the grid.

Parameters
velement to add
Warning
It is not thread safe should not be used in multi-thread environment reallocation, work only on cpu

vector_isel<T>::value

Definition at line 93 of file map_vector_std_cuda.hpp.

◆ add() [3/3]

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::add ( T &&  v)
inline

It insert a new object on the vector, eventually it reallocate the grid.

Parameters
velement to add
Warning
It is not thread safe should not be used in multi-thread environment reallocation, work only on cpu

vector_isel<T>::value

Definition at line 108 of file map_vector_std_cuda.hpp.

◆ at()

template<typename T >
T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::at ( int  i)
inline

Definition at line 160 of file map_vector_std_cuda.hpp.

◆ clear()

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::clear ( )
inline

Remove all the element from the vector.

Definition at line 79 of file map_vector_std_cuda.hpp.

◆ deviceToHost() [1/2]

template<typename T >
template<unsigned int ... prp>
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::deviceToHost ( )
inline

Do nothing.

Definition at line 387 of file map_vector_std_cuda.hpp.

◆ deviceToHost() [2/2]

template<typename T >
template<unsigned int ... prp>
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::deviceToHost ( size_t  start,
size_t  stop 
)
inline

Do nothing.

Definition at line 396 of file map_vector_std_cuda.hpp.

◆ get() [1/4]

template<typename T >
T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::get ( int  id)
inline

Get an element of the vector.

Parameters
idelement to get
Returns
the reference to the element

Definition at line 188 of file map_vector_std_cuda.hpp.

◆ get() [2/4]

template<typename T >
const T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::get ( int  id) const
inline

Get an element of the vector.

Template Parameters
pmust be 0
Parameters
idelement to get
Returns
the reference to the element

Definition at line 206 of file map_vector_std_cuda.hpp.

◆ get() [3/4]

template<typename T >
T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::get ( size_t  id)
inline

Get an element of the vector.

Parameters
idelement to get
Returns
the element reference

Definition at line 222 of file map_vector_std_cuda.hpp.

◆ get() [4/4]

template<typename T >
const T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::get ( size_t  id) const
inline

Get an element of the vector.

Parameters
idelement to get
Returns
the element value

Definition at line 237 of file map_vector_std_cuda.hpp.

◆ getIterator()

template<typename T >
vector_key_iterator vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::getIterator ( ) const
inline

Get an iterator over all the elements of the vector.

Returns
an iterator

Definition at line 339 of file map_vector_std_cuda.hpp.

◆ getIteratorTo()

template<typename T >
vector_key_iterator vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::getIteratorTo ( size_t  k) const
inline

Get iterator until a specified element.

Parameters
kkey
Returns
an iterator

Definition at line 351 of file map_vector_std_cuda.hpp.

◆ getLastError()

template<typename T >
size_t vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::getLastError ( )
inline

Return the last error.

Returns
erro code

Definition at line 439 of file map_vector_std_cuda.hpp.

◆ getPointer() [1/2]

template<typename T >
void * vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::getPointer ( )
inline

Return the pointer to the chunk of memory.

Returns
the pointer to the chunk of memory

Definition at line 361 of file map_vector_std_cuda.hpp.

◆ getPointer() [2/2]

template<typename T >
const void * vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::getPointer ( ) const
inline

Return the pointer to the chunk of memory.

Returns
the pointer to the chunk of memory

Definition at line 371 of file map_vector_std_cuda.hpp.

◆ hostToDevice() [1/2]

template<typename T >
template<unsigned int ... prp>
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::hostToDevice ( )
inline

Do nothing.

Definition at line 379 of file map_vector_std_cuda.hpp.

◆ hostToDevice() [2/2]

template<typename T >
template<unsigned int ... prp>
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::hostToDevice ( size_t  start,
size_t  stop 
)
inline

Do nothing.

Definition at line 405 of file map_vector_std_cuda.hpp.

◆ last() [1/2]

template<typename T >
T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::last ( )
inline

Get the last element.

Returns
the last element as reference

Definition at line 127 of file map_vector_std_cuda.hpp.

◆ last() [2/2]

template<typename T >
const T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::last ( ) const
inline

Get the last element.

Returns
the last element as reference

Definition at line 141 of file map_vector_std_cuda.hpp.

◆ noPointers()

template<typename T >
static bool vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::noPointers ( )
inlinestatic

This class has pointer inside.

Returns
false

Definition at line 429 of file map_vector_std_cuda.hpp.

◆ operator=()

template<typename T >
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::operator= ( const vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &  v)
inline

Operator= copy the vector into another.

Parameters
vvector to copy
Returns
itself

Definition at line 327 of file map_vector_std_cuda.hpp.

◆ operator[]()

template<typename T >
T & vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::operator[] ( int  id)
inline

Get an element of the vector.

Parameters
idelement to get
Returns
the reference to the element

Definition at line 172 of file map_vector_std_cuda.hpp.

◆ reserve()

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::reserve ( size_t  ns)
inline

reserve a memory space in advance to avoid reallocation

Parameters
nsnumber of element the memory has to store

Definition at line 250 of file map_vector_std_cuda.hpp.

◆ resize()

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::resize ( size_t  slot)
inline

\ brief Resize the vector to contain n elements

Parameters
slotnumber of elements

Definition at line 71 of file map_vector_std_cuda.hpp.

◆ size()

template<typename T >
size_t vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::size ( ) const
inline

return the size of the vector

Definition at line 60 of file map_vector_std_cuda.hpp.

◆ swap() [1/2]

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::swap ( vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&  v)
inline

swap the memory between the two vector

Parameters
vvector to swap

Definition at line 155 of file map_vector_std_cuda.hpp.

◆ swap() [2/2]

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::swap ( vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &  v)
inline

swap the content of the vector

Parameters
vvector to be swapped with

Definition at line 314 of file map_vector_std_cuda.hpp.

◆ toKernel()

template<typename T >
vector_custd_ker< typename apply_transform< memory_traits_inte, aggregate< T > >::type, memory_traits_inte > vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::toKernel ( )
inline

Convert the grid into a data-structure compatible for computing into GPU.

The object created can be considered like a reference of the original

Returns
an usable vector in the kernel

Definition at line 417 of file map_vector_std_cuda.hpp.

◆ vector_overflow()

template<typename T >
void vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::vector_overflow ( size_t  v1) const
inline

check that the id does not overflow the buffer

Parameters
v1id to check

Definition at line 449 of file map_vector_std_cuda.hpp.

Field Documentation

◆ base

template<typename T >
vector<aggregate<T>,CudaMemory,memory_traits_inte,grow_policy_double> vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::base
private

1-D static grid

Definition at line 31 of file map_vector_std_cuda.hpp.

◆ err_code

template<typename T >
size_t vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR >::err_code = 0
private

Error code.

Definition at line 34 of file map_vector_std_cuda.hpp.


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