8#define BOOST_TEST_DYN_LINK
9#include <boost/test/unit_test.hpp>
10#include "Grid/grid_util_test.hpp"
11#include "data_type/aggregate.hpp"
12#include "VCluster/cuda/VCluster_semantic_unit_tests_funcs.hpp"
15constexpr int NBX_ASYNC = 2;
31BOOST_AUTO_TEST_SUITE( VCluster_semantic_test )
33BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather)
35 for (
size_t i = 0 ; i < 100 ; i++)
40 std::cout <<
"Semantic gather test start" << std::endl;
62 BOOST_REQUIRE_EQUAL(v2.
size(),n*(n-1)/2);
65 for (
size_t i = 0 ; i < v2.
size() ; i++)
66 is_five &= (v2.get(i) == 5);
68 BOOST_REQUIRE_EQUAL(is_five,
true);
73BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_2)
75 for (
size_t i = 0 ; i < 100 ; i++)
99 BOOST_REQUIRE_EQUAL(v2.
size(),n);
102 for (
size_t i = 0 ; i < v2.
size() ; i++)
104 for (
size_t j = 0 ; j < v2.get(i).size() ; j++)
105 is_five &= (v2.get(i).get(j) == 5);
107 BOOST_REQUIRE_EQUAL(is_five,
true);
118 BOOST_REQUIRE_EQUAL(v3.
size(),n-1);
121 for (
size_t i = 0 ; i < v3.
size() ; i++)
123 for (
size_t j = 0 ; j < v3.get(i).size() ; j++)
124 is_five &= (v3.get(i).get(j) == 5);
126 BOOST_REQUIRE_EQUAL(is_five,
true);
132BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_3)
134 for (
size_t i = 0 ; i < 100 ; i++)
147 v1_int2.add((
size_t)7);
148 v1_int2.add((
size_t)7);
150 aggr.template get<0>() = 7;
151 aggr.template get<1>() = v1_int2;
154 aggr.template get<2>() = p;
173 BOOST_REQUIRE_EQUAL(v2.
size(),v1.
size()*n);
175 bool is_seven =
true;
176 for (
size_t i = 0 ; i < v2.
size() ; i++)
178 for (
size_t j = 0 ; j < v2.get(i).size() ; j++)
180 is_seven &= (v2.get(i).template get<0>(j) == 7);
182 for (
size_t k = 0; k < v2.get(i).template get<1>(j).
size(); k++)
183 is_seven &= (v2.get(i).template get<1>(j).get(k) == 7);
187 BOOST_REQUIRE(p.template get<0>() == 1);
188 BOOST_REQUIRE(p.template get<1>() == 2);
189 BOOST_REQUIRE(p.template get<2>() == 3);
190 BOOST_REQUIRE(p.template get<3>() == 4);
192 for (
size_t l = 0 ; l < 3 ; l++)
193 p.template get<4>()[l] = 5;
195 for (
size_t m = 0 ; m < 3 ; m++)
197 for (
size_t n = 0 ; n < 3 ; n++)
199 p.template get<5>()[m][n] = 6;
204 BOOST_REQUIRE_EQUAL(is_seven,
true);
209BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_4)
211 for (
size_t i = 0 ; i < 100 ; i++)
218 size_t sz[] = {16,16};
233 BOOST_REQUIRE_EQUAL(v2.
size(),n);
236 for (
size_t i = 0 ; i < v2.
size() ; i++)
238 auto it = v2.get(i).getIterator();
244 match &= (v2.get(i).template get<p::x>(key) == g1.template get<p::x>(key));
245 match &= (v2.get(i).template get<p::y>(key) == g1.template get<p::y>(key));
246 match &= (v2.get(i).template get<p::z>(key) == g1.template get<p::z>(key));
247 match &= (v2.get(i).template get<p::s>(key) == g1.template get<p::s>(key));
249 match &= (v2.get(i).template get<p::v>(key)[0] == g1.template get<p::v>(key)[0]);
250 match &= (v2.get(i).template get<p::v>(key)[1] == g1.template get<p::v>(key)[1]);
251 match &= (v2.get(i).template get<p::v>(key)[2] == g1.template get<p::v>(key)[2]);
253 match &= (v2.get(i).template get<p::t>(key)[0][0] == g1.template get<p::t>(key)[0][0]);
254 match &= (v2.get(i).template get<p::t>(key)[0][1] == g1.template get<p::t>(key)[0][1]);
255 match &= (v2.get(i).template get<p::t>(key)[0][2] == g1.template get<p::t>(key)[0][2]);
256 match &= (v2.get(i).template get<p::t>(key)[1][0] == g1.template get<p::t>(key)[1][0]);
257 match &= (v2.get(i).template get<p::t>(key)[1][1] == g1.template get<p::t>(key)[1][1]);
258 match &= (v2.get(i).template get<p::t>(key)[1][2] == g1.template get<p::t>(key)[1][2]);
259 match &= (v2.get(i).template get<p::t>(key)[2][0] == g1.template get<p::t>(key)[2][0]);
260 match &= (v2.get(i).template get<p::t>(key)[2][1] == g1.template get<p::t>(key)[2][1]);
261 match &= (v2.get(i).template get<p::t>(key)[2][2] == g1.template get<p::t>(key)[2][2]);
267 BOOST_REQUIRE_EQUAL(match,
true);
272BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_5)
274 for (
size_t i = 0 ; i < 100 ; i++)
284 size_t sz[] = {16,16};
303 BOOST_REQUIRE_EQUAL(v2.
size(),v1.
size()*n);
306 for (
size_t i = 0 ; i < v2.
size() ; i++)
308 auto it = v2.get(i).getIterator();
314 match &= (v2.get(i).template get<p::x>(key) == g1.template get<p::x>(key));
315 match &= (v2.get(i).template get<p::y>(key) == g1.template get<p::y>(key));
316 match &= (v2.get(i).template get<p::z>(key) == g1.template get<p::z>(key));
317 match &= (v2.get(i).template get<p::s>(key) == g1.template get<p::s>(key));
319 match &= (v2.get(i).template get<p::v>(key)[0] == g1.template get<p::v>(key)[0]);
320 match &= (v2.get(i).template get<p::v>(key)[1] == g1.template get<p::v>(key)[1]);
321 match &= (v2.get(i).template get<p::v>(key)[2] == g1.template get<p::v>(key)[2]);
323 match &= (v2.get(i).template get<p::t>(key)[0][0] == g1.template get<p::t>(key)[0][0]);
324 match &= (v2.get(i).template get<p::t>(key)[0][1] == g1.template get<p::t>(key)[0][1]);
325 match &= (v2.get(i).template get<p::t>(key)[0][2] == g1.template get<p::t>(key)[0][2]);
326 match &= (v2.get(i).template get<p::t>(key)[1][0] == g1.template get<p::t>(key)[1][0]);
327 match &= (v2.get(i).template get<p::t>(key)[1][1] == g1.template get<p::t>(key)[1][1]);
328 match &= (v2.get(i).template get<p::t>(key)[1][2] == g1.template get<p::t>(key)[1][2]);
329 match &= (v2.get(i).template get<p::t>(key)[2][0] == g1.template get<p::t>(key)[2][0]);
330 match &= (v2.get(i).template get<p::t>(key)[2][1] == g1.template get<p::t>(key)[2][1]);
331 match &= (v2.get(i).template get<p::t>(key)[2][2] == g1.template get<p::t>(key)[2][2]);
337 BOOST_REQUIRE_EQUAL(match,
true);
342BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_6)
344 for (
size_t i = 0 ; i < 100 ; i++)
355 v1_int2.add((
size_t)7);
356 v1_int2.add((
size_t)7);
375 BOOST_REQUIRE_EQUAL(v2.
size(),v1.
size()*n);
377 bool is_seven =
true;
378 for (
size_t i = 0 ; i < v2.
size() ; i++)
380 for (
size_t j = 0 ; j < v2.get(i).size() ; j++)
382 for (
size_t k = 0 ; k < v2.get(i).get(j).size() ; k++)
383 is_seven &= (v2.get(i).get(j).get(k) == 7);
386 BOOST_REQUIRE_EQUAL(is_seven,
true);
391BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_7)
393 for (
size_t i = 0 ; i < 100 ; i++)
419 BOOST_REQUIRE_EQUAL(v2.
size(),n);
423 for (
size_t i = 0 ; i < v2.
size() ; i++)
425 for (
size_t j = 0 ; j < v2.get(i).size() ; j++)
430 match &= (p2.template get<p::x>() == p1.template get<p::x>());
431 match &= (p2.template get<p::y>() == p1.template get<p::y>());
432 match &= (p2.template get<p::z>() == p1.template get<p::z>());
433 match &= (p2.template get<p::s>() == p1.template get<p::s>());
435 match &= (p2.template get<p::v>()[0] == p1.template get<p::v>()[0]);
436 match &= (p2.template get<p::v>()[1] == p1.template get<p::v>()[1]);
437 match &= (p2.template get<p::v>()[2] == p1.template get<p::v>()[2]);
439 match &= (p2.template get<p::t>()[0][0] == p1.template get<p::t>()[0][0]);
440 match &= (p2.template get<p::t>()[0][1] == p1.template get<p::t>()[0][1]);
441 match &= (p2.template get<p::t>()[0][2] == p1.template get<p::t>()[0][2]);
442 match &= (p2.template get<p::t>()[1][0] == p1.template get<p::t>()[1][0]);
443 match &= (p2.template get<p::t>()[1][1] == p1.template get<p::t>()[1][1]);
444 match &= (p2.template get<p::t>()[1][2] == p1.template get<p::t>()[1][2]);
445 match &= (p2.template get<p::t>()[2][0] == p1.template get<p::t>()[2][0]);
446 match &= (p2.template get<p::t>()[2][1] == p1.template get<p::t>()[2][1]);
447 match &= (p2.template get<p::t>()[2][2] == p1.template get<p::t>()[2][2]);
450 BOOST_REQUIRE_EQUAL(match,
true);
455BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_8)
457 for (
size_t i = 0 ; i < 100 ; i++)
487 BOOST_REQUIRE_EQUAL(v2.
size(),n);
489 for (
size_t i = 0 ; i < v2.
size() ; i++)
491 for (
size_t j = 0 ; j < v2.get(i).size() ; j++)
494 BOOST_REQUIRE(bx == b2);
501BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_gather)
503 for (
size_t i = 0 ; i < 100 ; i++)
527 BOOST_REQUIRE_EQUAL(v2.
size(),n*(n-1)/2);
529 bool is_correct =
true;
530 for (
size_t i = 0 ; i < v2.
size() ; i++)
532 is_correct &= (v2.get(i).a == 5);
533 is_correct &= (v2.get(i).b == 10.0);
534 is_correct &= (v2.get(i).c == 11.0);
537 BOOST_REQUIRE_EQUAL(is_correct,
true);
540 std::cout <<
"Semantic gather test stop" << std::endl;
545BOOST_AUTO_TEST_CASE (Vcluster_semantic_layout_inte_gather)
547 test_different_layouts<HeapMemory,memory_traits_inte>();
548 test_different_layouts<HeapMemory,memory_traits_lin>();
551#define SSCATTER_MAX 7
553BOOST_AUTO_TEST_CASE (Vcluster_semantic_scatter)
555 for (
size_t i = 0 ; i < 100 ; i++)
564 nr = ((nr-1) * nr) / 2;
566 size_t n_elements = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
569 v1.resize(n_elements);
571 for(
size_t i = 0 ; i < n_elements ; i++)
584 sz.add(i % SSCATTER_MAX);
595 for (
size_t i = 0 ; i < v2.
size() ; i++)
596 is_five &= (v2.get(i) == 5);
598 BOOST_REQUIRE_EQUAL(is_five,
true);
603BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_scatter)
605 for (
size_t i = 0 ; i < 100 ; i++)
614 nr = ((nr-1) * nr) / 2;
616 size_t n_elements = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
619 v1.resize(n_elements);
621 for(
size_t i = 0 ; i < n_elements ; i++)
632 sz.add(i % SSCATTER_MAX);
643 for (
size_t i = 0 ; i < v2.
size() ; i++)
644 is_five &= (v2.get(i) == 5);
646 BOOST_REQUIRE_EQUAL(is_five,
true);
651template<
unsigned int impl,
typename VCluster_type,
typename vector1,
typename vector2,
typename vector3>
652void scomm_unknown(VCluster_type & vcl, vector1 & v1, vector2 & v2, vector3 & prc_send, vector3 & prc_recv, vector3 & sz_recv)
660 vcl.SSendRecv(v1,v2,prc_send,prc_recv,sz_recv);
664 vcl.SSendRecvAsync(v1,v2,prc_send,prc_recv,sz_recv);
666 vcl.progressCommunication();
668 vcl.progressCommunication();
670 vcl.progressCommunication();
673 vcl.SSendRecvWait(v1,v2,prc_send,prc_recv,sz_recv);
678template<
unsigned int impl>
679void Vcluster_semantic_sendrecv_all_unknown_impl()
687 for (
size_t i = 0 ; i < 100 ; i++)
692 std::cout <<
"Semantic sendrecv test start" << std::endl;
720 for(
size_t i = 0 ; i < v1.
size() ; i++)
723 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
736 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
744 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
750 nr = ((nr-1) * nr) / 2;
752 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
754 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
761 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
763 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
765 match &= v2.get(s+j) == j;
767 s += sz_recv2.get(i);
770 BOOST_REQUIRE_EQUAL(match,
true);
772 for (
size_t i = 0 ; i < v3.
size() ; i++)
774 for (
size_t j = 0 ; j < v3.get(i).size() ; j++)
776 match &= v3.get(i).get(j) == j;
780 BOOST_REQUIRE_EQUAL(match,
true);
784void Vcluster_semantic_sendrecv_all_unknown_multiple_impl()
797 for (
size_t i = 0 ; i < 100 ; i++)
801 for (
size_t k = 0 ; k < NQUEUE / 2 ; k++)
804 {std::cout <<
"Semantic sendrecv test start" << std::endl;}
810 prc_recv2[k].clear();
811 prc_recv3[k].clear();
832 for(
size_t i = 0 ; i < v1[k].
size() ; i++)
835 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
836 {v1[k].get(i).add(j);}
849 vcl.
SSendRecvAsync(v1[k],v2[k],prc_send[k],prc_recv2[k],sz_recv2[k]);
857 vcl.
SSendRecvAsync(v1[k],v3[k],prc_send[k],prc_recv3[k],sz_recv3[k]);
867 for (
size_t k = 0 ; k < NQUEUE / 2 ; k++)
869 vcl.
SSendRecvWait(v1[k],v2[k],prc_send[k],prc_recv2[k],sz_recv2[k]);
870 vcl.
SSendRecvWait(v1[k],v3[k],prc_send[k],prc_recv3[k],sz_recv3[k]);
875 for (
size_t k = 0 ; k < NQUEUE / 2 ; k++)
879 nr = ((nr-1) * nr) / 2;
881 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
883 BOOST_REQUIRE_EQUAL(v2[k].size(),n_ele);
890 for (
size_t i = 0 ; i < sz_recv2[k].
size() ; i++)
892 for (
size_t j = 0 ; j < sz_recv2[k].get(i); j++)
894 match &= v2[k].get(s+j) == j;
896 s += sz_recv2[k].get(i);
899 BOOST_REQUIRE_EQUAL(match,
true);
901 for (
size_t i = 0 ; i < v3[k].
size() ; i++)
903 for (
size_t j = 0 ; j < v3[k].get(i).size() ; j++)
905 match &= v3[k].get(i).get(j) == j;
909 BOOST_REQUIRE_EQUAL(match,
true);
914BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_all_unknown)
916 Vcluster_semantic_sendrecv_all_unknown_impl<NBX>();
919BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_all_unknown_async)
921 Vcluster_semantic_sendrecv_all_unknown_impl<NBX_ASYNC>();
924BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_all_multiple_unknown)
926 Vcluster_semantic_sendrecv_all_unknown_multiple_impl();
929template<
unsigned int impl,
typename VCluster_type,
typename vector1,
typename vector2,
typename vector3>
930void scomm_known(VCluster_type & vcl, vector1 & v1, vector2 & v2, vector3 & prc_send, vector3 & prc_recv, vector3 & sz_recv)
938 vcl.SSendRecv(v1,v2,prc_send,prc_recv,sz_recv,RECEIVE_KNOWN | KNOWN_ELEMENT_OR_BYTE);
942 vcl.SSendRecvAsync(v1,v2,prc_send,prc_recv,sz_recv,RECEIVE_KNOWN | KNOWN_ELEMENT_OR_BYTE);
944 vcl.progressCommunication();
946 vcl.progressCommunication();
948 vcl.progressCommunication();
951 vcl.SSendRecvWait(v1,v2,prc_send,prc_recv,sz_recv,RECEIVE_KNOWN | KNOWN_ELEMENT_OR_BYTE);
956template<
unsigned int impl>
957void Vcluster_semantic_sendrecv_receive_size_known_impl()
965 for (
size_t i = 0 ; i < 100 ; i++)
970 {std::cout <<
"Semantic sendrecv test start" << std::endl;}
986 nr = ((nr-1) * nr) / 2;
988 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
990 for(
size_t i = 0 ; i < v1.
size() ; i++)
992 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
999 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1002 for(
size_t i = 0 ; i < v1.
size() ; i++)
1004 if( i % SSCATTER_MAX == 0)
1014 scomm_known<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1015 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1017 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1024 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1026 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1028 match &= v2.get(s+j) == j;
1030 s += sz_recv2.get(i);
1033 BOOST_REQUIRE_EQUAL(match,
true);
1035 for (
size_t i = 0 ; i < v3.
size() ; i++)
1037 for (
size_t j = 0 ; j < v3.get(i).size() ; j++)
1039 match &= v3.get(i).get(j) == j;
1043 BOOST_REQUIRE_EQUAL(match,
true);
1047BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_receive_size_known)
1049 Vcluster_semantic_sendrecv_receive_size_known_impl<NBX>();
1052BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_receive_size_known_async)
1054 Vcluster_semantic_sendrecv_receive_size_known_impl<NBX_ASYNC>();
1057template<
unsigned int impl,
typename VCluster_type,
typename vector1,
typename vector2,
typename vector3>
1058void scomm_known2(VCluster_type & vcl, vector1 & v1, vector2 & v2, vector3 & prc_send, vector3 & prc_recv, vector3 & sz_recv)
1066 vcl.SSendRecv(v1,v2,prc_send,prc_recv,sz_recv,RECEIVE_KNOWN);
1070 vcl.SSendRecvAsync(v1,v2,prc_send,prc_recv,sz_recv,RECEIVE_KNOWN);
1072 vcl.progressCommunication();
1074 vcl.progressCommunication();
1076 vcl.progressCommunication();
1079 vcl.SSendRecvWait(v1,v2,prc_send,prc_recv,sz_recv,RECEIVE_KNOWN);
1083template<
unsigned int impl>
1084void Vcluster_semantic_sendrecv_receive_known_impl()
1092 for (
size_t i = 0 ; i < 100 ; i++)
1097 {std::cout <<
"Semantic sendrecv test start" << std::endl;}
1113 nr = ((nr-1) * nr) / 2;
1115 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
1117 for(
size_t i = 0 ; i < v1.
size() ; i++)
1119 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
1126 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1130 for(
size_t i = 0 ; i < v1.
size() ; i++)
1132 if( i % SSCATTER_MAX == 0)
1141 scomm_known2<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1142 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1144 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1151 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1153 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1155 match &= v2.get(s+j) == j;
1157 s += sz_recv2.get(i);
1160 BOOST_REQUIRE_EQUAL(match,
true);
1162 for (
size_t i = 0 ; i < v3.
size() ; i++)
1164 for (
size_t j = 0 ; j < v3.get(i).size() ; j++)
1166 match &= v3.get(i).get(j) == j;
1170 BOOST_REQUIRE_EQUAL(match,
true);
1174BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_receive_known)
1176 Vcluster_semantic_sendrecv_receive_known_impl<NBX>();
1179BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_receive_known_async)
1181 Vcluster_semantic_sendrecv_receive_known_impl<NBX_ASYNC>();
1184template<
unsigned int impl>
1185void Vcluster_semantic_struct_sendrecv_impl()
1187 for (
size_t i = 0 ; i < 100 ; i++)
1207 nr = ((nr-1) * nr) / 2;
1209 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
1211 for(
size_t i = 0 ; i < v1.
size() ; i++)
1213 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
1222 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1223 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1225 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1232 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1234 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1240 s += sz_recv2.get(i);
1243 BOOST_REQUIRE_EQUAL(match,
true);
1245 for (
size_t i = 0 ; i < v3.
size() ; i++)
1247 for (
size_t j = 0 ; j < v3.get(i).size() ; j++)
1255 BOOST_REQUIRE_EQUAL(match,
true);
1272 for(
size_t i = 0 ; i < v1.
size() ; i++)
1277 vcl.
SSendRecv(v1,v2,prc_send,prc_recv2,sz_recv2);
1279 BOOST_REQUIRE_EQUAL(v2.
size(),0ul);
1280 BOOST_REQUIRE_EQUAL(prc_recv2.
size(),0ul);
1281 BOOST_REQUIRE_EQUAL(sz_recv2.
size(),0ul);
1285BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_sendrecv)
1287 Vcluster_semantic_struct_sendrecv_impl<NBX>();
1290BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_sendrecv_async)
1292 Vcluster_semantic_struct_sendrecv_impl<NBX_ASYNC>();
1295template<
unsigned int impl>
1296void Vcluster_semantic_sendrecv_2_impl()
1298 for (
size_t i = 0 ; i < 100 ; i++)
1323 aggr.template get<0>() = v1_int2;
1331 for(
size_t i = 0 ; i < v1.
size() ; i++)
1333 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
1335 v1.get(i).add(aggr);
1343 nr = ((nr-1) * nr) / 2;
1345 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
1347 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1348 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1350 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1355 bool is_seven =
true;
1358 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1360 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1362 for (
size_t k = 0; k < v2.get(s+j).
template get<0>().size(); k++)
1363 is_seven &= (v2.get(s+j).template get<0>().get(k) == 7);
1365 s += sz_recv2.get(i);
1368 BOOST_REQUIRE_EQUAL(is_seven,
true);
1369 BOOST_REQUIRE_EQUAL(match,
true);
1371 for (
size_t i = 0 ; i < v3.
size() ; i++)
1373 for (
size_t j = 0 ; j < v3.get(i).size(); j++)
1375 for (
size_t k = 0; k < v3.get(i).
template get<0>(j).size(); k++)
1376 is_seven &= (v3.get(i).template get<0>(j).get(k) == 7);
1380 BOOST_REQUIRE_EQUAL(is_seven,
true);
1381 BOOST_REQUIRE_EQUAL(match,
true);
1385BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_2)
1387 Vcluster_semantic_sendrecv_2_impl<NBX>();
1390BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_2_async)
1392 Vcluster_semantic_sendrecv_2_impl<NBX_ASYNC>();
1395template<
unsigned int impl>
1396void Vcluster_semantic_sendrecv_3_impl()
1398 for (
size_t i = 0 ; i < 100 ; i++)
1419 v1_int2.add((
size_t)7);
1420 v1_int2.add((
size_t)7);
1422 aggr.template get<0>() = 7;
1423 aggr.template get<1>() = v1_int2;
1428 aggr.template get<2>() = p1;
1436 for(
size_t i = 0 ; i < v1.
size() ; i++)
1438 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
1440 v1.get(i).add(aggr);
1448 nr = ((nr-1) * nr) / 2;
1450 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
1452 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1453 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1455 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1460 bool is_seven =
true;
1463 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1465 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1467 is_seven &= (v2.get(s+j).template get<0>() == 7);
1469 for (
size_t k = 0; k < v2.get(s+j).template get<1>().
size(); k++)
1470 is_seven &= (v2.get(s+j).template get<1>().get(k) == 7);
1474 match &= (p2.template get<p::x>() == p1.template get<p::x>());
1475 match &= (p2.template get<p::y>() == p1.template get<p::y>());
1476 match &= (p2.template get<p::z>() == p1.template get<p::z>());
1477 match &= (p2.template get<p::s>() == p1.template get<p::s>());
1479 match &= (p2.template get<p::v>()[0] == p1.template get<p::v>()[0]);
1480 match &= (p2.template get<p::v>()[1] == p1.template get<p::v>()[1]);
1481 match &= (p2.template get<p::v>()[2] == p1.template get<p::v>()[2]);
1483 match &= (p2.template get<p::t>()[0][0] == p1.template get<p::t>()[0][0]);
1484 match &= (p2.template get<p::t>()[0][1] == p1.template get<p::t>()[0][1]);
1485 match &= (p2.template get<p::t>()[0][2] == p1.template get<p::t>()[0][2]);
1486 match &= (p2.template get<p::t>()[1][0] == p1.template get<p::t>()[1][0]);
1487 match &= (p2.template get<p::t>()[1][1] == p1.template get<p::t>()[1][1]);
1488 match &= (p2.template get<p::t>()[1][2] == p1.template get<p::t>()[1][2]);
1489 match &= (p2.template get<p::t>()[2][0] == p1.template get<p::t>()[2][0]);
1490 match &= (p2.template get<p::t>()[2][1] == p1.template get<p::t>()[2][1]);
1491 match &= (p2.template get<p::t>()[2][2] == p1.template get<p::t>()[2][2]);
1493 s += sz_recv2.get(i);
1496 BOOST_REQUIRE_EQUAL(is_seven,
true);
1497 BOOST_REQUIRE_EQUAL(match,
true);
1499 for (
size_t i = 0 ; i < v3.
size() ; i++)
1501 for (
size_t j = 0 ; j < v3.get(i).size(); j++)
1503 is_seven &= (v3.get(i).get(j).template get<0>() == 7);
1505 for (
size_t k = 0; k < v3.get(i).get(j).template get<1>().
size(); k++)
1506 is_seven &= (v3.get(i).get(j).template get<1>().get(k) == 7);
1510 match &= (p2.template get<p::x>() == p1.template get<p::x>());
1511 match &= (p2.template get<p::y>() == p1.template get<p::y>());
1512 match &= (p2.template get<p::z>() == p1.template get<p::z>());
1513 match &= (p2.template get<p::s>() == p1.template get<p::s>());
1515 match &= (p2.template get<p::v>()[0] == p1.template get<p::v>()[0]);
1516 match &= (p2.template get<p::v>()[1] == p1.template get<p::v>()[1]);
1517 match &= (p2.template get<p::v>()[2] == p1.template get<p::v>()[2]);
1519 match &= (p2.template get<p::t>()[0][0] == p1.template get<p::t>()[0][0]);
1520 match &= (p2.template get<p::t>()[0][1] == p1.template get<p::t>()[0][1]);
1521 match &= (p2.template get<p::t>()[0][2] == p1.template get<p::t>()[0][2]);
1522 match &= (p2.template get<p::t>()[1][0] == p1.template get<p::t>()[1][0]);
1523 match &= (p2.template get<p::t>()[1][1] == p1.template get<p::t>()[1][1]);
1524 match &= (p2.template get<p::t>()[1][2] == p1.template get<p::t>()[1][2]);
1525 match &= (p2.template get<p::t>()[2][0] == p1.template get<p::t>()[2][0]);
1526 match &= (p2.template get<p::t>()[2][1] == p1.template get<p::t>()[2][1]);
1527 match &= (p2.template get<p::t>()[2][2] == p1.template get<p::t>()[2][2]);
1531 BOOST_REQUIRE_EQUAL(is_seven,
true);
1532 BOOST_REQUIRE_EQUAL(match,
true);
1536BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_3)
1538 Vcluster_semantic_sendrecv_3_impl<NBX>();
1541BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_3_async)
1543 Vcluster_semantic_sendrecv_3_impl<NBX_ASYNC>();
1546template<
unsigned int impl>
1547void Vcluster_semantic_sendrecv_4_impl()
1549 for (
size_t i = 0 ; i < 100 ; i++)
1569 nr = ((nr-1) * nr) / 2;
1571 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
1581 aggr.template get<0>() = 7;
1582 aggr.template get<1>() = p1;
1585 for(
size_t i = 0 ; i < v1.
size() ; i++)
1587 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
1589 v1.get(i).add(aggr);
1595 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1596 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1598 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1602 bool is_seven =
true;
1605 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1607 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1609 is_seven &= (v2.get(s+j).template get<0>() == 7);
1613 match &= (p2.template get<p::x>() == p1.template get<p::x>());
1614 match &= (p2.template get<p::y>() == p1.template get<p::y>());
1615 match &= (p2.template get<p::z>() == p1.template get<p::z>());
1616 match &= (p2.template get<p::s>() == p1.template get<p::s>());
1618 match &= (p2.template get<p::v>()[0] == p1.template get<p::v>()[0]);
1619 match &= (p2.template get<p::v>()[1] == p1.template get<p::v>()[1]);
1620 match &= (p2.template get<p::v>()[2] == p1.template get<p::v>()[2]);
1622 match &= (p2.template get<p::t>()[0][0] == p1.template get<p::t>()[0][0]);
1623 match &= (p2.template get<p::t>()[0][1] == p1.template get<p::t>()[0][1]);
1624 match &= (p2.template get<p::t>()[0][2] == p1.template get<p::t>()[0][2]);
1625 match &= (p2.template get<p::t>()[1][0] == p1.template get<p::t>()[1][0]);
1626 match &= (p2.template get<p::t>()[1][1] == p1.template get<p::t>()[1][1]);
1627 match &= (p2.template get<p::t>()[1][2] == p1.template get<p::t>()[1][2]);
1628 match &= (p2.template get<p::t>()[2][0] == p1.template get<p::t>()[2][0]);
1629 match &= (p2.template get<p::t>()[2][1] == p1.template get<p::t>()[2][1]);
1630 match &= (p2.template get<p::t>()[2][2] == p1.template get<p::t>()[2][2]);
1632 s += sz_recv2.get(i);
1635 BOOST_REQUIRE_EQUAL(is_seven,
true);
1636 BOOST_REQUIRE_EQUAL(match,
true);
1638 for (
size_t i = 0 ; i < v3.
size() ; i++)
1640 for (
size_t j = 0 ; j < v3.get(i).size() ; j++)
1642 is_seven &= (v3.get(i).get(j).template get<0>() == 7);
1646 match &= (p2.template get<p::x>() == p1.template get<p::x>());
1647 match &= (p2.template get<p::y>() == p1.template get<p::y>());
1648 match &= (p2.template get<p::z>() == p1.template get<p::z>());
1649 match &= (p2.template get<p::s>() == p1.template get<p::s>());
1651 match &= (p2.template get<p::v>()[0] == p1.template get<p::v>()[0]);
1652 match &= (p2.template get<p::v>()[1] == p1.template get<p::v>()[1]);
1653 match &= (p2.template get<p::v>()[2] == p1.template get<p::v>()[2]);
1655 match &= (p2.template get<p::t>()[0][0] == p1.template get<p::t>()[0][0]);
1656 match &= (p2.template get<p::t>()[0][1] == p1.template get<p::t>()[0][1]);
1657 match &= (p2.template get<p::t>()[0][2] == p1.template get<p::t>()[0][2]);
1658 match &= (p2.template get<p::t>()[1][0] == p1.template get<p::t>()[1][0]);
1659 match &= (p2.template get<p::t>()[1][1] == p1.template get<p::t>()[1][1]);
1660 match &= (p2.template get<p::t>()[1][2] == p1.template get<p::t>()[1][2]);
1661 match &= (p2.template get<p::t>()[2][0] == p1.template get<p::t>()[2][0]);
1662 match &= (p2.template get<p::t>()[2][1] == p1.template get<p::t>()[2][1]);
1663 match &= (p2.template get<p::t>()[2][2] == p1.template get<p::t>()[2][2]);
1667 BOOST_REQUIRE_EQUAL(is_seven,
true);
1668 BOOST_REQUIRE_EQUAL(match,
true);
1672BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_4)
1674 Vcluster_semantic_sendrecv_4_impl<NBX>();
1677BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_4_async)
1679 Vcluster_semantic_sendrecv_4_impl<NBX_ASYNC>();
1682template<
unsigned int impl>
1683void Vcluster_semantic_sendrecv_5_impl()
1685 for (
size_t i = 0 ; i < 100 ; i++)
1698 size_t sz[] = {16,16};
1705 aggr.template get<0>() = g1;
1714 for(
size_t i = 0 ; i < v1.
size() ; i++)
1716 for (
size_t j = 0 ; j < i % SSCATTER_MAX ; j++)
1718 v1.get(i).add(aggr);
1726 nr = ((nr-1) * nr) / 2;
1728 size_t n_ele = nc * SSCATTER_MAX * (SSCATTER_MAX - 1) / 2 + nr;
1730 scomm_unknown<impl>(vcl,v1,v2,prc_send,prc_recv2,sz_recv2);
1732 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1734 BOOST_REQUIRE_EQUAL(v2.
size(),n_ele);
1742 for (
size_t i = 0 ; i < sz_recv2.
size() ; i++)
1744 for (
size_t j = 0 ; j < sz_recv2.get(i); j++)
1748 auto it = g2.getIterator();
1754 match &= (g2.template get<p::x>(key) == g1.template get<p::x>(key));
1755 match &= (g2.template get<p::y>(key) == g1.template get<p::y>(key));
1756 match &= (g2.template get<p::z>(key) == g1.template get<p::z>(key));
1757 match &= (g2.template get<p::s>(key) == g1.template get<p::s>(key));
1759 match &= (g2.template get<p::v>(key)[0] == g1.template get<p::v>(key)[0]);
1760 match &= (g2.template get<p::v>(key)[1] == g1.template get<p::v>(key)[1]);
1761 match &= (g2.template get<p::v>(key)[2] == g1.template get<p::v>(key)[2]);
1763 match &= (g2.template get<p::t>(key)[0][0] == g1.template get<p::t>(key)[0][0]);
1764 match &= (g2.template get<p::t>(key)[0][1] == g1.template get<p::t>(key)[0][1]);
1765 match &= (g2.template get<p::t>(key)[0][2] == g1.template get<p::t>(key)[0][2]);
1766 match &= (g2.template get<p::t>(key)[1][0] == g1.template get<p::t>(key)[1][0]);
1767 match &= (g2.template get<p::t>(key)[1][1] == g1.template get<p::t>(key)[1][1]);
1768 match &= (g2.template get<p::t>(key)[1][2] == g1.template get<p::t>(key)[1][2]);
1769 match &= (g2.template get<p::t>(key)[2][0] == g1.template get<p::t>(key)[2][0]);
1770 match &= (g2.template get<p::t>(key)[2][1] == g1.template get<p::t>(key)[2][1]);
1771 match &= (g2.template get<p::t>(key)[2][2] == g1.template get<p::t>(key)[2][2]);
1776 s += sz_recv2.get(i);
1778 BOOST_REQUIRE_EQUAL(match,
true);
1780 for (
size_t i = 0 ; i < v3.
size() ; i++)
1782 for (
size_t j = 0 ; j < v3.get(i).size(); j++)
1786 auto it = g2.getIterator();
1792 match &= (g2.template get<p::x>(key) == g1.template get<p::x>(key));
1793 match &= (g2.template get<p::y>(key) == g1.template get<p::y>(key));
1794 match &= (g2.template get<p::z>(key) == g1.template get<p::z>(key));
1795 match &= (g2.template get<p::s>(key) == g1.template get<p::s>(key));
1797 match &= (g2.template get<p::v>(key)[0] == g1.template get<p::v>(key)[0]);
1798 match &= (g2.template get<p::v>(key)[1] == g1.template get<p::v>(key)[1]);
1799 match &= (g2.template get<p::v>(key)[2] == g1.template get<p::v>(key)[2]);
1801 match &= (g2.template get<p::t>(key)[0][0] == g1.template get<p::t>(key)[0][0]);
1802 match &= (g2.template get<p::t>(key)[0][1] == g1.template get<p::t>(key)[0][1]);
1803 match &= (g2.template get<p::t>(key)[0][2] == g1.template get<p::t>(key)[0][2]);
1804 match &= (g2.template get<p::t>(key)[1][0] == g1.template get<p::t>(key)[1][0]);
1805 match &= (g2.template get<p::t>(key)[1][1] == g1.template get<p::t>(key)[1][1]);
1806 match &= (g2.template get<p::t>(key)[1][2] == g1.template get<p::t>(key)[1][2]);
1807 match &= (g2.template get<p::t>(key)[2][0] == g1.template get<p::t>(key)[2][0]);
1808 match &= (g2.template get<p::t>(key)[2][1] == g1.template get<p::t>(key)[2][1]);
1809 match &= (g2.template get<p::t>(key)[2][2] == g1.template get<p::t>(key)[2][2]);
1815 BOOST_REQUIRE_EQUAL(match,
true);
1819BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_5)
1821 Vcluster_semantic_sendrecv_5_impl<NBX>();
1824BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_5_async)
1826 Vcluster_semantic_sendrecv_5_impl<NBX_ASYNC>();
1829template<
unsigned int impl>
1830void Vcluster_semantic_sendrecv_6_impl()
1832 for (
size_t i = 0 ; i < 100 ; i++)
1845 size_t sz[] = {8,10};
1856 for(
size_t i = 0 ; i < v1.
size() ; i++)
1863 scomm_unknown<impl>(vcl,v1,v3,prc_send,prc_recv3,sz_recv3);
1870 for (
size_t i = 0 ; i < v3.
size() ; i++)
1872 for (
size_t j = 0 ; j < v3.get(i).size(); j++)
1876 auto it = g2.getIterator();
1882 match &= (g2.template get<p::x>(key) == g1.template get<p::x>(key));
1883 match &= (g2.template get<p::y>(key) == g1.template get<p::y>(key));
1884 match &= (g2.template get<p::z>(key) == g1.template get<p::z>(key));
1885 match &= (g2.template get<p::s>(key) == g1.template get<p::s>(key));
1887 match &= (g2.template get<p::v>(key)[0] == g1.template get<p::v>(key)[0]);
1888 match &= (g2.template get<p::v>(key)[1] == g1.template get<p::v>(key)[1]);
1889 match &= (g2.template get<p::v>(key)[2] == g1.template get<p::v>(key)[2]);
1891 match &= (g2.template get<p::t>(key)[0][0] == g1.template get<p::t>(key)[0][0]);
1892 match &= (g2.template get<p::t>(key)[0][1] == g1.template get<p::t>(key)[0][1]);
1893 match &= (g2.template get<p::t>(key)[0][2] == g1.template get<p::t>(key)[0][2]);
1894 match &= (g2.template get<p::t>(key)[1][0] == g1.template get<p::t>(key)[1][0]);
1895 match &= (g2.template get<p::t>(key)[1][1] == g1.template get<p::t>(key)[1][1]);
1896 match &= (g2.template get<p::t>(key)[1][2] == g1.template get<p::t>(key)[1][2]);
1897 match &= (g2.template get<p::t>(key)[2][0] == g1.template get<p::t>(key)[2][0]);
1898 match &= (g2.template get<p::t>(key)[2][1] == g1.template get<p::t>(key)[2][1]);
1899 match &= (g2.template get<p::t>(key)[2][2] == g1.template get<p::t>(key)[2][2]);
1905 BOOST_REQUIRE_EQUAL(match,
true);
1908 std::cout <<
"Semantic sendrecv test start" << std::endl;
1912BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_6)
1914 Vcluster_semantic_sendrecv_6_impl<NBX>();
1917BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_6_async)
1919 Vcluster_semantic_sendrecv_6_impl<NBX_ASYNC>();
1922BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Test structure used for several test.
void progressCommunication()
In case of Asynchonous communications like sendrecvMultipleMessagesNBXAsync this function progress th...
size_t size()
Get the total number of processors.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
bool SScatter(T &send, S &recv, openfpm::vector< size_t > &prc, openfpm::vector< size_t > &sz, size_t root)
Semantic Scatter, scatter the data from one processor to the other node.
bool SSendRecvWait(openfpm::vector< T > &send, S &recv, openfpm::vector< size_t > &prc_send, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &sz_recv, size_t opt=NONE)
Synchronize with SSendRecv.
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
bool SSendRecvAsync(openfpm::vector< T > &send, S &recv, openfpm::vector< size_t > &prc_send, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &sz_recv, size_t opt=NONE)
Semantic Send and receive, send the data to processors and receive from the other processors asynchro...
bool SSendRecv(openfpm::vector< T > &send, S &recv, openfpm::vector< size_t > &prc_send, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &sz_recv, size_t opt=NONE)
Semantic Send and receive, send the data to processors and receive from the other processors.
grid_key_dx is the key to access any element in the grid
__device__ __host__ index_type get(index_type i) const
Get the i index.
Implementation of 1-D std::vector like structure.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...