Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_vcluster
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openfpm
openfpm_vcluster
Commits
4d0157c1
Commit
4d0157c1
authored
Jul 28, 2016
by
Yaroslav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
has_pack_agg selector not fixed
parent
5dbe8c24
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
215 additions
and
45 deletions
+215
-45
src/VCluster.hpp
src/VCluster.hpp
+1
-0
src/VCluster_semantic.ipp
src/VCluster_semantic.ipp
+137
-44
src/VCluster_semantic_unit_tests.hpp
src/VCluster_semantic_unit_tests.hpp
+77
-1
No files found.
src/VCluster.hpp
View file @
4d0157c1
...
...
@@ -18,6 +18,7 @@
#endif
#include "util/Vcluster_log.hpp"
#include "memory/BHeapMemory.hpp"
#include "Packer_Unpacker/has_max_prop.hpp"
#ifdef HAVE_PETSC
#include <petscvec.h>
...
...
src/VCluster_semantic.ipp
View file @
4d0157c1
...
...
@@ -12,24 +12,129 @@ 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 pack
Request
_cond
template<bool cond, typename T
, typename S
>
struct pack
_unpack
_cond
{
void packingRequest(T & send, size_t & tot_size)
static
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);
Packer<
T
,HeapMemory>::packRequest< prop_to_pack::data >(send,tot_size);
}
static void packing(ExtPreAlloc<HeapMemory> & mem, T & send, Pack_stat & sts)
{
typedef typename ::generate_array_constexpr<unsigned int, has_max_prop<T, has_value_type<T>::value>::number, MetaFuncOrd>::result prop_to_pack;
Packer<T,HeapMemory>::pack< prop_to_pack::data >(mem,send,sts);
}
static void unpacking(S & recv, openfpm::vector<BHeapMemory> & recv_buf, Unpack_stat & ps, openfpm::vector<size_t> * sz = NULL)
{
typedef typename ::generate_array_constexpr<unsigned int, has_max_prop<T, has_value_type<T>::value>::number, MetaFuncOrd>::result prop_to_pack;
if (has_pack_agg<typename T::value_type, prop_to_pack::data >::result::value == true)
{
for (size_t i = 0 ; i < recv_buf.size() ; i++)
{
T unp;
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(recv_buf.get(i).size(),recv_buf.get(i)));
mem.incRef();
Unpacker<T,HeapMemory>::unpack< prop_to_pack::data >(mem, unp, ps);
// Merge the information
recv.add(unp);
}
}
else
{
for (size_t i = 0 ; i < recv_buf.size() ; i++)
{
// calculate the number of received elements
size_t n_ele = recv_buf.get(i).size() / sizeof(typename T::value_type);
// add the received particles to the vector
PtrMemory * ptr1 = new PtrMemory(recv_buf.get(i).getPointer(),recv_buf.get(i).size());
// create vector representation to a piece of memory already allocated
openfpm::vector<typename T::value_type,PtrMemory,typename memory_traits_lin<typename T::value_type>::type, memory_traits_lin,openfpm::grow_policy_identity> v2;
v2.setMemory(*ptr1);
// resize with the number of elements
v2.resize(n_ele);
// Merge the information
recv.add(v2);
if (sz != NULL)
sz->get(i) = v2.size();
}
}
}
};
//There is no max_prop inside
template<typename T>
struct pack
Request_cond<false, T
>
template<typename T
, typename S
>
struct pack
_unpack_cond<false, T, S
>
{
void packingRequest(T & send, size_t & tot_size)
static
void packingRequest(T & send, size_t & tot_size)
{
Packer<decltype(send),HeapMemory>::packRequest(send,tot_size);
//tot_size = send.size()*sizeof(typename T::value_type);
Packer<T,HeapMemory>::packRequest(send,tot_size);
std::cout << "Tot_size: " << tot_size << std::endl;
}
static void packing(ExtPreAlloc<HeapMemory> & mem, T & send, Pack_stat & sts)
{
Packer<T,HeapMemory>::pack(mem,send,sts);
}
static void unpacking(S & recv, openfpm::vector<BHeapMemory> & recv_buf, Unpack_stat & ps, openfpm::vector<size_t> * sz = NULL)
{
if (has_pack<typename T::value_type>::type::value == true)
{
for (size_t i = 0 ; i < recv_buf.size() ; i++)
{
T unp;
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(recv_buf.get(i).size(),recv_buf.get(i)));
mem.incRef();
Unpacker<T,HeapMemory>::unpack(mem, unp, ps);
// Merge the information
recv.add(unp);
}
}
else
{
for (size_t i = 0 ; i < recv_buf.size() ; i++)
{
// calculate the number of received elements
size_t n_ele = recv_buf.get(i).size() / sizeof(typename T::value_type);
// add the received particles to the vector
PtrMemory * ptr1 = new PtrMemory(recv_buf.get(i).getPointer(),recv_buf.get(i).size());
// create vector representation to a piece of memory already allocated
openfpm::vector<typename T::value_type,PtrMemory,typename memory_traits_lin<typename T::value_type>::type, memory_traits_lin,openfpm::grow_policy_identity> v2;
v2.setMemory(*ptr1);
// resize with the number of elements
v2.resize(n_ele);
// Merge the information
recv.add(v2);
if (sz != NULL)
sz->get(i) = v2.size();
}
}
}
};
...
...
@@ -109,30 +214,10 @@ template<typename T, typename S> void process_receive_buffer(S & recv, openfpm::
{
if (sz != NULL)
sz->resize(recv_buf.size());
Unpack_stat ps;
for (size_t i = 0 ; i < recv_buf.size() ; i++)
{
// for each received buffer create a memory reppresentation
// calculate the number of received elements
size_t n_ele = recv_buf.get(i).size() / sizeof(typename T::value_type);
// add the received particles to the vector
PtrMemory * ptr1 = new PtrMemory(recv_buf.get(i).getPointer(),recv_buf.get(i).size());
// create vector representation to a piece of memory already allocated
openfpm::vector<typename T::value_type,PtrMemory,typename memory_traits_lin<typename T::value_type>::type, memory_traits_lin,openfpm::grow_policy_identity> v2;
v2.setMemory(*ptr1);
// resize with the number of elements
v2.resize(n_ele);
// Merge the information
recv.add(v2);
if (sz != NULL)
sz->get(i) = v2.size();
}
pack_unpack_cond<has_max_prop<T, has_value_type<T>::value>::value, T, S>::unpacking(recv, recv_buf, ps, sz);
}
public:
...
...
@@ -209,10 +294,11 @@ 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)
{
std::cout << "Inside root " << root << std::endl;
// send buffer (master does not send anything) so send req and send_buf
// remain buffer with size 0
openfpm::vector<size_t> send_req;
...
...
@@ -224,15 +310,15 @@ template<typename T, typename S> bool SGather(T & send, S & recv, openfpm::vecto
sendrecvMultipleMessagesNBX(send_req.size(),NULL,NULL,NULL,msg_alloc,&bi);
// Convert the received byte into number of elements
for (size_t i = 0 ; i < sz.size() ; i++)
sz.get(i) /= sizeof(typename T::value_type);
/*
for (size_t i = 0 ; i < sz.size() ; i++)
sz.get(i) /= sizeof(typename T::value_type);
*/
// process the received information
process_receive_buffer<T,S>(recv,&sz);
recv.add(send);
prc.add(root);
sz.add(send.size()
*sizeof(typename T::value_type)
);
sz.add(send.size());
}
else
{
...
...
@@ -240,22 +326,29 @@ 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);
pack_unpack_cond<has_max_prop<T, has_value_type<T>::value>::value, T, S>::packingRequest(send, tot_size);
HeapMemory pmem;
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(tot_size,pmem));
mem.incRef();
//Packing
Pack_stat sts;
pack_unpack_cond<has_max_prop<T, has_value_type<T>::value>::value, T, S>::packing(mem, send, sts);
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(tot_size);
send_buf.add(mem.getPointer());
openfpm::vector<size_t> sz;
sz.add(send.size());
// receive information
base_info bi(NULL,prc,sz);
...
...
src/VCluster_semantic_unit_tests.hpp
View file @
4d0157c1
...
...
@@ -357,7 +357,83 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_sendrecv)
}
}
BOOST_AUTO_TEST_CASE
(
Vcluster_semantic_gather_ptst
)
BOOST_AUTO_TEST_CASE
(
Vcluster_semantic_gather_test
)
{
Vcluster
&
vcl
=
create_vcluster
();
if
(
vcl
.
getProcessingUnits
()
>=
32
)
return
;
openfpm
::
vector
<
size_t
>
v1
;
v1
.
resize
(
vcl
.
getProcessUnitID
());
for
(
size_t
i
=
0
;
i
<
vcl
.
getProcessUnitID
()
;
i
++
)
v1
.
get
(
i
)
=
5
;
openfpm
::
vector
<
size_t
>
v2
;
vcl
.
SGather
(
v1
,
v2
,
0
);
if
(
vcl
.
getProcessUnitID
()
==
0
)
{
size_t
n
=
vcl
.
getProcessingUnits
();
BOOST_REQUIRE_EQUAL
(
v2
.
size
(),
n
*
(
n
-
1
)
/
2
);
std
::
cout
<<
v2
.
size
()
<<
std
::
endl
;
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_gather_test_2
)
{
Vcluster
&
vcl
=
create_vcluster
();
if
(
vcl
.
getProcessingUnits
()
>=
32
)
return
;
openfpm
::
vector
<
size_t
>
v1
;
v1
.
resize
(
vcl
.
getProcessUnitID
());
for
(
size_t
i
=
0
;
i
<
vcl
.
getProcessUnitID
()
;
i
++
)
v1
.
get
(
i
)
=
5
;
openfpm
::
vector
<
openfpm
::
vector
<
size_t
>>
v2
;
vcl
.
SGather
(
v1
,
v2
,
0
);
if
(
vcl
.
getProcessUnitID
()
==
0
)
{
size_t
n
=
vcl
.
getProcessingUnits
();
BOOST_REQUIRE_EQUAL
(
v2
.
size
(),
n
);
std
::
cout
<<
v2
.
size
()
<<
std
::
endl
;
/* for (size_t i = 0 ; i < v2.size() ; i++)
{
for (size_t j = 0 ; j < v2.get(i).size() ; j++)
{
int m = v2.get(i).get(j);
BOOST_REQUIRE_EQUAL(m,5);
}
}*/
for
(
size_t
i
=
0
;
i
<
v2
.
size
()
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
v2
.
get
(
i
).
size
()
;
j
++
)
{
std
::
cout
<<
v2
.
get
(
i
).
get
(
j
)
<<
" "
<<
std
::
endl
;
}
std
::
cout
<<
"Size is "
<<
v2
.
get
(
i
).
size
()
<<
" "
<<
std
::
endl
;
}
}
}
BOOST_AUTO_TEST_CASE
(
Vcluster_semantic_gather_test_3
)
{
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
...
...
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