8#ifndef MAP_VECTOR_STD_CUDA_HPP_
9#define MAP_VECTOR_STD_CUDA_HPP_
11#include "map_vector_std_cuda_ker.cuh"
48 typedef void base_to_copy;
53 template<
typename Tobj>
73 base.resize_no_device(slot);
93 inline void add(
const T & v)
96 base.template get<0>(size()-1) = v;
110 base.add_no_device();
111 base.template get<0>(size()-1).swap(v);
119 base.add_no_device();
130 if (base.size() == 0)
131 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" vector of size 0\n";
133 return base.template get<0>(size()-1);
144 if (base.size() == 0)
145 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" vector of size 0\n";
147 return base.template get<0>(size()-1);
155 void swap(vector<T,CudaMemory,memory_traits_inte,grow_policy_double,STD_VECTOR> && v)
178 return base.template get<0>(
id);
194 return base.template get<0>(
id);
206 inline const T&
get(
int id)
const
212 return base.template get<0>(
id);
227 return base.template get<0>(
id);
237 inline const T &
get(
size_t id)
const
242 return base.template get<0>(
id);
263 :base(sz),err_code(0)
268 vector(
const vector<T,CudaMemory,memory_traits_inte,grow_policy_double,STD_VECTOR> & v) noexcept
279 vector(
const std::initializer_list<T> & v)
288 vector(vector<T,CudaMemory,memory_traits_inte,grow_policy_double,STD_VECTOR> && v) noexcept
295 template<
class InputIt >
298 while(first != last) {
314 void swap(vector<T,CudaMemory,memory_traits_inte,grow_policy_double,STD_VECTOR> & v)
326 vector<T,CudaMemory,memory_traits_inte,grow_policy_double,STD_VECTOR> &
327 operator=(
const vector<T,CudaMemory,memory_traits_inte,grow_policy_double,STD_VECTOR> & v)
341 return vector_key_iterator(base.size());
353 return vector_key_iterator(k);
363 return &base.template get<0>(0);
373 return &base.template get<0>(0);
381 base.template hostToDevice<0>();
389 base.template deviceToHost<0>();
396 template<
unsigned int ... prp>
void deviceToHost(
size_t start,
size_t stop)
398 base.template deviceToHost<0>(start,stop);
405 template<
unsigned int ... prp>
void hostToDevice(
size_t start,
size_t stop)
407 base.template hostToDevice<0>(start,stop);
451 if (v1 >= base.size())
453 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" overflow id: " << v1 <<
"\n";\
454 size_t * err_code_pointer = (
size_t *)&this->err_code;\
455 *err_code_pointer = 2001;\
457 ACTION_ON_ERROR(VECTOR_ERROR_OBJECT);\
T & get(size_t id)
Get an element of the vector.
void hostToDevice(size_t start, size_t stop)
Do nothing.
void add()
Add an empty object (it call the default constructor () ) at the end of the vector.
const T & last() const
Get the last element.
vector(vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&v) noexcept
Constructor from another vector.
void add(T &&v)
It insert a new object on the vector, eventually it reallocate the grid.
void deviceToHost()
Do nothing.
T & get(int id)
Get an element of the vector.
vector< aggregate< T >, CudaMemory, memory_traits_inte, grow_policy_double > base
1-D static grid
vector(size_t sz) noexcept
Constructor, vector of size sz.
void vector_overflow(size_t v1) const
check that the id does not overflow the buffer
vector_key_iterator iterator_key
iterator for the vector
grow_policy_double grow_policy
growing policy of this vector
void * getPointer()
Return the pointer to the chunk of memory.
vector() noexcept
Constructor, vector of size 0.
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.
void clear()
Remove all the element from the vector.
T value_type
Type of the value the vector is storing.
void hostToDevice()
Do nothing.
vector(InputIt first, InputIt last)
Constructor from iterators.
int yes_i_am_vector
it define that it is a vector
void add(const T &v)
It insert a new object on the vector, eventually it reallocate the grid.
vector_key_iterator getIterator() const
Get an iterator over all the elements of the vector.
const void * getPointer() const
Return the pointer to the chunk of memory.
size_t getLastError()
Return the last error.
static bool noPointers()
This class has pointer inside.
vector_key_iterator getIteratorTo(size_t k) const
Get iterator until a specified element.
size_t size() const
return the size of the vector
void swap(vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &v)
void deviceToHost(size_t start, size_t stop)
Do nothing.
T & last()
Get the last element.
~vector() noexcept
destructor
const T & get(size_t id) const
Get an element of the vector.
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.
vector(const std::initializer_list< T > &v)
Initializer from constructor.
void reserve(size_t ns)
reserve a memory space in advance to avoid reallocation
void swap(vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &&v)
swap the memory between the two vector
vector(const vector< T, CudaMemory, memory_traits_inte, grow_policy_double, STD_VECTOR > &v) noexcept
Constructor from another vector.
const T & get(int id) const
Get an element of the vector.
T & operator[](int id)
Get an element of the vector.
Transform the boost::fusion::vector into memory specification (memory_traits)
grid interface available when on gpu