OpenFPM  5.2.0
Project that contain the implementation of distributed structures
vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > Class Template Reference

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

#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. More...
 
void add (T &&v)
 It insert a new object on the vector, eventually it reallocate the grid. More...
 
void add ()
 Add an empty object (it call the default constructor () ) at the end of the vector.
 
T & last ()
 Get the last element. More...
 
const T & last () const
 Get the last element. More...
 
void swap (vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&v)
 swap the memory between the two vector More...
 
T & at (int i)
 
T & operator[] (int id)
 Get an element of the vector. More...
 
T & get (int id)
 Get an element of the vector. More...
 
const T & get (int id) const
 Get an element of the vector. More...
 
T & get (size_t id)
 Get an element of the vector. More...
 
const T & get (size_t id) const
 Get an element of the vector. More...
 
void reserve (size_t ns)
 reserve a memory space in advance to avoid reallocation More...
 
 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. More...
 
 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. More...
 
vector_key_iterator getIterator () const
 Get an iterator over all the elements of the vector. More...
 
vector_key_iterator getIteratorTo (size_t k) const
 Get iterator until a specified element. More...
 
void * getPointer ()
 Return the pointer to the chunk of memory. More...
 
const void * getPointer () const
 Return the pointer to the chunk of memory. More...
 
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_inte > toKernel ()
 Convert the grid into a data-structure compatible for computing into GPU. More...
 
size_t getLastError ()
 Return the last error. More...
 
void vector_overflow (size_t v1) const
 check that the id does not overflow the buffer More...
 

Static Public Member Functions

static bool noPointers ()
 This class has pointer inside. More...
 

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.
 

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.

Constructor & Destructor Documentation

◆ vector()

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.

Member Function Documentation

◆ add() [1/2]

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() [2/2]

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.

◆ 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.

◆ 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.

◆ 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.


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