OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
cp_block.hpp
1 /*
2  * cp_block.hpp
3  *
4  * Created on: Apr 20, 2020
5  * Author: i-bird
6  */
7 
8 #ifndef CP_BLOCK_HPP_
9 #define CP_BLOCK_HPP_
10 
11 #include "util/create_vmpl_sequence.hpp"
12 
13 template<typename T, unsigned int stencil_size, typename vector_vmpl, unsigned int dim>
15 {
16 public:
17 
18  typedef typename vmpl_sum_constant<2*stencil_size,vector_vmpl>::type stop_border_vmpl;
19  typedef typename vmpl_create_constant<dim,stencil_size>::type start_border_vmpl;
20 
21  static const int sizeBlock = vmpl_reduce_prod<vector_vmpl>::type::value;
22  static const int sizeBlockBord = vmpl_reduce_prod<stop_border_vmpl>::type::value;
23 };
24 
25 template<typename T, unsigned int stencil_size, typename vector_vmpl, unsigned int dim>
26 class cp_block: public cp_block_base<T,stencil_size,vector_vmpl,dim>
27 {
28  // we create first a vector with
29 
31 
32  T (& ptr)[base::sizeBlock];
33 
34 public:
35 
36  __device__ __host__ explicit cp_block(T (& ptr)[base::sizeBlock])
37  :ptr(ptr)
38  {}
39 
40  template<typename ... ArgsT>
41  __device__ __host__ T & operator()(ArgsT ... args)
42  {
43  return ptr[Lin_vmpl_off<vector_vmpl,typename base::start_border_vmpl>(args ...)];
44  }
45 };
46 
47 template<typename T, unsigned int stencil_size, typename vector_vmpl>
48 class cp_block<T,stencil_size,vector_vmpl,2>: public cp_block_base<T,stencil_size,vector_vmpl,2>
49 {
50  // we create first a vector with
51 
53 
54  T (& ptr)[base::sizeBlock];
55 
56 public:
57 
58  __device__ __host__ explicit cp_block(T (& ptr)[base::sizeBlock])
59  :ptr(ptr)
60  {}
61 
62  __device__ __host__ int LinId(int i , int j)
63  {
64  return Lin_vmpl_off<vector_vmpl,typename base::start_border_vmpl>(i,j);
65  }
66 
67  __device__ __host__ T & operator()( int i , int j)
68  {
69  return ptr[Lin_vmpl_off<vector_vmpl,typename base::start_border_vmpl>(i,j)];
70  }
71 };
72 
73 template<typename T, unsigned int stencil_size, typename vector_vmpl>
74 class cp_block<T,stencil_size,vector_vmpl,3>: public cp_block_base<T,stencil_size,vector_vmpl,3>
75 {
76  // we create first a vector with
77 
79 
80  T (& ptr)[base::sizeBlock];
81 
82 public:
83 
84  __device__ __host__ explicit cp_block(T (& ptr)[base::sizeBlock])
85  :ptr(ptr)
86  {}
87 
88  __device__ __host__ int LinId(int i , int j, int k)
89  {
90  return Lin_vmpl_off<vector_vmpl,typename base::start_border_vmpl>(i,j,k);
91  }
92 
93  __device__ __host__ T & operator()(int i , int j, int k)
94  {
95  return ptr[Lin_vmpl_off<vector_vmpl,typename base::start_border_vmpl>(i,j,k)];
96  }
97 };
98 
99 #endif /* CP_BLOCK_HPP_ */
to_variadic_const_impl< 1, N, M, exit_::value, M >::type type
generate the boost::fusion::vector apply H on each term