8#define DISABLE_MPI_WRITTERS
10#define BOOST_TEST_DYN_LINK
11#include <boost/test/unit_test.hpp>
12#include "SparseGrid/SparseGrid.hpp"
13#include "NN/CellList/CellDecomposer.hpp"
17BOOST_AUTO_TEST_SUITE( sparse_grid_test )
19template <
typename gr
id_type,
typename cell_decomposer>
29 for (r = 0.3 ; r < 0.35 ;r += 0.001)
31 for (omega = 0.0; omega < M_PI ; omega += 0.006)
33 for (phi = 0.0; phi < 2.0*M_PI ; phi += 0.006)
37 p.
get(0) = r*sin(omega)*sin(phi) + 0.5;
38 p.
get(1) = r*sin(omega)*cos(phi) + 0.5;
39 p.
get(2) = r*cos(omega) + 0.5;
45 grid.template insert<0>(kd) = sin(omega)*sin(omega)*sin(2*phi);
46 grid.template insert<1>(kd) = 0;
51 auto it =
grid.getIterator();
63template <
typename gr
id_type,
typename cell_decomposer>
64size_t fill_sphere_quad(
grid_type &
grid, cell_decomposer & cdsm)
73 for (r = 0.3 ; r < 0.4 ;r += 0.001)
75 for (omega = 0.0; omega < M_PI ; omega += 0.006)
77 for (phi = 0.0; phi < 2.0*M_PI ; phi += 0.006)
81 p.
get(0) = r*sin(omega)*sin(phi) + 0.5;
82 p.
get(1) = r*sin(omega)*cos(phi) + 0.5;
83 p.
get(2) = r*cos(omega) + 0.5;
90 grid.template insert<1>(kd) = 0;
95 auto it =
grid.getIterator();
107template <
typename gr
id_type,
typename cell_decomposer>
108size_t fill_sphere_quad_v(
grid_type &
grid, cell_decomposer & cdsm)
110 size_t tot_count = 0;
117 for (r = 0.3 ; r < 0.4 ;r += 0.001)
119 for (omega = 0.0; omega < M_PI ; omega += 0.006)
121 for (phi = 0.0; phi < 2.0*M_PI ; phi += 0.006)
125 p.
get(0) = r*sin(omega)*sin(phi) + 0.5;
126 p.
get(1) = r*sin(omega)*cos(phi) + 0.5;
127 p.
get(2) = r*cos(omega) + 0.5;
134 grid.template insert<1>(kd) = 0;
142 auto it =
grid.getIterator();
154BOOST_AUTO_TEST_CASE( sparse_grid_use_test)
156 size_t sz[3] = {10000,10000,10000};
160 grid.getBackgroundValue().template get<0>() = 0.0;
168 grid.template insert<0>(key1) = 1.0;
169 grid.template insert<0>(key2) = 2.0;
170 grid.template insert<0>(key3) = 3.0;
172 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key1),1.0);
173 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key2),2.0);
174 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key3),3.0);
176 auto it =
grid.getIterator();
187 BOOST_REQUIRE_EQUAL(count,(
size_t)3);
190BOOST_AUTO_TEST_CASE( sparse_grid_fill_all_test)
192 size_t sz[3] = {171,171,171};
196 grid.getBackgroundValue().template get<0>() = 0.0;
204 auto key = kit.get();
206 grid.template insert<0>(key) = g_sm.LinId(key);
211 auto it =
grid.getIterator();
222 auto key_pos = it.getKeyF();
224 match &= (
grid.template get<0>(key_pos) == g_sm.LinId(key));
231 BOOST_REQUIRE_EQUAL(count,(
size_t)171*171*171);
232 BOOST_REQUIRE_EQUAL(
grid.size(),(
size_t)171*171*171);
233 BOOST_REQUIRE_EQUAL(match,
true);
239 while (kit2.isNext())
241 auto key = kit2.get();
248 size_t tot =
grid.size();
249 BOOST_REQUIRE_EQUAL(tot,0ul);
253BOOST_AUTO_TEST_CASE( sparse_grid_fill_sparse_test)
255 size_t sz[3] = {500,500,500};
259 grid.getBackgroundValue().template get<0>() = 0.0;
261 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
265 cdsm.setDimensions(domain, sz, 0);
267 fill_sphere(
grid,cdsm);
273 for (r = 0.3 ; r < 0.35 ;r += 0.001)
275 for (omega = 0.0; omega < M_PI ; omega += 0.006)
277 for (phi = 0.0; phi < 2.0*M_PI ; phi += 0.006)
282 p.
get(0) = r*sin(omega)*sin(phi) + 0.5;
283 p.
get(1) = r*sin(omega)*cos(phi) + 0.5;
284 p.
get(2) = r*cos(omega) + 0.5;
291 if (
grid.template get<0>(kd) == sin(omega)*sin(omega)*sin(2*phi))
292 {
grid.template insert<1>(kd) = 1;}
298 auto it =
grid.getIterator();
306 if (
grid.template get<1>(key) == 0)
312 BOOST_REQUIRE_EQUAL(match,
true);
316 for (r = 0.3 ; r < 0.35 ;r += 0.001)
318 for (omega = 0.0; omega < M_PI ; omega += 0.006)
320 for (phi = 0.0; phi < 2.0*M_PI ; phi += 0.006)
325 p.
get(0) = r*sin(omega)*sin(phi) + 0.5;
326 p.
get(1) = r*sin(omega)*cos(phi) + 0.5;
327 p.
get(2) = r*cos(omega) + 0.5;
343 BOOST_REQUIRE_EQUAL(tot,0ul);
347BOOST_AUTO_TEST_CASE( sparse_grid_resize_test)
349 size_t sz[3] = {500,500,500};
354 grid.getBackgroundValue().template get<0>() = 0.0;
356 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
360 cdsm.setDimensions(domain, sz, 0);
368 for (r = 0.3 ; r < 0.35 ;r += 0.001)
370 for (omega = 0.0; omega < M_PI ; omega += 0.006)
372 for (phi = 0.0; phi < 2.0*M_PI ; phi += 0.006)
376 p.
get(0) = r*sin(omega)*sin(phi) + 0.5;
377 p.
get(1) = r*sin(omega)*cos(phi) + 0.5;
378 p.
get(2) = r*cos(omega) + 0.5;
384 grid.template insert<0>(kd) = sin(omega)*sin(omega)*sin(2*phi);
385 grid.template insert<1>(kd) = 0;
386 grid2.template insert<0>(kd) = sin(omega)*sin(omega)*sin(2*phi);
387 grid2.template insert<1>(kd) = 0;
392 size_t sz_b[3] = {1024,1024,1024};
397 auto it = grid2.getIterator();
405 if (
grid.template get<0>(key) != grid2.template get<0>(key))
414 BOOST_REQUIRE_EQUAL(match,
true);
418 size_t sz_s[3] = {250,250,250};
423 auto it2 =
grid.getIterator();
429 auto key = it2.get();
435 cin &= (size_t)key.get(0) < sz_s[0];
436 cin &= (size_t)key.get(1) < sz_s[1];
437 cin &= (size_t)key.get(2) < sz_s[2];
442 if (
grid.template get<0>(key) != grid2.template get<0>(key))
452 BOOST_REQUIRE_EQUAL(match,
true);
457BOOST_AUTO_TEST_CASE( sparse_grid_fill_all_with_resize_test)
459 size_t sz[3] = {10,10,171};
463 grid.getBackgroundValue().template get<0>() = 0.0;
471 auto key = kit.get();
473 grid.template insert<0>(key) = g_sm.LinId(key);
478 size_t sz_b[3] = {20,20,200};
483 auto it =
grid.getIterator();
494 auto key_pos = it.getKeyF();
496 match &= (
grid.template get<0>(key_pos) == g_sm.LinId(key));
503 BOOST_REQUIRE_EQUAL(count,(
size_t)10*10*171);
504 BOOST_REQUIRE_EQUAL(
grid.size(),(
size_t)10*10*171);
505 BOOST_REQUIRE_EQUAL(match,
true);
513 while (kit2.isNext())
515 auto key = kit2.get();
517 grid.template insert<0>(key) = g_sm2.LinId(key);
522 auto it2 =
grid.getIterator();
530 auto key = it2.get();
533 auto key_pos = it2.getKeyF();
535 match &= (
grid.template get<0>(key_pos) == g_sm2.LinId(key));
542 BOOST_REQUIRE_EQUAL(count,(
size_t)20*20*200);
543 BOOST_REQUIRE_EQUAL(
grid.size(),(
size_t)20*20*200);
544 BOOST_REQUIRE_EQUAL(match,
true);
547BOOST_AUTO_TEST_CASE( sparse_grid_insert_o_test)
549 size_t sz[3] = {10,10,171};
553 grid.getBackgroundValue().template get<0>() = 0.0;
558 auto & flt =
grid.insert_o(key,
ele).template get<0>();
561 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key),117.0);
565BOOST_AUTO_TEST_CASE( sparse_grid_sub_grid_it)
567 size_t sz[3] = {171,171,171};
571 grid.getBackgroundValue().template get<0>() = 0.0;
579 auto key = kit.get();
581 grid.template insert<0>(key) = g_sm.LinId(key);
591 auto it_sub =
grid.getIterator(start,stop);
593 while (it_sub.isNext())
595 auto gkey = it_sub.get();
597 if (gkey.get(0) < start.get(0) ||
598 gkey.get(1) < start.get(1) ||
599 gkey.get(2) < start.get(2) ||
600 gkey.get(0) > stop.get(0) ||
601 gkey.get(1) > stop.get(1) ||
602 gkey.get(2) > stop.get(2))
612 size_t tot = (stop.get(2) - start.get(2) + 1)*(stop.get(1) - start.get(1) + 1)*(stop.get(0) - start.get(0) + 1);
613 BOOST_REQUIRE_EQUAL(error,
false);
614 BOOST_REQUIRE_EQUAL(count,tot);
618BOOST_AUTO_TEST_CASE( sparse_grid_sub_grid_it_quarter_sphere)
620 size_t sz[3] = {501,501,501};
621 size_t sz_cell[3] = {500,500,500};
625 grid.getBackgroundValue().template get<0>() = 0.0;
627 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
631 cdsm.setDimensions(domain, sz_cell, 0);
633 fill_sphere(
grid,cdsm);
640 auto it_sub =
grid.getIterator(start,stop);
642 while (it_sub.isNext())
644 auto gkey = it_sub.get();
646 if (gkey.get(0) < start.get(0) ||
647 gkey.get(1) < start.get(1) ||
648 gkey.get(2) < start.get(2) ||
649 gkey.get(0) > stop.get(0) ||
650 gkey.get(1) > stop.get(1) ||
651 gkey.get(2) > stop.get(2))
658 double radius = (gkey.get(0) - 250)*(gkey.get(0) - 250) +
659 (gkey.get(1) - 250)*(gkey.get(1) - 250) +
660 (gkey.get(2) - 250)*(gkey.get(2) - 250);
662 radius = sqrt(radius);
664 if (radius < 150 || radius >= 175)
675 BOOST_REQUIRE_EQUAL(error,
false);
680 auto it_sub2 =
grid.getIterator(start,stop);
682 while (it_sub2.isNext())
684 auto gkey = it_sub2.get();
686 if (gkey.get(0) < start.get(0) ||
687 gkey.get(1) < start.get(1) ||
688 gkey.get(2) < start.get(2) ||
689 gkey.get(0) > stop.get(0) ||
690 gkey.get(1) > stop.get(1) ||
691 gkey.get(2) > stop.get(2))
698 double radius = (gkey.get(0) - 250)*(gkey.get(0) - 250) +
699 (gkey.get(1) - 250)*(gkey.get(1) - 250) +
700 (gkey.get(2) - 250)*(gkey.get(2) - 250);
702 radius = sqrt(radius);
704 if (radius < 150 || radius >= 175)
714 BOOST_REQUIRE_EQUAL(error,
false);
717BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil)
719 size_t sz[3] = {501,501,501};
720 size_t sz_cell[3] = {500,500,500};
724 grid.getBackgroundValue().template get<0>() = 0.0;
726 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
730 cdsm.setDimensions(domain, sz_cell, 0);
732 fill_sphere_quad(
grid,cdsm);
737 for (
int i = 0 ; i < 1 ; i++)
741 auto it =
grid.getBlockIterator<1>(start,stop);
743 unsigned char mask[
decltype(it)::sizeBlockBord];
744 __attribute__ ((aligned (32))) double block_bord_src[decltype(it)::sizeBlockBord];
745 __attribute__ ((aligned (32)))
double block_bord_dst[decltype(it)::sizeBlock];
747 const Vc::double_v six(6.0);
751 it.loadBlockBorder<0,
NNStar_c<3>,
false>(block_bord_src,mask);
753 for (
int i = 0 ; i < 1 ; i++)
756 for (
int k = it.start_b(2) ; k < it.stop_b(2) ; k++)
758 for (
int j = it.start_b(1) ; j < it.stop_b(1) ; j++)
760 int c = it.LinB(it.start_b(0),j,k);
765 int yp = it.LinB(it.start_b(0),j+1,k);
766 int ym = it.LinB(it.start_b(0),j-1,k);
768 int zp = it.LinB(it.start_b(0),j,k+1);
769 int zm = it.LinB(it.start_b(0),j,k-1);
771 for (
int i = it.start_b(0) ; i < it.stop_b(0) ; i++)
774 if (mask[c] ==
false) {
continue;}
776 bool surround = mask[xp] & mask[xm] & mask[ym] & mask[yp] & mask[zp] & mask[zm];
778 double Lap = block_bord_src[xp] + block_bord_src[xm] +
779 block_bord_src[yp] + block_bord_src[ym] +
780 block_bord_src[zp] + block_bord_src[zm] - 6.0*block_bord_src[c];
784 block_bord_dst[it.LinB_off(i,j,k)] =
Lap;
799 it.storeBlock<1>(block_bord_dst);
807 auto it2 =
grid.getIterator();
812 check &=
grid.template get<1>(p) == 6;
817 BOOST_REQUIRE_EQUAL(check,
true);
823BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized)
825 size_t sz[3] = {501,501,501};
826 size_t sz_cell[3] = {500,500,500};
830 grid.getBackgroundValue().template get<0>() = 0.0;
832 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
836 cdsm.setDimensions(domain, sz_cell, 0);
838 fill_sphere_quad(
grid,cdsm);
845 for (
int i = 0 ; i < 1 ; i++)
848 auto it =
grid.getBlockIterator<1>(start,stop);
850 unsigned char mask[
decltype(it)::sizeBlockBord];
851 unsigned char mask_sum[
decltype(it)::sizeBlockBord];
852 __attribute__ ((aligned (32))) double block_bord_src[decltype(it)::sizeBlockBord];
853 __attribute__ ((aligned (32)))
double block_bord_dst[decltype(it)::sizeBlock];
855 typedef typename boost::mpl::at<decltype(it)::stop_border_vmpl,boost::mpl::int_<0>>::type sz0;
856 typedef typename boost::mpl::at<decltype(it)::stop_border_vmpl,boost::mpl::int_<1>>::type sz1;
857 typedef typename boost::mpl::at<decltype(it)::stop_border_vmpl,boost::mpl::int_<2>>::type sz2;
859 const Vc::double_v six(6.0);
863 it.loadBlockBorder<0,
NNStar_c<3>,
false>(block_bord_src,mask);
866 for (
int k = it.start_b(2) ; k < it.stop_b(2) ; k++)
868 for (
int j = it.start_b(1) ; j < it.stop_b(1) ; j++)
870 int c = it.LinB(it.start_b(0),j,k);
872 int yp = it.LinB(it.start_b(0),j+1,k);
873 int ym = it.LinB(it.start_b(0),j-1,k);
875 int zp = it.LinB(it.start_b(0),j,k+1);
876 int zm = it.LinB(it.start_b(0),j,k-1);
878 for (
int i = it.start_b(0) ; i < it.stop_b(0) ; i +=
sizeof(size_t))
880 size_t cmd = *(
size_t *)&mask[c];
882 if (cmd == 0) {
continue;}
884 size_t xpd = *(
size_t *)&mask[c+1];
885 size_t xmd = *(
size_t *)&mask[c-1];
886 size_t ypd = *(
size_t *)&mask[yp];
887 size_t ymd = *(
size_t *)&mask[ym];
888 size_t zpd = *(
size_t *)&mask[zp];
889 size_t zmd = *(
size_t *)&mask[zm];
891 size_t sum = xpd + xmd +
895 *(
size_t *)&mask_sum[c] =
sum;
898 yp +=
sizeof(size_t);
899 ym +=
sizeof(size_t);
900 zp +=
sizeof(size_t);
901 zm +=
sizeof(size_t);
906 for (
int k = it.start_b(2) ; k < it.stop_b(2) ; k++)
908 for (
int j = it.start_b(1) ; j < it.stop_b(1) ; j++)
910 int c = it.LinB(it.start_b(0),j,k);
912 int yp = it.LinB(it.start_b(0),j+1,k);
913 int ym = it.LinB(it.start_b(0),j-1,k);
915 int zp = it.LinB(it.start_b(0),j,k+1);
916 int zm = it.LinB(it.start_b(0),j,k-1);
918 int cd = it.LinB_off(it.start_b(0),j,k);
920 for (
int i = it.start_b(0) ; i < it.stop_b(0) ; i += Vc::double_v::Size)
922 Vc::Mask<double> cmp;
924 if (Vc::double_v::Size == 2)
926 cmp[0] = mask[c] ==
true;
927 cmp[1] = mask[c+1] ==
true;
929 else if (Vc::double_v::Size == 4)
931 cmp[0] = mask[c] ==
true;
932 cmp[1] = mask[c+1] ==
true;
933 cmp[2] = mask[c+2] ==
true;
934 cmp[3] = mask[c+3] ==
true;
938 std::cout <<
"UNSUPPORTED" << std::endl;
944 if (Vc::none_of(cmp) ==
true) {
continue;}
946 Vc::Mask<double> surround;
948 Vc::double_v xpd(&block_bord_src[c+1],Vc::Unaligned);
949 Vc::double_v xmd(&block_bord_src[c-1],Vc::Unaligned);
950 Vc::double_v ypd(&block_bord_src[c+sz0::value],Vc::Unaligned);
951 Vc::double_v ymd(&block_bord_src[c-sz0::value],Vc::Unaligned);
952 Vc::double_v zpd(&block_bord_src[zp],Vc::Unaligned);
953 Vc::double_v zmd(&block_bord_src[zm],Vc::Unaligned);
954 Vc::double_v cmd(&block_bord_src[c],Vc::Unaligned);
956 Vc::double_v
Lap = xpd + xmd +
960 if (Vc::double_v::Size == 2)
962 surround[0] = (mask_sum[c] == 7);
963 surround[1] = (mask_sum[c+1] == 7);
965 else if (Vc::double_v::Size == 4)
967 surround[0] = (mask_sum[c] == 7);
968 surround[1] = (mask_sum[c+1] == 7);
969 surround[2] = (mask_sum[c+2] == 7);
970 surround[3] = (mask_sum[c+3] == 7);
973 Lap = Vc::iif(surround,
Lap,six);
975 Lap.store(&block_bord_dst[cd],cmp,Vc::Aligned);
977 c+=Vc::double_v::Size;
978 zp+=Vc::double_v::Size;
979 zm+=Vc::double_v::Size;
980 cd+=Vc::double_v::Size;
985 it.storeBlock<1>(block_bord_dst);
993 auto it2 =
grid.getIterator();
998 check &=
grid.template get<1>(p) == 6;
1003 BOOST_REQUIRE_EQUAL(check,
true);
1009BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized_block_skip)
1011 size_t sz[3] = {501,501,501};
1012 size_t sz_cell[3] = {500,500,500};
1016 grid.getBackgroundValue().template get<0>() = 0.0;
1018 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1022 cdsm.setDimensions(domain, sz_cell, 0);
1024 fill_sphere_quad(
grid,cdsm);
1031 for (
int i = 0 ; i < 1 ; i++)
1034 auto it =
grid.getBlockIterator<1>(start,stop);
1036 auto & datas =
grid.private_get_data();
1037 auto & headers =
grid.private_get_header_mask();
1039 typedef typename boost::mpl::at<
decltype(it)::stop_border_vmpl,boost::mpl::int_<0>>::type sz0;
1040 typedef typename boost::mpl::at<
decltype(it)::stop_border_vmpl,boost::mpl::int_<1>>::type sz1;
1041 typedef typename boost::mpl::at<
decltype(it)::stop_border_vmpl,boost::mpl::int_<2>>::type sz2;
1045 const Vc::double_v one(1.0);
1050 long int offset_jump[6];
1051 size_t cid = it.getChunkId();
1053 auto chunk = datas.get(cid);
1054 auto & mask = headers.get(cid);
1058 long int r =
grid.getChunk(p,exist);
1059 offset_jump[0] = (r-cid)*
decltype(it)::sizeBlock;
1062 r =
grid.getChunk(p,exist);
1063 offset_jump[1] = (r-cid)*
decltype(it)::sizeBlock;
1066 r =
grid.getChunk(p,exist);
1067 offset_jump[2] = (r-cid)*
decltype(it)::sizeBlock;
1070 r =
grid.getChunk(p,exist);
1071 offset_jump[3] = (r-cid)*
decltype(it)::sizeBlock;
1074 r =
grid.getChunk(p,exist);
1075 offset_jump[4] = (r-cid)*
decltype(it)::sizeBlock;
1078 r =
grid.getChunk(p,exist);
1079 offset_jump[5] = (r-cid)*
decltype(it)::sizeBlock;
1085 typedef boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type sz;
1086 typedef boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type sy;
1087 typedef boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type sx;
1089 for (
int v = 0 ; v < sz::value ; v++)
1091 for (
int j = 0 ; j < sy::value ; j++)
1093 for (
int k = 0 ; k < sx::value ; k += Vc::double_v::Size)
1096 if (*(
int *)&mask.mask[s2] == 0) {s2 += Vc::double_v::Size;
continue;}
1098 Vc::Mask<double> surround;
1110 Vc::double_v cmd(&chunk.template get<0>()[s2]);
1113 long int sumxm = s2-1;
1114 sumxm += (k==0)?offset_jump[0] + sx::value:0;
1117 long int sumxp = s2+Vc::double_v::Size;
1118 sumxp += (k+Vc::double_v::Size == sx::value)?offset_jump[1] - sx::value:0;
1120 long int sumym = (j == 0)?offset_jump[2] + (sy::value-1)*sx::value:-sx::value;
1122 long int sumyp = (j == sy::value-1)?offset_jump[3] - (sy::value - 1)*sx::value:sx::value;
1124 long int sumzm = (v == 0)?offset_jump[4] + (sz::value-1)*sx::value*sy::value:-sx::value*sy::value;
1126 long int sumzp = (v == sz::value-1)?offset_jump[5] - (sz::value - 1)*sx::value*sy::value:sx::value*sy::value;
1129 if (Vc::double_v::Size == 2)
1131 mxm.uc[0] = mask.mask[sumxm];
1132 mxm.uc[1] = mask.mask[s2];
1134 mxp.uc[0] = mask.mask[s2+1];
1135 mxp.uc[1] = mask.mask[sumxp];
1137 else if (Vc::double_v::Size == 4)
1139 mxm.uc[0] = mask.mask[sumxm];
1140 mxm.uc[1] = mask.mask[s2];
1141 mxm.uc[2] = mask.mask[s2+1];
1142 mxm.uc[3] = mask.mask[s2+2];
1144 mxp.uc[0] = mask.mask[s2+1];
1145 mxp.uc[1] = mask.mask[s2+2];
1146 mxp.uc[2] = mask.mask[s2+3];
1147 mxp.uc[3] = mask.mask[sumxp];
1151 std::cout <<
"UNSUPPORTED" << std::endl;
1155 mym.i = *(
int *)&mask.mask[sumym];
1156 myp.i = *(
int *)&mask.mask[sumyp];
1158 mzm.i = *(
int *)&mask.mask[sumzm];
1159 mzp.i = *(
int *)&mask.mask[sumzp];
1161 if (Vc::double_v::Size == 2)
1163 xm[0] = chunk.template get<0>()[sumxm];
1167 xp[1] = chunk.template get<0>()[sumxp];
1169 else if (Vc::double_v::Size == 4)
1171 xm[0] = chunk.template get<0>()[sumxm];
1179 xp[3] = chunk.template get<0>()[sumxp];
1184 Vc::double_v ym(&chunk.template get<0>()[sumym],Vc::Aligned);
1185 Vc::double_v yp(&chunk.template get<0>()[sumyp],Vc::Aligned);
1186 Vc::double_v zm(&chunk.template get<0>()[sumzm],Vc::Aligned);
1187 Vc::double_v zp(&chunk.template get<0>()[sumzp],Vc::Aligned);
1192 tot_m.i = mxm.i + mxp.i + mym.i + myp.i + mzm.i + mzp.i;
1194 if (Vc::double_v::Size == 2)
1196 surround[0] = (tot_m.uc[0] == 6);
1197 surround[1] = (tot_m.uc[1] == 6);
1199 else if (Vc::double_v::Size == 4)
1201 surround[0] = (tot_m.uc[0] == 6);
1202 surround[1] = (tot_m.uc[1] == 6);
1203 surround[2] = (tot_m.uc[2] == 6);
1204 surround[3] = (tot_m.uc[3] == 6);
1207 Vc::double_v
Lap = xp + xm +
1211 Lap = Vc::iif(surround,
Lap,one);
1213 Lap.store(&chunk.template get<1>()[s2],Vc::Aligned);
1215 s2 += Vc::double_v::Size;
1229 auto it2 =
grid.getIterator();
1230 while (it2.isNext())
1234 check &= (
grid.template get<1>(p) == 6 ||
grid.template get<1>(p) == 1);
1236 if (
grid.template get<1>(p) == 1)
1241 if (
grid.template get<1>(p) == 6)
1249 BOOST_REQUIRE_EQUAL(check,
true);
1250 BOOST_REQUIRE_EQUAL(tot_six,15857813);
1251 BOOST_REQUIRE_EQUAL(tot_one,2977262);
1257BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized_simplified)
1259 size_t sz[3] = {501,501,501};
1260 size_t sz_cell[3] = {500,500,500};
1264 grid.getBackgroundValue().template get<0>() = 0.0;
1266 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1270 cdsm.setDimensions(domain, sz_cell, 0);
1272 fill_sphere_quad(
grid,cdsm);
1277 for (
int i = 0 ; i < 1 ; i++)
1280 int stencil[6][3] = {{1,0,0},{-1,0,0},{0,-1,0},{0,1,0},{0,0,-1},{0,0,1}};
1282 grid.conv<0,1,1>(stencil,start,stop,[](Vc::double_v (& xs)[7],
unsigned char * mask_sum){
1283 Vc::double_v
Lap = xs[1] + xs[2] +
1285 xs[5] + xs[6] - 6.0*xs[0];
1287 auto surround = load_mask<Vc::double_v>(mask_sum);
1289 auto sur_mask = (surround == 6.0);
1291 Lap = Vc::iif(sur_mask,
Lap,Vc::double_v(1.0));
1301 auto it2 =
grid.getIterator(start,stop);
1302 while (it2.isNext())
1306 check &= (
grid.template get<1>(p) == 6 ||
grid.template get<1>(p) == 1);
1309 auto xp = p.move(0,1);
1310 auto xm = p.move(0,-1);
1312 auto yp = p.move(1,1);
1313 auto ym = p.move(1,-1);
1315 auto zp = p.move(2,1);
1316 auto zm = p.move(2,-1);
1319 if (
grid.existPoint(xp) &&
grid.existPoint(xm) &&
1320 grid.existPoint(yp) &&
grid.existPoint(ym) &&
1321 grid.existPoint(zp) &&
grid.existPoint(zm))
1330 if (is_six ==
true &&
grid.template get<1>(p) != 6.0)
1336 if (
grid.template get<1>(p) == 1)
1341 if (
grid.template get<1>(p) == 6)
1349 BOOST_REQUIRE_EQUAL(check,
true);
1350 BOOST_REQUIRE_EQUAL(tot_six,2020091);
1351 BOOST_REQUIRE_EQUAL(tot_one,376791);
1357BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized_cross_simplified)
1359 size_t sz[3] = {501,501,501};
1360 size_t sz_cell[3] = {500,500,500};
1364 grid.getBackgroundValue().template get<0>() = 0.0;
1366 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1370 cdsm.setDimensions(domain, sz_cell, 0);
1372 fill_sphere_quad(
grid,cdsm);
1379 for (
int i = 0 ; i < 1 ; i++)
1382 unsigned char * mask_sum){
1384 Vc::double_v
Lap = s.xm + s.xp +
1386 s.zm + s.zp - 6.0*cmd;
1388 Vc::Mask<double> surround;
1390 for (
int i = 0 ; i < Vc::double_v::Size ; i++)
1391 {surround[i] = (mask_sum[i] == 6);}
1393 Lap = Vc::iif(surround,
Lap,Vc::double_v(1.0));
1403 auto it2 =
grid.getIterator(start,stop);
1404 while (it2.isNext())
1408 check &= (
grid.template get<1>(p) == 6 ||
grid.template get<1>(p) == 1);
1411 auto xp = p.move(0,1);
1412 auto xm = p.move(0,-1);
1414 auto yp = p.move(1,1);
1415 auto ym = p.move(1,-1);
1417 auto zp = p.move(2,1);
1418 auto zm = p.move(2,-1);
1421 if (
grid.existPoint(xp) &&
grid.existPoint(xm) &&
1422 grid.existPoint(yp) &&
grid.existPoint(ym) &&
1423 grid.existPoint(zp) &&
grid.existPoint(zm))
1432 if (is_six ==
true &&
grid.template get<1>(p) != 6.0)
1438 if (
grid.template get<1>(p) == 1)
1443 if (
grid.template get<1>(p) == 6)
1451 BOOST_REQUIRE_EQUAL(check,
true);
1452 BOOST_REQUIRE_EQUAL(tot_six,15857813);
1453 BOOST_REQUIRE_EQUAL(tot_one,2977262);
1459BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized_cross_simplified_float)
1461 size_t sz[3] = {501,501,501};
1462 size_t sz_cell[3] = {500,500,500};
1466 grid.getBackgroundValue().template get<0>() = 0.0;
1468 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1472 cdsm.setDimensions(domain, sz_cell, 0);
1474 fill_sphere_quad(
grid,cdsm);
1481 for (
int i = 0 ; i < 1 ; i++)
1484 unsigned char * mask_sum){
1486 Vc::float_v
Lap = s.xm + s.xp +
1488 s.zm + s.zp - 6.0f*cmd;
1490 Vc::Mask<float> surround;
1492 for (
int i = 0 ; i < Vc::float_v::Size ; i++)
1493 {surround[i] = (mask_sum[i] == 6);}
1495 Lap = Vc::iif(surround,
Lap,Vc::float_v(1.0f));
1505 auto it2 =
grid.getIterator(start,stop);
1506 while (it2.isNext())
1510 check &= (
grid.template get<1>(p) == 6 ||
grid.template get<1>(p) == 1);
1513 auto xp = p.move(0,1);
1514 auto xm = p.move(0,-1);
1516 auto yp = p.move(1,1);
1517 auto ym = p.move(1,-1);
1519 auto zp = p.move(2,1);
1520 auto zm = p.move(2,-1);
1523 if (
grid.existPoint(xp) &&
grid.existPoint(xm) &&
1524 grid.existPoint(yp) &&
grid.existPoint(ym) &&
1525 grid.existPoint(zp) &&
grid.existPoint(zm))
1534 if (is_six ==
true &&
grid.template get<1>(p) != 6.0)
1540 if (
grid.template get<1>(p) == 1)
1545 if (
grid.template get<1>(p) == 6)
1553 BOOST_REQUIRE_EQUAL(check,
true);
1554 BOOST_REQUIRE_EQUAL(tot_six,15857813);
1555 BOOST_REQUIRE_EQUAL(tot_one,2977262);
1565BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized_cross_simplified_ids)
1567 size_t sz[3] = {501,501,501};
1568 size_t sz_cell[3] = {500,500,500};
1572 grid.getBackgroundValue().template get<0>() = 0.0;
1574 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1578 cdsm.setDimensions(domain, sz_cell, 0);
1580 fill_sphere_quad(
grid,cdsm);
1587 for (
int i = 0 ; i < 1 ; i++)
1589 grid.conv_cross_ids<1,
double>(start,stop,[](
auto &
grid,
auto & ids,
1590 unsigned char * mask_sum){
1600 load_crs<x,-1,0>(xm,
grid,ids);
1601 load_crs<x,1,0>(xp,
grid,ids);
1602 load_crs<y,-1,0>(ym,
grid,ids);
1603 load_crs<y,1,0>(yp,
grid,ids);
1604 load_crs<z,-1,0>(zm,
grid,ids);
1605 load_crs<z,1,0>(zp,
grid,ids);
1606 load_crs<x,0,0>(cmd,
grid,ids);
1608 Vc::double_v
Lap = xm + xp +
1612 Vc::Mask<double> surround;
1614 for (
int i = 0 ; i < Vc::double_v::Size ; i++)
1615 {surround[i] = (mask_sum[i] == 6);}
1617 Lap = Vc::iif(surround,
Lap,Vc::double_v(1.0));
1627 auto it2 =
grid.getIterator(start,stop);
1628 while (it2.isNext())
1632 check &= (
grid.template get<1>(p) == 6 ||
grid.template get<1>(p) == 1);
1635 auto xp = p.move(0,1);
1636 auto xm = p.move(0,-1);
1638 auto yp = p.move(1,1);
1639 auto ym = p.move(1,-1);
1641 auto zp = p.move(2,1);
1642 auto zm = p.move(2,-1);
1645 if (
grid.existPoint(xp) &&
grid.existPoint(xm) &&
1646 grid.existPoint(yp) &&
grid.existPoint(ym) &&
1647 grid.existPoint(zp) &&
grid.existPoint(zm))
1656 if (is_six ==
true &&
grid.template get<1>(p) != 6.0)
1662 if (
grid.template get<1>(p) == 1)
1667 if (
grid.template get<1>(p) == 6)
1675 BOOST_REQUIRE_EQUAL(check,
true);
1676 BOOST_REQUIRE_EQUAL(tot_six,15857813);
1677 BOOST_REQUIRE_EQUAL(tot_one,2977262);
1683BOOST_AUTO_TEST_CASE( sparse_grid_fast_stencil_vectorized_cross_simplified_ids_vector)
1685 size_t sz[3] = {501,501,501};
1686 size_t sz_cell[3] = {500,500,500};
1690 grid.getBackgroundValue().template get<0>() = 0.0;
1692 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1696 cdsm.setDimensions(domain, sz_cell, 0);
1698 fill_sphere_quad_v(
grid,cdsm);
1705 for (
int i = 0 ; i < 1 ; i++)
1707 grid.conv_cross_ids<1,
double>(start,stop,[](
auto &
grid,
auto & ids,
1708 unsigned char * mask_sum){
1718 load_crs<x,-1,0>(xm,
grid,ids);
1719 load_crs<x,1,0>(xp,
grid,ids);
1720 load_crs<y,-1,0>(ym,
grid,ids);
1721 load_crs<y,1,0>(yp,
grid,ids);
1722 load_crs<z,-1,0>(zm,
grid,ids);
1723 load_crs<z,1,0>(zp,
grid,ids);
1724 load_crs<x,0,0>(cmd,
grid,ids);
1726 Vc::double_v
Lap = xm + xp +
1732 load_crs_v<x,-1,x,3>(xm,
grid,ids);
1733 load_crs_v<x,1,x,3>(xp,
grid,ids);
1734 load_crs_v<y,-1,x,3>(ym,
grid,ids);
1735 load_crs_v<y,1,x,3>(yp,
grid,ids);
1736 load_crs_v<z,-1,x,3>(zm,
grid,ids);
1737 load_crs_v<z,1,x,3>(zp,
grid,ids);
1738 load_crs_v<x,0,x,3>(cmd,
grid,ids);
1740 Vc::double_v Lap_x = xm + xp +
1744 load_crs_v<x,-1,y,3>(xm,
grid,ids);
1745 load_crs_v<x,1,y,3>(xp,
grid,ids);
1746 load_crs_v<y,-1,y,3>(ym,
grid,ids);
1747 load_crs_v<y,1,y,3>(yp,
grid,ids);
1748 load_crs_v<z,-1,y,3>(zm,
grid,ids);
1749 load_crs_v<z,1,y,3>(zp,
grid,ids);
1750 load_crs_v<x,0,y,3>(cmd,
grid,ids);
1752 Vc::double_v Lap_y = xm + xp +
1756 load_crs_v<x,-1,z,3>(xm,
grid,ids);
1757 load_crs_v<x,1,z,3>(xp,
grid,ids);
1758 load_crs_v<y,-1,z,3>(ym,
grid,ids);
1759 load_crs_v<y,1,z,3>(yp,
grid,ids);
1760 load_crs_v<z,-1,z,3>(zm,
grid,ids);
1761 load_crs_v<z,1,z,3>(zp,
grid,ids);
1762 load_crs_v<x,0,z,3>(cmd,
grid,ids);
1764 Vc::double_v Lap_z = xm + xp +
1768 Vc::Mask<double> surround;
1770 for (
int i = 0 ; i < Vc::double_v::Size ; i++)
1771 {surround[i] = (mask_sum[i] == 6);}
1773 Lap = Vc::iif(surround,
Lap,Vc::double_v(1.0));
1774 Lap_x = Vc::iif(surround,Lap_x,Vc::double_v(1.0));
1775 Lap_y = Vc::iif(surround,Lap_y,Vc::double_v(1.0));
1776 Lap_z = Vc::iif(surround,Lap_z,Vc::double_v(1.0));
1779 store_crs_v<4,x>(
grid,Lap_x,ids);
1780 store_crs_v<4,y>(
grid,Lap_y,ids);
1781 store_crs_v<4,z>(
grid,Lap_z,ids);
1789 auto it2 =
grid.getIterator(start,stop);
1790 while (it2.isNext())
1794 check &= (
grid.template get<1>(p) == 6 ||
grid.template get<1>(p) == 1);
1795 check &= (
grid.template get<4>(p)[0] == 6 ||
grid.template get<4>(p)[0] == 1);
1796 check &= (
grid.template get<4>(p)[1] == 6 ||
grid.template get<4>(p)[1] == 1);
1797 check &= (
grid.template get<4>(p)[2] == 6 ||
grid.template get<4>(p)[2] == 1);
1800 auto xp = p.move(0,1);
1801 auto xm = p.move(0,-1);
1803 auto yp = p.move(1,1);
1804 auto ym = p.move(1,-1);
1806 auto zp = p.move(2,1);
1807 auto zm = p.move(2,-1);
1810 if (
grid.existPoint(xp) &&
grid.existPoint(xm) &&
1811 grid.existPoint(yp) &&
grid.existPoint(ym) &&
1812 grid.existPoint(zp) &&
grid.existPoint(zm))
1821 if (is_six ==
true &&
grid.template get<1>(p) != 6.0)
1827 if (is_six ==
true &&
grid.template get<4>(p)[0] != 6.0)
1833 if (is_six ==
true &&
grid.template get<4>(p)[1] != 6.0)
1839 if (is_six ==
true &&
grid.template get<4>(p)[2] != 6.0)
1845 if (
grid.template get<1>(p) == 1)
1850 if (
grid.template get<1>(p) == 6)
1858 BOOST_REQUIRE_EQUAL(check,
true);
1859 BOOST_REQUIRE_EQUAL(tot_six,15857813);
1860 BOOST_REQUIRE_EQUAL(tot_one,2977262);
1866BOOST_AUTO_TEST_CASE( sparse_grid_slow_stencil)
1868 size_t sz[3] = {501,501,501};
1869 size_t sz_cell[3] = {500,500,500};
1873 grid.getBackgroundValue().template get<0>() = 0.0;
1875 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
1879 cdsm.setDimensions(domain, sz_cell, 0);
1881 fill_sphere_quad(
grid,cdsm);
1886 for (
int i = 0 ; i < 1 ; i++)
1889 auto it =
grid.getIterator();
1897 auto mx = p.move(0,-1);
1898 auto px = p.move(0,1);
1899 auto my = p.move(1,-1);
1900 auto py = p.move(1,1);
1901 auto mz = p.move(2,-1);
1902 auto pz = p.move(2,1);
1904 bool surround =
grid.existPoint(mx) &
grid.existPoint(px) &
grid.existPoint(py) &
grid.existPoint(my) &
grid.existPoint(mz) &
grid.existPoint(pz);
1906 double Lap =
grid.template get<0>(mz) +
grid.template get<0>(pz) +
1907 grid.template get<0>(my) +
grid.template get<0>(py) +
1908 grid.template get<0>(mx) +
grid.template get<0>(px) - 6.0*
grid.template get<0>(p);
1910 grid.template insert<1>(p) = (surround)?
Lap:6.0;
1918 auto it2 =
grid.getIterator();
1919 while (it2.isNext())
1923 check &=
grid.template get<1>(p) == 6;
1928 BOOST_REQUIRE_EQUAL(check,
true);
1933template<
typename sgr
id>
void Test_unpack_and_check_full(sgrid &
grid)
1941 for (
size_t i = 0 ; i < 3 ; i++)
1943 end.
set_d(i,
grid.getGrid().size(i) - 1);
1947 grid.template packRequest<0>(req2);
1948 auto sub_it =
grid.getIterator(zero,end);
1949 grid.template packRequest<0>(sub_it,req3);
1951 BOOST_REQUIRE_EQUAL(req2,req3);
1968 grid.template pack<0>(mem2,sts2);
1969 grid.template pack<0>(mem3,sub_it,sts3);
1971 BOOST_REQUIRE_EQUAL(mem2.
size(),mem3.
size());
1978 for (
size_t i = 0 ; i < mem2.
size(); i++)
1980 check &= (p2[i] == p3[i]);
1983 BOOST_REQUIRE_EQUAL(check,
true);
1990 empty.template unpack<0>(mem3,ps);
1992 BOOST_REQUIRE_EQUAL(empty.getGrid().size(0),
grid.getGrid().size(0));
1993 BOOST_REQUIRE_EQUAL(empty.getGrid().size(1),
grid.getGrid().size(1));
1994 BOOST_REQUIRE_EQUAL(empty.getGrid().size(2),
grid.getGrid().size(2));
1996 auto it = empty.getIterator();
2002 check &= (
grid.template get<0>(p) == empty.template get<0>(p));
2007 BOOST_REQUIRE_EQUAL(check,
true);
2011template<
typename sgr
id>
void Test_unpack_and_check_full_noprp(sgrid &
grid)
2019 for (
size_t i = 0 ; i < 3 ; i++)
2021 end.
set_d(i,
grid.getGrid().size(i) - 1);
2025 grid.template packRequest(req2);
2026 auto sub_it =
grid.getIterator(zero,end);
2027 grid.template packRequest<0,1>(sub_it,req3);
2029 BOOST_REQUIRE_EQUAL(req2,req3);
2049 grid.template pack(mem2,sts2);
2050 grid.template pack<0,1>(mem3,sub_it,sts3);
2052 BOOST_REQUIRE_EQUAL(mem2.
size(),mem3.
size());
2059 for (
size_t i = 0 ; i < mem2.
size(); i++)
2061 check &= (p2[i] == p3[i]);
2064 BOOST_REQUIRE_EQUAL(check,
true);
2071 empty.template unpack(mem2,ps);
2073 BOOST_REQUIRE_EQUAL(empty.getGrid().size(0),
grid.getGrid().size(0));
2074 BOOST_REQUIRE_EQUAL(empty.getGrid().size(1),
grid.getGrid().size(1));
2075 BOOST_REQUIRE_EQUAL(empty.getGrid().size(2),
grid.getGrid().size(2));
2077 auto it = empty.getIterator();
2083 check &= (
grid.template get<0>(p) == empty.template get<0>(p));
2088 BOOST_REQUIRE_EQUAL(check,
true);
2091template<
typename sgr
id>
void Test_unpack_and_check(sgrid &
grid, sgrid & grid2,
size_t (& sz_cell)[3])
2093 grid.getBackgroundValue().template get<0>() = 0.0;
2100 auto sub_it =
grid.getIterator(start,stop);
2102 grid.template packRequest<0>(sub_it,req);
2112 grid.template pack<0>(mem,sub_it,sts);
2118 grid2.template unpack<0>(mem,sub_it,usts,ctx,rem_copy_opt::NONE_OPT);
2121 auto it =
grid.getIterator();
2125 auto key = it.get();
2127 if (bx.isInside(key.toPoint()) ==
true)
2128 {match &=
grid.template get<0>(key) == grid2.template get<0>(key);}
2133 BOOST_REQUIRE_EQUAL(match,
true);
2136BOOST_AUTO_TEST_CASE( sparse_grid_sub_grid_it_packing)
2138 size_t sz[3] = {501,501,501};
2139 size_t sz_cell[3] = {500,500,500};
2145 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
2149 cdsm.setDimensions(domain, sz_cell, 0);
2151 fill_sphere(
grid,cdsm);
2153 Test_unpack_and_check(
grid,grid2,sz_cell);
2161 auto sub_it =
grid.getIterator(start,stop);
2163 while (sub_it.isNext())
2165 auto p = sub_it.
get();
2167 grid3.template insert<0>(p) =
grid.template get<0>(p);
2168 grid3.template insert<1>(p) =
grid.template get<1>(p);
2175 Test_unpack_and_check(
grid,grid3,sz_cell);
2182 auto sub_it2 =
grid.getIterator(start2,stop2);
2186 while (sub_it2.isNext())
2188 auto p = sub_it2.
get();
2190 match &= grid3.template insert<0>(p) ==
grid.template get<0>(p);
2191 match &= grid3.template insert<1>(p) ==
grid.template get<1>(p);
2198 BOOST_REQUIRE_EQUAL(match,
true);
2199 BOOST_REQUIRE_EQUAL(cnt,cnt2);
2203BOOST_AUTO_TEST_CASE( sparse_grid_remove_area)
2205 size_t sz[3] = {501,501,501};
2218 while (sub.isNext())
2222 grid.template insert<0>(p) = 1.0;
2227 grid.remove(bx_delete);
2232 auto it2 =
grid.getIterator(bx_create.getKP1(),bx_create.getKP2());
2233 while (it2.isNext())
2237 check &= bx_delete.isInside(p.
toPoint()) ==
false;
2244 BOOST_REQUIRE_EQUAL(check,
true);
2246 BOOST_REQUIRE_EQUAL(cnt,bx_create.getVolumeKey() - bx_delete.getVolumeKey());
2249BOOST_AUTO_TEST_CASE( sparse_grid_copy_to)
2251 size_t sz[3] = {501,501,501};
2255 grid.getBackgroundValue().template get<0>() = 0.0;
2257 size_t sz_g2[3] = {259,27,27};
2261 auto gs = grid2.getGrid();
2263 while (key_it.isNext())
2265 auto key = key_it.get();
2267 grid2.insert<0>(key) = gs.LinId(key);
2275 grid.copy_to(grid2,bx_src,bx_dst);
2277 BOOST_REQUIRE(
grid.size() != 0);
2278 BOOST_REQUIRE_EQUAL(
grid.size(),bx_dst.getVolumeKey());
2281 auto it_check =
grid.getIterator(bx_dst.getKP1(),bx_dst.getKP2());
2283 while (it_check.isNext())
2285 auto key = it_check.get();
2288 key2 += bx_src.getKP1();
2290 if (
grid.template get<0>(key) != gs.LinId(key2))
2296 BOOST_REQUIRE_EQUAL(match,
true);
2299 grid.copy_to(grid2,bx_src,bx_dst);
2301 BOOST_REQUIRE(
grid.size() != 0);
2302 BOOST_REQUIRE_EQUAL(
grid.size(),2*bx_dst.getVolumeKey());
2305 auto it_check2 =
grid.getIterator(bx_dst.getKP1(),bx_dst.getKP2());
2307 while (it_check2.isNext())
2309 auto key = it_check2.get();
2312 key2 += bx_src.getKP1();
2314 if (
grid.template get<0>(key) != gs.LinId(key2))
2320 BOOST_REQUIRE_EQUAL(match,
true);
2323BOOST_AUTO_TEST_CASE( sparse_pack_full )
2325 size_t sz[3] = {501,501,501};
2326 size_t sz_cell[3] = {500,500,500};
2330 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
2334 cdsm.setDimensions(domain, sz_cell, 0);
2336 fill_sphere(
grid,cdsm);
2338 Test_unpack_and_check_full(
grid);
2341BOOST_AUTO_TEST_CASE( sparse_pack_full_noprp )
2343 size_t sz[3] = {501,501,501};
2344 size_t sz_cell[3] = {500,500,500};
2348 CellDecomposer_sm<3, float, shift<3,float>> cdsm;
2352 cdsm.setDimensions(domain, sz_cell, 0);
2354 fill_sphere(
grid,cdsm);
2356 Test_unpack_and_check_full_noprp(
grid);
2359BOOST_AUTO_TEST_CASE( sparse_operator_equal )
2361 size_t sz[3] = {270,270,270};
2365 grid.getBackgroundValue().template get<0>() = 0.0;
2370 auto gs =
grid.getGrid();
2372 while (key_it.isNext())
2374 auto key = key_it.get();
2376 grid.insert<0>(key) = gs.LinId(key);
2383 BOOST_REQUIRE(
grid.size() == grid2.
size());
2386 auto it_check =
grid.getIterator();
2388 while (it_check.isNext())
2390 auto key = it_check.get();
2392 if (
grid.template get<0>(key) != grid2.template get<0>(key))
2398 BOOST_REQUIRE_EQUAL(match,
true);
2401BOOST_AUTO_TEST_CASE( sparse_testing_clear )
2403 size_t sz[3] = {10000,10000,10000};
2407 grid.getBackgroundValue().template get<0>() = 555.0;
2413 grid.template insert<0>(key1) = 1.0;
2414 grid.template insert<0>(key2) = 2.0;
2415 grid.template insert<0>(key3) = 3.0;
2421 BOOST_REQUIRE_EQUAL(
grid.template get<0>(keyzero),555.0);
2423 grid.template insert<0>(key1) = 1.0;
2424 grid.template insert<0>(key2) = 2.0;
2425 grid.template insert<0>(key3) = 3.0;
2427 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key1),1.0);
2428 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key2),2.0);
2429 BOOST_REQUIRE_EQUAL(
grid.template get<0>(key3),3.0);
2431 BOOST_REQUIRE_EQUAL(
grid.template get<0>(keyzero),555.0);
2434BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
virtual void fill(unsigned char c)
fill host and device memory with the selected byte
virtual void incRef()
Increment the reference counter.
virtual size_t size() const
Get the size of the LAST allocated memory.
This class allocate, and destroy CPU memory.
virtual bool allocate(size_t sz)
allocate memory
virtual void * getPointer()
get a readable pointer with the data
Laplacian second order on h (spacing)
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This is a distributed grid.
Declaration grid_key_dx_iterator_sub.
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.
__host__ __device__ Point< dim, typeT > toPoint() const
Convert to a point the grid_key_dx.
__device__ __host__ index_type get(index_type i) const
Get the i index.
It model an expression expr1 + ... exprn.