8#ifndef VCLUSTER_SEMANTIC_UNIT_TESTS_FUNCS_HPP_
9#define VCLUSTER_SEMANTIC_UNIT_TESTS_FUNCS_HPP_
11#include "VCluster/VCluster.hpp"
13template<
typename Memory,
template<
typename>
class layout_base>
14void test_different_layouts()
16 for (
size_t i = 0 ; i < 100 ; i++)
28 v1.template get<0>(j) = 5;
29 v1.template get<1>(j) = 10.0+1000.0;
30 v1.template get<2>(j) = 11.0+100000;
40 BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
42 bool is_correct =
true;
43 for (
size_t i = 0 ; i < v2.size() ; i++)
45 is_correct &= (v2.template get<0>(i) == 5);
46 is_correct &= (v2.template get<1>(i) == 10.0+1000.0);
47 is_correct &= (v2.template get<2>(i) == 11.0+100000.0);
50 BOOST_REQUIRE_EQUAL(is_correct,
true);
53 std::cout <<
"Semantic gather test stop" << std::endl;
57template<
typename Memory>
58void test_ssend_recv_layout_switch(
size_t opt)
60 auto & v_cl = create_vcluster<Memory>();
62 if (v_cl.size() > 10) {
return;}
71 vd.resize(v_cl.size());
73 for (
size_t i = 0 ; i < vd.
size() ; i++)
75 vd.get(i).resize(100);
77 for (
size_t j = 0 ; j < vd.get(i).size() ; j++)
79 vd.get(i).template get<0>(j) = 10000*i + v_cl.rank()*100 + j;
81 vd.get(i).template get<1>(j)[0] = 400000 + 10000*i + v_cl.rank()*100 + j;
82 vd.get(i).template get<1>(j)[1] = 400000 + 10000*i + v_cl.rank()*100 + j;
83 vd.get(i).template get<1>(j)[2] = 400000 + 10000*i + v_cl.rank()*100 + j;
88 if (opt & MPI_GPU_DIRECT)
90 vd.get(i).template hostToDevice<0,1>();
94 for (
size_t j = 0 ; j < vd.get(i).size() ; j++)
96 vd.get(i).template get<0>(j) = 0.0;
98 vd.get(i).template get<1>(j)[0] = 0.0;
99 vd.get(i).template get<1>(j)[1] = 0.0;
100 vd.get(i).template get<1>(j)[2] = 0.0;
105 v_cl.template SSendRecv<openfpm::vector_gpu_single<aggregate<float,float[3]>>,
decltype(collect),
memory_traits_inte>
106 (vd,collect,prc_send, prc_recv,sz_recv,opt);
108 v_cl.template SSendRecvP<openfpm::vector_gpu_single<aggregate<float,float[3]>>,
decltype(collect),
memory_traits_inte,0,1>
109 (vd,collect2,prc_send, prc_recv,sz_recv,opt);
113 BOOST_REQUIRE_EQUAL(collect.
size(),100*v_cl.size());
114 BOOST_REQUIRE_EQUAL(collect2.
size(),100*v_cl.size());
118 if (opt & MPI_GPU_DIRECT)
120 for (
size_t j = 0 ; j < collect.
size() ; j++)
122 collect.template get<0>(j) = 0.0;
124 collect.template get<1>(j)[0] = 0.0;
125 collect.template get<1>(j)[1] = 0.0;
126 collect.template get<1>(j)[2] = 0.0;
128 collect2.template get<0>(j) = 0.0;
130 collect2.template get<1>(j)[0] = 0.0;
131 collect2.template get<1>(j)[1] = 0.0;
132 collect2.template get<1>(j)[2] = 0.0;
138 if (opt & MPI_GPU_DIRECT)
140 collect.template deviceToHost<0,1>();
141 collect2.template deviceToHost<0,1>();
149 for (
size_t i = 0 ; i < v_cl.size() ; i++)
151 for (
size_t j = 0 ; j < 100 ; j++)
153 match &= collect.template get<0>(i*100 +j) == v_cl.rank()*10000 + i*100 + j;
155 match &= collect.template get<1>(i*100 +j)[0] == 400000 + v_cl.rank()*10000 + i*100 + j;
156 match &= collect.template get<1>(i*100 +j)[1] == 400000 + v_cl.rank()*10000 + i*100 + j;
157 match &= collect.template get<1>(i*100 +j)[2] == 400000 + v_cl.rank()*10000 + i*100 + j;
159 match &= collect2.template get<0>(i*100 +j) == v_cl.rank()*10000 + i*100 + j;
161 match &= collect2.template get<1>(i*100 +j)[0] == 400000 + v_cl.rank()*10000 + i*100 + j;
162 match &= collect2.template get<1>(i*100 +j)[1] == 400000 + v_cl.rank()*10000 + i*100 + j;
163 match &= collect2.template get<1>(i*100 +j)[2] == 400000 + v_cl.rank()*10000 + i*100 + j;
166 if (match ==
false){
break;}
169 BOOST_REQUIRE_EQUAL(match,
true);
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
Implementation of 1-D std::vector like structure.
Transform the boost::fusion::vector into memory specification (memory_traits)