8 #ifndef CUDA_GRID_GPU_FUNCS_CUH_
9 #define CUDA_GRID_GPU_FUNCS_CUH_
12 #include "util/cuda_util.hpp"
13 #include "map_grid_cuda_ker.cuh"
15 #if defined(CUDA_GPU) && defined(__NVCC__)
17 template<
unsigned int dim,
typename gr
id_type>
20 unsigned int i = blockIdx.x;
22 if (i >= src.getGrid().
size() || i >= dst.getGrid().
size())
25 auto key_src = src.getGrid().InvLinId(i);
27 dst.get_o(key_src) = src.get_o(key_src);
30 template<
unsigned int dim,
typename gr
id_type>
31 struct copy_ndim_grid_impl
35 unsigned int i = threadIdx.x + blockIdx.x * blockDim.x;
37 if (i >= src.getGrid().
size() || i >= dst.getGrid().
size())
40 auto key_src = src.getGrid().InvLinId(i);
42 dst.get_o(key_src) = src.get_o(key_src);
46 template<
typename gr
id_type>
52 key_src.
set_d(0,threadIdx.x + blockIdx.x * blockDim.x);
53 key_src.
set_d(1,threadIdx.y + blockIdx.y * blockDim.y);
55 if (key_src.
get(0) >= src.getGrid().
size(0)) {
return;}
56 if (key_src.
get(1) >= src.getGrid().
size(1)) {
return;}
58 if (key_src.
get(0) >= dst.getGrid().
size(0)) {
return;}
59 if (key_src.
get(1) >= dst.getGrid().
size(1)) {
return;}
61 dst.get_o(key_src) = src.get_o(key_src);
65 template<
typename gr
id_type>
71 key_src.
set_d(0,threadIdx.x + blockIdx.x * blockDim.x);
72 key_src.
set_d(1,threadIdx.y + blockIdx.y * blockDim.y);
73 key_src.
set_d(2,threadIdx.y + blockIdx.y * blockDim.y);
75 if (key_src.
get(0) >= src.getGrid().
size(0)) {
return;}
76 if (key_src.
get(1) >= src.getGrid().
size(1)) {
return;}
77 if (key_src.
get(2) >= src.getGrid().
size(2)) {
return;}
79 if (key_src.
get(0) >= dst.getGrid().
size(0)) {
return;}
80 if (key_src.
get(1) >= dst.getGrid().
size(1)) {
return;}
81 if (key_src.
get(2) >= dst.getGrid().
size(2)) {
return;}
83 dst.get_o(key_src) = src.get_o(key_src);
87 template<
unsigned int dim,
typename gr
id_type>
90 copy_ndim_grid_impl<dim,grid_type>::copy(src,dst);
97 template<
bool inte_or_lin,
typename base_gr
id,
unsigned int dim,
typename T,
typename S>
100 template<
typename gr
id_type>
static base_grid toKernel(
grid_type & gc)
102 base_grid g(gc.getGrid());
103 auto &grid_layout = g.get_data_();
105 grid_layout.disable_manage_memory();
106 grid_layout.mem = gc.get_internal_data_().mem;
109 grid_layout.mem_r.bind_ref(gc.get_internal_data_().mem_r);
111 {grid_layout.mem_r.set_pointer(((S*)grid_layout.mem)->getDevicePointer());}
117 template<
typename base_gr
id,
unsigned int dim,
typename T,
typename S>
120 template<
typename gr
id_type>
static base_grid toKernel(
grid_type & gc)
122 base_grid g(gc.getGrid());
124 typename std::remove_reference<decltype(g.get_data_())>::type> cp_mc(gc.get_internal_data_(),g.get_data_());
126 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,T::max_prop> >(cp_mc);
This is a distributed grid.
size_t size() const
Return the total number of points in the grid.
grid_key_dx is the key to access any element in the grid
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
__device__ __host__ index_type get(index_type i) const
Get the i index.
this class is a functor for "for_each" algorithm