8#ifndef CUDA_GRID_GPU_FUNCS_CUH_
9#define CUDA_GRID_GPU_FUNCS_CUH_
12#include "util/cuda_launch.hpp"
13#include "map_grid_cuda_ker.cuh"
15#if defined(CUDA_GPU) && defined(__NVCC__)
17template<
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);
30template<
unsigned int dim,
typename gr
id_type>
31struct 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);
46template<
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);
65template<
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);
87template<
unsigned int dim,
typename gr
id_type>
90 copy_ndim_grid_impl<dim,grid_type>::copy(src,dst);
97template<
bool inte_or_lin,
typename base_gr
id,
unsigned int dim,
typename T>
100 template<
typename gr
id_type>
static base_grid toKernel(
grid_type & gc)
102 base_grid g(gc.getGrid());
104 g.get_data_().disable_manage_memory();
105 g.get_data_().mem = gc.get_internal_data_().mem;
108 g.get_data_().mem_r.bind_ref(gc.get_internal_data_().mem_r);
109 g.get_data_().switchToDevicePtr();
115template<
typename base_gr
id,
unsigned int dim,
typename T>
118 template<
typename gr
id_type>
static base_grid toKernel(
grid_type & gc)
120 base_grid g(gc.getGrid());
122 typename std::remove_reference<
decltype(g.get_data_())>::type> cp_mc(gc.get_internal_data_(),g.get_data_());
124 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