Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sbalzarini Lab
S
Software
P
Parallel Computing
OpenFPM
openfpm_vcluster
Commits
5dbe8c24
Commit
5dbe8c24
authored
Jul 20, 2016
by
Yaroslav
Browse files
Work on SGather 2
parent
81e452b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/VCluster_semantic.ipp
View file @
5dbe8c24
...
...
@@ -9,6 +9,31 @@
private:
// Structures that do a pack request, depending on the existence of max_prop inside 'send'
//There is max_prop inside
template<bool cond, typename T>
struct packRequest_cond
{
void packingRequest(T & send, size_t & tot_size)
{
typedef typename ::generate_array_constexpr<unsigned int,T::max_prop, MetaFuncOrd>::result prop_to_pack;
Packer<decltype(send),HeapMemory>::packRequest< prop_to_pack::data >(send,tot_size);
}
};
//There is no max_prop inside
template<typename T>
struct packRequest_cond<false, T>
{
void packingRequest(T & send, size_t & tot_size)
{
Packer<decltype(send),HeapMemory>::packRequest(send,tot_size);
}
};
/*! \brief Reset the receive buffer
*
*
...
...
@@ -147,6 +172,10 @@ template<typename T, typename S> bool SGather(T & send, S & recv,size_t root)
return SGather(send,recv,prc,sz,root);
}
template<size_t index, size_t N> struct MetaFuncOrd {
enum { value = index };
};
/*! \brief Semantic Gather, gather the data from all processors into one node
*
* Semantic communication differ from the normal one. They in general
...
...
@@ -180,7 +209,7 @@ template<typename T, typename S> bool SGather(T & send, S & recv, openfpm::vecto
{
// Reset the receive buffer
reset_recv_buf();
// If we are on master collect the information
if (getProcessUnitID() == root)
{
...
...
@@ -203,7 +232,7 @@ template<typename T, typename S> bool SGather(T & send, S & recv, openfpm::vecto
recv.add(send);
prc.add(root);
sz.add(send.size());
sz.add(send.size()
*sizeof(typename T::value_type)
);
}
else
{
...
...
@@ -211,10 +240,22 @@ template<typename T, typename S> bool SGather(T & send, S & recv, openfpm::vecto
// remain buffer with size 0
openfpm::vector<size_t> send_prc;
send_prc.add(root);
size_t tot_size = 0;
//Pack requesting
packRequest_cond<has_max_prop<T>::value, T> pr;
pr.packingRequest(send, tot_size);
openfpm::vector<const void *> send_buf;
send_buf.add(send.getPointer());
openfpm::vector<size_t> sz;
sz.add(send.size()*sizeof(typename T::value_type));
//sz.add(send.size()*sizeof(typename T::value_type));
sz.add(tot_size);
// receive information
base_info bi(NULL,prc,sz);
...
...
src/VCluster_semantic_unit_tests.hpp
View file @
5dbe8c24
...
...
@@ -191,50 +191,6 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_scatter)
}
}
BOOST_AUTO_TEST_CASE
(
Vcluster_semantic_gather_ptst
)
{
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
Vcluster
&
vcl
=
create_vcluster
();
if
(
vcl
.
getProcessingUnits
()
>=
32
)
return
;
openfpm
::
vector
<
aggregate
<
openfpm
::
vector
<
int
>>>
v1
;
openfpm
::
vector
<
int
>
v1_int
;
v1_int
.
resize
(
10
);
for
(
size_t
i
=
0
;
i
<
v1_int
.
size
();
i
++
)
v1_int
.
get
(
i
)
=
5
;
v1
.
resize
(
vcl
.
getProcessUnitID
());
for
(
size_t
i
=
0
;
i
<
vcl
.
getProcessUnitID
()
;
i
++
)
v1
.
template
get
<
0
>(
i
)
=
v1_int
;
openfpm
::
vector
<
aggregate
<
openfpm
::
vector
<
int
>>>
v2
;
/*vcl.SGather(v1,v2,(i%vcl.getProcessingUnits()));
if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits()))
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
bool is_five = true;
for (size_t i = 0 ; i < v2.size() ; i++)
is_five &= (v2.get(i) == 5);
BOOST_REQUIRE_EQUAL(is_five,true);
}*/
}
}
BOOST_AUTO_TEST_CASE
(
Vcluster_semantic_sendrecv
)
{
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
...
...
@@ -401,6 +357,47 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_sendrecv)
}
}
BOOST_AUTO_TEST_CASE
(
Vcluster_semantic_gather_ptst
)
{
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
Vcluster
&
vcl
=
create_vcluster
();
if
(
vcl
.
getProcessingUnits
()
>=
32
)
return
;
openfpm
::
vector
<
aggregate
<
openfpm
::
vector
<
int
>>>
v1
;
openfpm
::
vector
<
int
>
v1_int
;
v1_int
.
resize
(
10
);
for
(
size_t
i
=
0
;
i
<
v1_int
.
size
();
i
++
)
v1_int
.
get
(
i
)
=
5
;
v1
.
resize
(
vcl
.
getProcessUnitID
());
for
(
size_t
i
=
0
;
i
<
vcl
.
getProcessUnitID
()
;
i
++
)
v1
.
template
get
<
0
>(
i
)
=
v1_int
;
openfpm
::
vector
<
aggregate
<
openfpm
::
vector
<
int
>>>
v2
;
/*
vcl.SGather(v1,v2,(i%vcl.getProcessingUnits()));
if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits()))
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
bool is_five = true;
for (size_t i = 0 ; i < v2.size() ; i++)
is_five &= (v2.get(i) == 5);
BOOST_REQUIRE_EQUAL(is_five,true);
}*/
}
}
BOOST_AUTO_TEST_SUITE_END
()
#endif
/* OPENFPM_VCLUSTER_SRC_VCLUSTER_SEMANTIC_UNIT_TESTS_HPP_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment