8#ifndef SRC_GRID_GRID_UTIL_TEST_HPP_
9#define SRC_GRID_GRID_UTIL_TEST_HPP_
11#include "map_grid.hpp"
12#include "Point_test.hpp"
13#include "grid_key.hpp"
14#include "Space/Shape/HyperCube.hpp"
21template<
unsigned int dim,
typename T>
void fill_grid(T &
grid)
25 auto key_it =
grid.getIterator();
27 while (key_it.isNext())
31 grid.template get<P::x>(kk) =
grid.getGrid().LinId(kk);
32 grid.template get<P::y>(kk) =
grid.getGrid().LinId(kk)+1;
33 grid.template get<P::z>(kk) =
grid.getGrid().LinId(kk)+2;
34 grid.template get<P::s>(kk) =
grid.getGrid().LinId(kk)+3;
36 grid.template get<P::v>(kk)[0] =
grid.getGrid().LinId(kk)+123;
37 grid.template get<P::v>(kk)[1] =
grid.getGrid().LinId(kk)+124;
38 grid.template get<P::v>(kk)[2] =
grid.getGrid().LinId(kk)+125;
40 grid.template get<P::t>(kk)[0][0] =
grid.getGrid().LinId(kk)+567;
41 grid.template get<P::t>(kk)[0][1] =
grid.getGrid().LinId(kk)+568;
42 grid.template get<P::t>(kk)[0][2] =
grid.getGrid().LinId(kk)+569;
43 grid.template get<P::t>(kk)[1][0] =
grid.getGrid().LinId(kk)+570;
44 grid.template get<P::t>(kk)[1][1] =
grid.getGrid().LinId(kk)+571;
45 grid.template get<P::t>(kk)[1][2] =
grid.getGrid().LinId(kk)+572;
46 grid.template get<P::t>(kk)[2][0] =
grid.getGrid().LinId(kk)+573;
47 grid.template get<P::t>(kk)[2][1] =
grid.getGrid().LinId(kk)+574;
48 grid.template get<P::t>(kk)[2][2] =
grid.getGrid().LinId(kk)+575;
54template<
unsigned int dim,
typename g>
void test_layout_gridNd(g & c3,
size_t sz)
57 std::cout << dim <<
"D Array with grid_key (without redundant dimension): " <<
"\n";
72 c3.template get<P::x>(kk) = 1.1f;
73 c3.template get<P::y>(kk) = 1.2f;
74 c3.template get<P::z>(kk) = 1.3f;
75 c3.template get<P::s>(kk) = 1.0f;
77 c3.template get<P::v>(kk)[0] = 1.0f;
78 c3.template get<P::v>(kk)[1] = 2.0f;
79 c3.template get<P::v>(kk)[2] = 3.0f;
81 c3.template get<P::t>(kk)[0][0] = 1.0f;
82 c3.template get<P::t>(kk)[0][1] = 2.0f;
83 c3.template get<P::t>(kk)[0][2] = 3.0f;
84 c3.template get<P::t>(kk)[1][0] = 4.0f;
85 c3.template get<P::t>(kk)[1][1] = 5.0f;
86 c3.template get<P::t>(kk)[1][2] = 6.0f;
87 c3.template get<P::t>(kk)[2][0] = 7.0f;
88 c3.template get<P::t>(kk)[2][1] = 8.0f;
89 c3.template get<P::t>(kk)[2][2] = 9.0f;
99 std::cout <<
"End : " << pow(sz,dim)*16*4/1024/1024 <<
" MB " <<
" Bandwidth: " << pow(sz,dim)*16*4/1024/1024/t.
getwct() <<
" MB/s " <<
"\n";
106 key_it = c3.getIterator();
112 c3.template get<P::x>(kk) = c3.getGrid().LinId(kk);
113 c3.template get<P::y>(kk) = c3.getGrid().LinId(kk)+1;
114 c3.template get<P::z>(kk) = c3.getGrid().LinId(kk)+2;
115 c3.template get<P::s>(kk) = c3.getGrid().LinId(kk)+3;
117 c3.template get<P::v>(kk)[0] = c3.getGrid().LinId(kk)+123;
118 c3.template get<P::v>(kk)[1] = c3.getGrid().LinId(kk)+124;
119 c3.template get<P::v>(kk)[2] = c3.getGrid().LinId(kk)+125;
121 c3.template get<P::t>(kk)[0][0] = c3.getGrid().LinId(kk)+567;
122 c3.template get<P::t>(kk)[0][1] = c3.getGrid().LinId(kk)+568;
123 c3.template get<P::t>(kk)[0][2] = c3.getGrid().LinId(kk)+569;
124 c3.template get<P::t>(kk)[1][0] = c3.getGrid().LinId(kk)+570;
125 c3.template get<P::t>(kk)[1][1] = c3.getGrid().LinId(kk)+571;
126 c3.template get<P::t>(kk)[1][2] = c3.getGrid().LinId(kk)+572;
127 c3.template get<P::t>(kk)[2][0] = c3.getGrid().LinId(kk)+573;
128 c3.template get<P::t>(kk)[2][1] = c3.getGrid().LinId(kk)+574;
129 c3.template get<P::t>(kk)[2][2] = c3.getGrid().LinId(kk)+575;
135 key_it = c3.getIterator();
141 if (c3.template get<P::x>(kk) != c3.getGrid().LinId(kk)) passed =
false;
142 if (c3.template get<P::y>(kk) != c3.getGrid().LinId(kk)+1) passed =
false;
143 if (c3.template get<P::z>(kk) != c3.getGrid().LinId(kk)+2) passed =
false;
144 if (c3.template get<P::s>(kk) != c3.getGrid().LinId(kk)+3) passed =
false;
146 if (c3.template get<P::v>(kk)[0] != c3.getGrid().LinId(kk)+123) passed =
false;
147 if (c3.template get<P::v>(kk)[1] != c3.getGrid().LinId(kk)+124) passed =
false;
148 if (c3.template get<P::v>(kk)[2] != c3.getGrid().LinId(kk)+125) passed =
false;
150 if (c3.template get<P::t>(kk)[0][0] != c3.getGrid().LinId(kk)+567) passed =
false;
151 if (c3.template get<P::t>(kk)[0][1] != c3.getGrid().LinId(kk)+568) passed =
false;
152 if (c3.template get<P::t>(kk)[0][2] != c3.getGrid().LinId(kk)+569) passed =
false;
153 if (c3.template get<P::t>(kk)[1][0] != c3.getGrid().LinId(kk)+570) passed =
false;
154 if (c3.template get<P::t>(kk)[1][1] != c3.getGrid().LinId(kk)+571) passed =
false;
155 if (c3.template get<P::t>(kk)[1][2] != c3.getGrid().LinId(kk)+572) passed =
false;
156 if (c3.template get<P::t>(kk)[2][0] != c3.getGrid().LinId(kk)+573) passed =
false;
157 if (c3.template get<P::t>(kk)[2][1] != c3.getGrid().LinId(kk)+574) passed =
false;
158 if (c3.template get<P::t>(kk)[2][2] != c3.getGrid().LinId(kk)+575) passed =
false;
163 BOOST_REQUIRE_EQUAL(passed,
true);
192 key_it = c3.getIterator();
198 c3.template get<P::x>(kk) = 0.0;
203 for(
size_t i = 0 ; i <= dim ; i++)
210 for (
size_t j = 0 ; j < combs.size() ; j++)
219 for (
size_t k = 0 ; k < dim ; k++)
223 if (combs[j].c[k] == -1)
228 else if (combs[j].c[k] == 1)
230 start.
set_d(k,c3.getGrid().size(k)-1);
231 stop.
set_d(k,c3.getGrid().size(k)-1);
236 stop.
set_d(k,c3.getGrid().size(k)-2);
240 bool make_test =
true;
249 if (make_test ==
true)
251 auto key_it = c3.getSubIterator(start,stop);
257 BOOST_REQUIRE_EQUAL(c3.template get<P::x>(kk),0.0);
259 c3.template get<P::x>(kk) = 1.0;
269 key_it = c3.getIterator();
275 BOOST_REQUIRE_EQUAL(c3.template get<P::x>(kk),1.0);
static std::vector< comb< dim > > getCombinations_R(size_t d)
Test structure used for several test.
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
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.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
double getwct()
Return the elapsed real time.