8#ifndef OPENFPM_DATA_SRC_UTIL_TEST_COMPUTE_OPTIMAL_DEVICE_GRID_UNIT_TESTS_HPP_
9#define OPENFPM_DATA_SRC_UTIL_TEST_COMPUTE_OPTIMAL_DEVICE_GRID_UNIT_TESTS_HPP_
11#include "util/compute_optimal_device_grid.hpp"
13BOOST_AUTO_TEST_SUITE( compute_optimal_device_grid_test )
15BOOST_AUTO_TEST_CASE( compute_optimal_device_use_test )
21 calculate_optimal_device_grid<1>(dg,sz,1,1);
23 BOOST_REQUIRE_EQUAL(dg.
threads.
x,1ul);
24 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
25 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
27 BOOST_REQUIRE_EQUAL(dg.
grids.
x,1ul);
28 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
29 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
40 calculate_optimal_device_grid<1>(dg,sz,8,4);
42 BOOST_REQUIRE_EQUAL(dg.
threads.
x,1ul);
43 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
44 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
46 BOOST_REQUIRE_EQUAL(dg.
grids.
x,1ul);
47 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
48 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
51 calculate_optimal_device_grid<1>(dg,sz,8,4);
53 BOOST_REQUIRE_EQUAL(dg.
threads.
x,6ul);
54 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
55 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
57 BOOST_REQUIRE_EQUAL(dg.
grids.
x,1ul);
58 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
59 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
71 calculate_optimal_device_grid<1>(dg,sz,28,10);
73 BOOST_REQUIRE_EQUAL(dg.
threads.
x,6ul);
74 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
75 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
77 BOOST_REQUIRE_EQUAL(dg.
grids.
x,1ul);
78 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
79 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
83 calculate_optimal_device_grid<1>(dg,sz,28,10);
85 BOOST_REQUIRE_EQUAL(dg.
threads.
x,17ul);
86 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
87 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
89 BOOST_REQUIRE_EQUAL(dg.
grids.
x,1ul);
90 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
91 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
95 calculate_optimal_device_grid<1>(dg,sz,1,1);
97 BOOST_REQUIRE_EQUAL(dg.
threads.
x,1ul);
98 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
99 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
101 BOOST_REQUIRE_EQUAL(dg.
grids.
x,17ul);
102 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
103 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
115 calculate_optimal_device_grid<1>(dg,sz,5,3);
117 BOOST_REQUIRE_EQUAL(dg.
threads.
x,1ul);
118 BOOST_REQUIRE_EQUAL(dg.
threads.
y,1ul);
119 BOOST_REQUIRE_EQUAL(dg.
threads.
z,1ul);
121 BOOST_REQUIRE_EQUAL(dg.
grids.
x,17ul);
122 BOOST_REQUIRE_EQUAL(dg.
grids.
y,1ul);
123 BOOST_REQUIRE_EQUAL(dg.
grids.
z,1ul);
128 size_t sz2[] = {64,64};
131 calculate_optimal_device_grid<2>(dg2,sz2,1536,512);
133 BOOST_REQUIRE_EQUAL(dg2.
threads.
x,64ul);
134 BOOST_REQUIRE_EQUAL(dg2.
threads.
y,16ul);
135 BOOST_REQUIRE_EQUAL(dg2.
threads.
z,1ul);
137 BOOST_REQUIRE_EQUAL(dg2.
grids.
x,1ul);
138 BOOST_REQUIRE_EQUAL(dg2.
grids.
y,4ul);
139 BOOST_REQUIRE_EQUAL(dg2.
grids.
z,1ul);
146 calculate_optimal_device_grid<2>(dg2,sz2,1536,512);
148 BOOST_REQUIRE_EQUAL(dg2.
threads.
x,18ul);
149 BOOST_REQUIRE_EQUAL(dg2.
threads.
y,18ul);
150 BOOST_REQUIRE_EQUAL(dg2.
threads.
z,1ul);
152 BOOST_REQUIRE_EQUAL(dg2.
grids.
x,7ul);
153 BOOST_REQUIRE_EQUAL(dg2.
grids.
y,7ul);
154 BOOST_REQUIRE_EQUAL(dg2.
grids.
z,1ul);
159 calculate_optimal_device_grid<2>(dg2,sz2,1536,512);
161 BOOST_REQUIRE_EQUAL(dg2.
threads.
x,162ul);
162 BOOST_REQUIRE_EQUAL(dg2.
threads.
y,6ul);
163 BOOST_REQUIRE_EQUAL(dg2.
threads.
z,1ul);
165 BOOST_REQUIRE_EQUAL(dg2.
grids.
x,1ul);
166 BOOST_REQUIRE_EQUAL(dg2.
grids.
y,21ul);
167 BOOST_REQUIRE_EQUAL(dg2.
grids.
z,1ul);
169 size_t sz3[3] = {126,126,126};
173 calculate_optimal_device_grid<3>(dg3,sz3,1536,512);
175 BOOST_REQUIRE_EQUAL(dg3.
threads.
x,18ul);
176 BOOST_REQUIRE_EQUAL(dg3.
threads.
y,18ul);
177 BOOST_REQUIRE_EQUAL(dg3.
threads.
z,2ul);
179 BOOST_REQUIRE_EQUAL(dg3.
grids.
x,7ul);
180 BOOST_REQUIRE_EQUAL(dg3.
grids.
y,7ul);
181 BOOST_REQUIRE_EQUAL(dg3.
grids.
z,63ul);
184BOOST_AUTO_TEST_SUITE_END()
dim3_ grids
number of grid for the kernel execution
dim3_ threads
number of treads in each block
unsigned int z
size in z dimension
unsigned int x
size in x dimension
unsigned int y
size in y dimension