OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector_subset.hpp
1#ifndef VECTOR_SUBSET_HPP
2#define VECTOR_SUBSET_HPP
3
4namespace openfpm
5{
6
7template<unsigned int dim,
8 typename prop,
9 template<typename> class layout_base = memory_traits_inte>
11 {
13
14 mutable openfpm::vector_gpu_ker<aggregate<int>,layout_base> indexes;
15
16 public:
17
18 vector_subset_ker(openfpm::vector_gpu_ker<typename apply_transform<layout_base,prop>::type,layout_base> & v_all,
19 openfpm::vector_gpu_ker<aggregate<int>,layout_base> & indexes)
20 :v_all(v_all),indexes(indexes)
21 {}
22
23 // get the
24
25 template <unsigned int p>
26 __device__ __host__ inline auto get(size_t id) const -> decltype(v_all.template get<p>(0))
27 {
28 return v_all.template get<p>(indexes.template get<0>(id));
29 }
30 }
31
32public:
33
34 template<typename T, typename Memory, template<typename> class layout_base, typename grow_p, unsigned int impl>
35 class vector_sub
36 {
38
39 vector<aggregate<int>,Memory,layout_base,grow_p,impl> & indexes;
40
41 public:
42
44 vector<aggregate<int>,Memory,layout_base,grow_p,impl> & indexes)
45 :v_all(v_all),indexes(indexes)
46 {}
47
48
49 // To kernel
50 template<unsigned int ... prp> vector_dist_ker<dim,St,prop,layout_base> toKernel()
51 {
52 vector_subset_ker<dim,St,prop,layout_base> v(v_all.toKernel(), indexes.toKernel());
53
54 return v;
55 }
56
57 template <unsigned int p>
58 inline auto get(size_t id) const -> decltype(v_all.template get<p>(0))
59 {
60 return v_all.template get<p>(indexes.template get<0>(id));
61 }
62
63 }
64
65};
66
67#endif
Implementation of 1-D std::vector like structure.
convert a type into constant type
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Transform the boost::fusion::vector into memory specification (memory_traits)
grid interface available when on gpu