Commit f551f4b7 authored by incardon's avatar incardon

Latest changes

parent a9991812
......@@ -43,9 +43,13 @@ class Vcluster: public Vcluster_base
struct index_gen<index_tuple<prp...>>
{
//! Process the receive buffer
template<typename op, typename T, typename S> inline static void process_recv(Vcluster & vcl, S & recv, openfpm::vector<size_t> * sz_recv, openfpm::vector<size_t> * sz_recv_byte, op & op_param)
template<typename op,
typename T,
typename S,
template <typename> class layout_base = memory_traits_lin>
inline static void process_recv(Vcluster & vcl, S & recv, openfpm::vector<size_t> * sz_recv, openfpm::vector<size_t> * sz_recv_byte, op & op_param)
{
vcl.process_receive_buffer_with_prp<op,T,S,prp...>(recv,sz_recv,sz_recv_byte,op_param);
vcl.process_receive_buffer_with_prp<op,T,S,layout_base,prp...>(recv,sz_recv,sz_recv_byte,op_param);
}
};
......@@ -67,7 +71,7 @@ class Vcluster: public Vcluster_base
* \param opt Options using RECEIVE_KNOWN enable patters with less latencies, in case of RECEIVE_KNOWN
*
*/
template<typename op, typename T, typename S> void prepare_send_buffer(openfpm::vector<T> & send,
template<typename op, typename T, typename S, template <typename> class layout_base> void prepare_send_buffer(openfpm::vector<T> & send,
S & recv,
openfpm::vector<size_t> & prc_send,
openfpm::vector<size_t> & prc_recv,
......@@ -97,7 +101,7 @@ class Vcluster: public Vcluster_base
size_t req = 0;
//Pack requesting
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op, T, S>::packingRequest(send.get(i), req, send_sz_byte);
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op, T, S, layout_base>::packingRequest(send.get(i), req, send_sz_byte);
tot_size += req;
}
......@@ -112,7 +116,7 @@ class Vcluster: public Vcluster_base
Pack_stat sts;
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value, op, T, S>::packing(mem, send.get(i), sts, send_buf);
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value, op, T, S, layout_base>::packing(mem, send.get(i), sts, send_buf);
}
// receive information
......@@ -265,7 +269,7 @@ class Vcluster: public Vcluster_base
* \param op_param operation to do in merging the received information with recv
*
*/
template<typename op, typename T, typename S, unsigned int ... prp >
template<typename op, typename T, typename S, template <typename> class layout_base ,unsigned int ... prp >
void process_receive_buffer_with_prp(S & recv,
openfpm::vector<size_t> * sz,
openfpm::vector<size_t> * sz_byte,
......@@ -274,7 +278,7 @@ class Vcluster: public Vcluster_base
if (sz != NULL)
sz->resize(recv_buf.size());
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op, T, S, prp... >::unpacking(recv, recv_buf, sz, sz_byte, op_param);
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op, T, S, layout_base, prp... >::unpacking(recv, recv_buf, sz, sz_byte, op_param);
}
public:
......@@ -359,11 +363,14 @@ class Vcluster: public Vcluster_base
* \return true if the function completed succefully
*
*/
template<typename T, typename S> bool SGather(T & send,
S & recv,
openfpm::vector<size_t> & prc,
openfpm::vector<size_t> & sz,
size_t root)
template<typename T,
typename S,
template <typename> class layout_base = memory_traits_lin>
bool SGather(T & send,
S & recv,
openfpm::vector<size_t> & prc,
openfpm::vector<size_t> & sz,
size_t root)
{
#ifdef SE_CLASS1
if (&send == (T *)&recv)
......@@ -392,7 +399,7 @@ class Vcluster: public Vcluster_base
// operation object
op_ssend_recv_add<void> opa;
index_gen<ind_prop_to_pack>::template process_recv<op_ssend_recv_add<void>,T,S>(*this,recv,&sz,NULL,opa);
index_gen<ind_prop_to_pack>::template process_recv<op_ssend_recv_add<void>,T,S,layout_base>(*this,recv,&sz,NULL,opa);
recv.add(send);
prc.add(root);
......@@ -413,7 +420,7 @@ class Vcluster: public Vcluster_base
size_t tot_size = 0;
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op_ssend_recv_add<void>, T, S>::packingRequest(send, tot_size, sz);
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op_ssend_recv_add<void>, T, S, layout_base>::packingRequest(send, tot_size, sz);
HeapMemory pmem;
......@@ -424,7 +431,7 @@ class Vcluster: public Vcluster_base
Pack_stat sts;
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op_ssend_recv_add<void>, T, S>::packing(mem, send, sts, send_buf);
pack_unpack_cond_with_prp<has_max_prop<T, has_value_type<T>::value>::value,op_ssend_recv_add<void>, T, S, layout_base>::packing(mem, send, sts, send_buf);
// receive information
base_info bi(NULL,prc,sz);
......@@ -620,21 +627,24 @@ class Vcluster: public Vcluster_base
* \return true if the function completed succefully
*
*/
template<typename T, typename S> 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)
template<typename T,
typename S,
template <typename> class layout_base = memory_traits_lin>
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)
{
prepare_send_buffer<op_ssend_recv_add<void>,T,S>(send,recv,prc_send,prc_recv,sz_recv,opt);
prepare_send_buffer<op_ssend_recv_add<void>,T,S,layout_base>(send,recv,prc_send,prc_recv,sz_recv,opt);
// we generate the list of the properties to pack
typedef typename ::generate_indexes<int, has_max_prop<T, has_value_type<T>::value>::number, MetaFuncOrd>::result ind_prop_to_pack;
op_ssend_recv_add<void> opa;
index_gen<ind_prop_to_pack>::template process_recv<op_ssend_recv_add<void>,T,S>(*this,recv,&sz_recv,NULL,opa);
index_gen<ind_prop_to_pack>::template process_recv<op_ssend_recv_add<void>,T,S,layout_base>(*this,recv,&sz_recv,NULL,opa);
return true;
}
......@@ -668,20 +678,20 @@ class Vcluster: public Vcluster_base
* \return true if the function completed successful
*
*/
template<typename T, typename S, int ... prp> bool SSendRecvP(openfpm::vector<T> & send,
template<typename T, typename S, template <typename> class layout_base, int ... prp> bool SSendRecvP(openfpm::vector<T> & send,
S & recv,
openfpm::vector<size_t> & prc_send,
openfpm::vector<size_t> & prc_recv,
openfpm::vector<size_t> & sz_recv,
openfpm::vector<size_t> & sz_recv_byte)
{
prepare_send_buffer<op_ssend_recv_add<void>,T,S>(send,recv,prc_send,prc_recv,sz_recv,NONE);
prepare_send_buffer<op_ssend_recv_add<void>,T,S,layout_base>(send,recv,prc_send,prc_recv,sz_recv,NONE);
// operation object
op_ssend_recv_add<void> opa;
// process the received information
process_receive_buffer_with_prp<op_ssend_recv_add<void>,T,S,prp...>(recv,&sz_recv,&sz_recv_byte,opa);
process_receive_buffer_with_prp<op_ssend_recv_add<void>,T,S,layout_base,prp...>(recv,&sz_recv,&sz_recv_byte,opa);
return true;
}
......@@ -714,19 +724,20 @@ class Vcluster: public Vcluster_base
* \return true if the function completed succefully
*
*/
template<typename T, typename S, int ... prp> bool SSendRecvP(openfpm::vector<T> & send,
S & recv,
openfpm::vector<size_t> & prc_send,
openfpm::vector<size_t> & prc_recv,
openfpm::vector<size_t> & sz_recv)
template<typename T, typename S, template <typename> class layout_base, int ... prp>
bool SSendRecvP(openfpm::vector<T> & send,
S & recv,
openfpm::vector<size_t> & prc_send,
openfpm::vector<size_t> & prc_recv,
openfpm::vector<size_t> & sz_recv)
{
prepare_send_buffer<op_ssend_recv_add<void>,T,S>(send,recv,prc_send,prc_recv,sz_recv,NONE);
prepare_send_buffer<op_ssend_recv_add<void>,T,S,layout_base>(send,recv,prc_send,prc_recv,sz_recv,NONE);
// operation object
op_ssend_recv_add<void> opa;
// process the received information
process_receive_buffer_with_prp<op_ssend_recv_add<void>,T,S,prp...>(recv,&sz_recv,NULL,opa);
process_receive_buffer_with_prp<op_ssend_recv_add<void>,T,S,layout_base,prp...>(recv,&sz_recv,NULL,opa);
return true;
}
......@@ -767,18 +778,23 @@ class Vcluster: public Vcluster_base
* \return true if the function completed successful
*
*/
template<typename op, typename T, typename S, int ... prp> bool SSendRecvP_op(openfpm::vector<T> & send,
S & recv,
openfpm::vector<size_t> & prc_send,
op & op_param,
openfpm::vector<size_t> & prc_recv,
openfpm::vector<size_t> & recv_sz,
size_t opt = NONE)
template<typename op,
typename T,
typename S,
template <typename> class layout_base,
int ... prp>
bool SSendRecvP_op(openfpm::vector<T> & send,
S & recv,
openfpm::vector<size_t> & prc_send,
op & op_param,
openfpm::vector<size_t> & prc_recv,
openfpm::vector<size_t> & recv_sz,
size_t opt = NONE)
{
prepare_send_buffer<op,T,S>(send,recv,prc_send,prc_recv,recv_sz,opt);
prepare_send_buffer<op,T,S,layout_base>(send,recv,prc_send,prc_recv,recv_sz,opt);
// process the received information
process_receive_buffer_with_prp<op,T,S,prp...>(recv,NULL,NULL,op_param);
process_receive_buffer_with_prp<op,T,S,layout_base,prp...>(recv,NULL,NULL,op_param);
return true;
}
......
......@@ -14,7 +14,14 @@
template<bool result, typename T, typename S>
struct unpack_selector_with_prp
{
template<typename op, int ... prp> static void call_unpack(S & recv, openfpm::vector<BHeapMemory> & recv_buf, openfpm::vector<size_t> * sz, openfpm::vector<size_t> * sz_byte, op & op_param)
template<typename op,
template <typename> class layout_base,
int ... prp>
static void call_unpack(S & recv,
openfpm::vector<BHeapMemory> & recv_buf,
openfpm::vector<size_t> * sz,
openfpm::vector<size_t> * sz_byte,
op & op_param)
{
if (sz_byte != NULL)
sz_byte->resize(recv_buf.size());
......@@ -33,7 +40,7 @@ struct unpack_selector_with_prp
size_t recv_size_old = recv.size();
// Merge the information
op_param.template execute<true,T,decltype(recv),decltype(unp),prp...>(recv,unp,i);
op_param.template execute<true,T,decltype(recv),decltype(unp),layout_base,prp...>(recv,unp,i);
size_t recv_size_new = recv.size();
......@@ -52,7 +59,10 @@ struct unpack_selector_with_prp
template<typename T, typename S>
struct unpack_selector_with_prp<true,T,S>
{
template<typename op, unsigned int ... prp> static void call_unpack(S & recv, openfpm::vector<BHeapMemory> & recv_buf, openfpm::vector<size_t> * sz, openfpm::vector<size_t> * sz_byte, op & op_param)
template<typename op,
template <typename> class layout_base,
unsigned int ... prp>
static void call_unpack(S & recv, openfpm::vector<BHeapMemory> & recv_buf, openfpm::vector<size_t> * sz, openfpm::vector<size_t> * sz_byte, op & op_param)
{
if (sz_byte != NULL)
sz_byte->resize(recv_buf.size());
......@@ -77,7 +87,7 @@ struct unpack_selector_with_prp<true,T,S>
size_t recv_size_old = recv.size();
op_param.template execute<false,T,decltype(recv),decltype(v2),prp...>(recv,v2,i);
op_param.template execute<false,T,decltype(recv),decltype(v2),memory_traits_lin,prp...>(recv,v2,i);
size_t recv_size_new = recv.size();
......@@ -106,16 +116,29 @@ struct call_serialize_variadic<index_tuple<prp...>>
Packer<T,HeapMemory>::template pack<prp...>(mem,send,sts);
}
template<typename op, typename T, typename S> inline static void call_unpack(S & recv, openfpm::vector<BHeapMemory> & recv_buf, openfpm::vector<size_t> * sz, openfpm::vector<size_t> * sz_byte, op & op_param)
template<typename op,
typename T,
typename S,
template <typename> class layout_base>
inline static void call_unpack(S & recv,
openfpm::vector<BHeapMemory> & recv_buf,
openfpm::vector<size_t> * sz,
openfpm::vector<size_t> * sz_byte,
op & op_param)
{
const bool result = has_pack_gen<typename T::value_type>::value == false && is_vector<T>::value == true;
unpack_selector_with_prp<result, T, S>::template call_unpack<op,prp...>(recv, recv_buf, sz, sz_byte, op_param);
unpack_selector_with_prp<result, T, S>::template call_unpack<op,layout_base,prp...>(recv, recv_buf, sz, sz_byte, op_param);
}
};
//! There is max_prop inside
template<bool cond, typename op, typename T, typename S, unsigned int ... prp>
template<bool cond,
typename op,
typename T,
typename S,
template <typename> class layout_base,
unsigned int ... prp>
struct pack_unpack_cond_with_prp
{
static void packingRequest(T & send, size_t & tot_size, openfpm::vector<size_t> & sz)
......@@ -150,10 +173,14 @@ struct pack_unpack_cond_with_prp
}
}
static void unpacking(S & recv, openfpm::vector<BHeapMemory> & recv_buf, openfpm::vector<size_t> * sz, openfpm::vector<size_t> * sz_byte, op & op_param)
static void unpacking(S & recv,
openfpm::vector<BHeapMemory> & recv_buf,
openfpm::vector<size_t> * sz,
openfpm::vector<size_t> * sz_byte,
op & op_param)
{
typedef index_tuple<prp...> ind_prop_to_pack;
call_serialize_variadic<ind_prop_to_pack>::template call_unpack<op,T,S>(recv, recv_buf, sz, sz_byte, op_param);
call_serialize_variadic<ind_prop_to_pack>::template call_unpack<op,T,S,layout_base>(recv, recv_buf, sz, sz_byte, op_param);
}
};
......@@ -165,10 +192,19 @@ template<bool sr>
struct op_ssend_recv_add_sr
{
//! Add data
template<typename T, typename D, typename S, int ... prp> static void execute(D & recv,S & v2, size_t i)
template<typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp> static void execute(D & recv,S & v2, size_t i)
{
// Merge the information
recv.template add_prp<typename T::value_type,PtrMemory,openfpm::grow_policy_identity,openfpm::vect_isel<typename T::value_type>::value,prp...>(v2);
recv.template add_prp<typename T::value_type,
PtrMemory,
openfpm::grow_policy_identity,
openfpm::vect_isel<typename T::value_type>::value,
layout_base,
prp...>(v2);
}
};
......@@ -177,10 +213,20 @@ template<>
struct op_ssend_recv_add_sr<true>
{
//! Add data
template<typename T, typename D, typename S, int ... prp> static void execute(D & recv,S & v2, size_t i)
template<typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp>
static void execute(D & recv,S & v2, size_t i)
{
// Merge the information
recv.template add_prp<typename T::value_type,HeapMemory,openfpm::grow_policy_double,openfpm::vect_isel<typename T::value_type>::value, prp...>(v2);
recv.template add_prp<typename T::value_type,
HeapMemory,
openfpm::grow_policy_double,
openfpm::vect_isel<typename T::value_type>::value,
layout_base,
prp...>(v2);
}
};
......@@ -189,10 +235,16 @@ template<typename op>
struct op_ssend_recv_add
{
//! Add data
template<bool sr, typename T, typename D, typename S, int ... prp> static void execute(D & recv,S & v2, size_t i)
template<bool sr,
typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp>
static void execute(D & recv,S & v2, size_t i)
{
// Merge the information
op_ssend_recv_add_sr<sr>::template execute<T,D,S,prp...>(recv,v2,i);
op_ssend_recv_add_sr<sr>::template execute<T,D,S,layout_base,prp...>(recv,v2,i);
}
};
......@@ -201,10 +253,20 @@ template<bool sr,template<typename,typename> class op>
struct op_ssend_recv_merge_impl
{
//! Merge the
template<typename T, typename D, typename S, int ... prp> inline static void execute(D & recv,S & v2,size_t i,openfpm::vector<openfpm::vector<aggregate<size_t,size_t>>> & opart)
template<typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp>
inline static void execute(D & recv,S & v2,size_t i,openfpm::vector<openfpm::vector<aggregate<size_t,size_t>>> & opart)
{
// Merge the information
recv.template merge_prp_v<op,typename T::value_type, PtrMemory, openfpm::grow_policy_identity, prp...>(v2,opart.get(i));
recv.template merge_prp_v<op,
typename T::value_type,
PtrMemory,
openfpm::grow_policy_identity,
layout_base,
prp...>(v2,opart.get(i));
}
};
......@@ -213,10 +275,20 @@ template<template<typename,typename> class op>
struct op_ssend_recv_merge_impl<true,op>
{
//! merge the data
template<typename T, typename D, typename S, int ... prp> inline static void execute(D & recv,S & v2,size_t i,openfpm::vector<openfpm::vector<aggregate<size_t,size_t>>> & opart)
template<typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp>
inline static void execute(D & recv,S & v2,size_t i,openfpm::vector<openfpm::vector<aggregate<size_t,size_t>>> & opart)
{
// Merge the information
recv.template merge_prp_v<op,typename T::value_type, HeapMemory, openfpm::grow_policy_double, prp...>(v2,opart.get(i));
recv.template merge_prp_v<op,
typename T::value_type,
HeapMemory,
openfpm::grow_policy_double,
layout_base,
prp...>(v2,opart.get(i));
}
};
......@@ -233,9 +305,15 @@ struct op_ssend_recv_merge
{}
//! execute the merge
template<bool sr, typename T, typename D, typename S, int ... prp> void execute(D & recv,S & v2,size_t i)
template<bool sr,
typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp>
void execute(D & recv,S & v2,size_t i)
{
op_ssend_recv_merge_impl<sr,op>::template execute<T,D,S,prp...>(recv,v2,i,opart);
op_ssend_recv_merge_impl<sr,op>::template execute<T,D,S,layout_base,prp...>(recv,v2,i,opart);
}
};
......@@ -244,10 +322,20 @@ template<bool sr>
struct op_ssend_gg_recv_merge_impl
{
//! Merge the
template<typename T, typename D, typename S, int ... prp> inline static void execute(D & recv,S & v2,size_t i,size_t & start)
template<typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp>
inline static void execute(D & recv,S & v2,size_t i,size_t & start)
{
// Merge the information
recv.template merge_prp_v<replace_,typename T::value_type, PtrMemory, openfpm::grow_policy_identity, prp...>(v2,start);
recv.template merge_prp_v<replace_,
typename T::value_type,
PtrMemory,
openfpm::grow_policy_identity,
layout_base,
prp...>(v2,start);
start += v2.size();
}
......@@ -258,10 +346,19 @@ template<>
struct op_ssend_gg_recv_merge_impl<true>
{
//! merge the data
template<typename T, typename D, typename S, int ... prp> inline static void execute(D & recv,S & v2,size_t i,size_t & start)
template<typename T,
typename D,
typename S,
template <typename> class layout_base,
int ... prp> inline static void execute(D & recv,S & v2,size_t i,size_t & start)
{
// Merge the information
recv.template merge_prp_v<replace_,typename T::value_type, HeapMemory, openfpm::grow_policy_double, prp...>(v2,start);
recv.template merge_prp_v<replace_,
typename T::value_type,
HeapMemory,
openfpm::grow_policy_double,
layout_base,
prp...>(v2,start);
// from
start += v2.size();
......@@ -280,9 +377,9 @@ struct op_ssend_gg_recv_merge
{}
//! execute the merge
template<bool sr, typename T, typename D, typename S, int ... prp> void execute(D & recv,S & v2,size_t i)
template<bool sr, typename T, typename D, typename S, template <typename> class layout_base, int ... prp> void execute(D & recv,S & v2,size_t i)
{
op_ssend_gg_recv_merge_impl<sr>::template execute<T,D,S,prp...>(recv,v2,i,start);
op_ssend_gg_recv_merge_impl<sr>::template execute<T,D,S,layout_base,prp...>(recv,v2,i,start);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment