8 #ifndef SRC_GRID_GRID_DIST_ID_COMM_HPP_ 9 #define SRC_GRID_GRID_DIST_ID_COMM_HPP_ 11 #include "Vector/vector_dist_ofb.hpp" 12 #include "Grid/copy_grid_fast.hpp" 13 #include "grid_dist_util.hpp" 14 #include "util/common_pdata.hpp" 15 #include "lib/pdata.hpp" 22 template<
bool result,
typename T,
typename device_gr
id,
typename Memory>
35 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error: complex properties on grids are not supported yet" << std::endl;
43 template<
typename T,
typename device_gr
id,
typename Memory>
55 template<
template<
typename,
typename>
class op,
typename sub_it_type,
unsigned int ... prp>
61 gd.template unpack_with_op<op,Memory,prp ...>(recv_buf,sub2,ps);
70 template<
typename device_gr
id,
typename Memory,
typename T>
78 template<
typename device_grid,
typename Memory ,
int ... prp>
90 template<
template<
typename,
typename>
class op,
typename sub_it_type,
typename T>
107 template<
template<
typename,
typename>
class op,
typename T,
typename device_grid,
typename Memory>
139 template<
unsigned int dim,
typename St,
typename T,
typename Decomposition = CartDecomposition<dim,St>,
typename Memory=HeapMemory ,
typename device_gr
id=gr
id_cpu<dim,T> >
171 bool operator<(
const rp_id & tmp)
const 173 return p_id < tmp.p_id;
198 int n_headers_slot = 1;
219 std::unordered_map<size_t,size_t> & g_id_to_external_ghost_box,
224 rem_copy_opt opt_ = rem_copy_opt::NONE_OPT;
225 if (
opt & SKIP_LABELLING)
226 {opt_ = rem_copy_opt::KEEP_GEOMETRY;}
228 if (opt_ != rem_copy_opt::KEEP_GEOMETRY)
230 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
231 {loc_grid.get(i).copyRemoveReset();}
238 for (
size_t i = 0 ; i < loc_ig_box.size() ; i++)
241 for (
size_t j = 0 ; j < loc_ig_box.get(i).bid.size() ; j++)
243 size_t sub_id_src_gdb_ext = loc_ig_box.get(i).bid.get(j).sub_gdb_ext;
246 size_t sub_id_dst = loc_ig_box.get(i).bid.get(j).sub;
249 for (
size_t v = 0 ; v < loc_ig_box.get(i).bid.get(j).k.size() ; v++)
251 size_t k = loc_ig_box.get(i).bid.get(j).k.get(v);
256 size_t sub_id_dst_gdb_ext = loc_eg_box.get(sub_id_dst).bid.get(k).sub_gdb_ext;
257 bx_dst -= gdb_ext.get(sub_id_dst_gdb_ext).origin;
264 Box<dim,long int> bx_src = flip_box(loc_eg_box.get(sub_id_dst).bid.get(k).ebox,loc_eg_box.get(sub_id_dst).bid.get(k).cmb,ginfo);
265 bx_src -= gdb_ext.get(sub_id_src_gdb_ext).origin;
269 if (use_bx_def ==
false)
271 if (loc_eg_box.get(sub_id_dst).bid.get(k).sub != i)
272 {std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" source and destination are not correctly linked" <<
"\n";}
276 {std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" source and destination does not match in size" <<
"\n";}
280 auto & gd = loc_grid.get(sub_id_dst_gdb_ext);
283 gd.copy_to(loc_grid.get(sub_id_src_gdb_ext),bx_src,bx_dst);
288 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
290 loc_grid.get(i).template removeCopyToFinalize<prp ...>(
v_cl.
getmgpuContext(), rem_copy_opt::PHASE1 | opt_);
293 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
295 loc_grid.get(i).template removeCopyToFinalize<prp ...>(
v_cl.
getmgpuContext(), rem_copy_opt::PHASE2 | opt_);
298 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
300 loc_grid.get(i).template removeCopyToFinalize<prp ...>(
v_cl.
getmgpuContext(), rem_copy_opt::PHASE3 | opt_);
319 openfpm::vector<std::unordered_map<size_t,size_t>> & g_id_to_external_ghost_box)
322 for (
size_t i = 0 ; i < loc_eg_box.size() ; i++)
325 for (
size_t j = 0 ; j < loc_eg_box.get(i).bid.size() ; j++)
327 if (loc_eg_box.get(i).bid.get(j).initialized ==
false)
332 bx_src -= gdb_ext.get(i).origin;
335 size_t sub_id_dst = loc_eg_box.get(i).bid.get(j).sub;
338 size_t k = loc_eg_box.get(i).bid.get(j).k;
343 bx_dst -= gdb_ext.get(sub_id_dst).origin;
352 if (loc_ig_box.get(sub_id_dst).bid.get(k).sub != i)
353 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" source and destination are not correctly linked" <<
"\n";
356 {std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" source and destination does not match in size" <<
"\n";}
360 auto & gd2 = loc_grid.get(sub_id_dst);
361 gd2.template copy_to_op<op,prp...>(loc_grid.get(i),bx_src,bx_dst);
375 void send_or_queue(
size_t prc,
char * pointer,
char * pointer2)
377 if (device_grid::isCompressed() ==
false)
378 {
v_cl.
send(prc,0,pointer,(
char *)pointer2 - (
char *)pointer);}
387 static void * receive_dynamic(
size_t msg_i ,
size_t total_msg,
size_t total_p,
size_t i,
size_t ri,
size_t tag,
void * ptr)
398 if (gd->
opt & RUN_ON_DEVICE)
412 template <
typename prp_
object>
414 std::vector<size_t> & prp_recv,
418 cudaDeviceSynchronize();
421 if (device_grid::isCompressed() ==
false)
424 for (
size_t i = 0 ; i < eg_box.size() ; i++ )
426 prp_recv.push_back(eg_box.get(i).recv_pnt *
sizeof(prp_object) +
sizeof(
size_t)*eg_box.get(i).n_r_box);
435 for (
size_t i = 0 ; i < eg_box.size() ; i++ )
449 receive_dynamic,
this);
455 receive_dynamic,
this);
465 for (
int i = 0 ; i <
recv_proc.size() ; i++)
482 template <
typename prp_
object>
484 std::vector<size_t> & prp_recv,
487 if (device_grid::isCompressed() ==
false)
490 for (
size_t i = 0 ; i < ig_box.size() ; i++ )
492 prp_recv.push_back(0);
495 for (
size_t j = 0 ; j < ig_box.get(i).bid.size() ; j++)
499 prp_recv[prp_recv.size()-1] += g_ig_box.
getVolumeKey() *
sizeof(prp_object) +
sizeof(
size_t);
511 for (
size_t i = 0 ; i < ig_box.size() ; i++ )
527 receive_dynamic,
this);
533 receive_dynamic,
this);
538 template<
typename mem,
unsigned ... prp>
543 const std::unordered_map<size_t,size_t> & g_id_to_external_ghost_box,
552 if (
opt & RUN_ON_DEVICE)
558 auto key = g_id_to_external_ghost_box.find(g_id);
560 if (key != g_id_to_external_ghost_box.end())
561 {l_id = key->second;}
570 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" Critical, cannot unpack object, because received data cannot be interpreted\n";
579 size_t le_id = eb_gid_list.get(l_id).full_match;
580 size_t ei = eb_gid_list.get(l_id).e_id;
584 size_t sub_id = eg_box.get(ei).bid.get(le_id).sub;
587 auto sub2 = loc_grid.get(sub_id).getIterator(box.
getKP1(),box.
getKP2(),
false);
589 rem_copy_opt opt_ = rem_copy_opt::NONE_OPT;
590 if (
opt & SKIP_LABELLING)
591 {opt_ = rem_copy_opt::KEEP_GEOMETRY;}
594 loc_grid.get(sub_id).remove(box);
598 for (
long int j = 0 ; j < (
long int)eb_gid_list.get(l_id).eb_list.size() ; j++)
600 size_t nle_id = eb_gid_list.get(l_id).eb_list.get(j);
604 size_t n_sub_id = eg_box.get(ei).bid.get(nle_id).sub;
609 loc_grid.get(n_sub_id).remove(box);
610 loc_grid.get(n_sub_id).copy_to(loc_grid.get(sub_id),rbox,box);
615 template<
typename mem,
typename header_type,
unsigned ... prp>
618 header_type & headers,
621 const std::unordered_map<size_t,size_t> & g_id_to_external_ghost_box,
630 g_id = headers.template get<0>(i);
635 auto key = g_id_to_external_ghost_box.find(g_id);
637 if (key != g_id_to_external_ghost_box.end())
638 {l_id = key->second;}
647 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" Critical, cannot unpack object, because received data cannot be interpreted\n";
656 size_t le_id = eb_gid_list.get(l_id).full_match;
657 size_t ei = eb_gid_list.get(l_id).e_id;
661 size_t sub_id = eg_box.get(ei).bid.get(le_id).sub;
664 auto sub2 = loc_grid.get(sub_id).getIterator(box.
getKP1(),box.
getKP2(),
false);
666 rem_copy_opt opt_ = rem_copy_opt::NONE_OPT;
667 if (
opt & SKIP_LABELLING)
668 {opt_ = rem_copy_opt::KEEP_GEOMETRY;}
671 loc_grid.get(sub_id).remove(box);
675 loc_grid.get(sub_id),
683 for (
long int j = 0 ; j < (
long int)eb_gid_list.get(l_id).eb_list.size() ; j++)
685 size_t nle_id = eb_gid_list.get(l_id).eb_list.get(j);
689 size_t n_sub_id = eg_box.get(ei).bid.get(nle_id).sub;
694 loc_grid.get(n_sub_id).remove(box);
695 loc_grid.get(n_sub_id).copy_to(loc_grid.get(sub_id),rbox,box);
700 template<
unsigned int ... prp>
701 void fill_headers(
size_t opt)
703 if ((
opt & KEEP_PROPERTIES) == 0 && device_grid::is_unpack_header_supported())
708 result.allocate(
sizeof(
int));
725 *(
int *)result.getPointer() = 0;
726 result.hostToDevice();
728 device_grid::template unpack_headers<decltype(
pointers_h),decltype(headers),decltype(result),prp ...>(
pointers_h,headers,result,n_headers_slot);
729 result.deviceToHost();
731 if (*(
int *)result.getPointer() == 0) {
break;}
738 headers.template deviceToHost<0,1,2>();
742 template<
unsigned ... prp>
745 const std::vector<size_t> & prp_recv,
747 const std::unordered_map<size_t,size_t> & g_id_to_external_ghost_box,
751 if (device_grid::isCompressed() ==
false)
759 for (
size_t i = 0 ; i < eg_box.size() ; i++ )
764 while (ps.
getOffset() - mark_here < prp_recv[i])
769 unpack_data_to_ext_ghost<Memory,prp ...>(prRecv_prp,loc_grid,i,
770 eg_box,g_id_to_external_ghost_box,eb_gid_list,
777 fill_headers<prp ...>(
opt);
779 if (headers.size() != 0)
796 unpack_data_to_ext_ghost_with_header<BMemory<Memory>,decltype(headers),prp ...>(mem,loc_grid,headers,i*n_headers_slot+j,
797 eg_box,g_id_to_external_ghost_box,eb_gid_list,
819 unpack_data_to_ext_ghost<BMemory<Memory>,prp ...>(mem,loc_grid,i,
820 eg_box,g_id_to_external_ghost_box,eb_gid_list,
829 template<
template<
typename,
typename>
class op,
unsigned ... prp>
832 const std::vector<size_t> & prp_recv,
835 const openfpm::vector<std::unordered_map<size_t,size_t>> & g_id_to_internal_ghost_box)
837 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
839 if (device_grid::isCompressed() ==
false)
846 for (
size_t i = 0 ; i < ig_box.size() ; i++ )
849 for (
size_t j = 0 ; j < ig_box.get(i).bid.
size() ; j++)
858 auto key = g_id_to_internal_ghost_box.get(i).find(g_id);
859 if (key != g_id_to_internal_ghost_box.get(i).end())
860 {l_id = key->second;}
869 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" Critical, cannot unpack object, because received data cannot be interpreted\n";
876 size_t sub_id = ig_box.get(i).bid.get(l_id).sub;
877 box -= gdb_ext.get(sub_id).origin.template convertPoint<size_t>();
880 auto sub2 = loc_grid.get(sub_id).getIterator(box.
getKP1(),box.
getKP2());
905 size_t pid = dec.ProctoID(
recv_proc.get(i).p_id);
909 auto key = g_id_to_internal_ghost_box.get(pid).find(g_id);
910 if (key != g_id_to_internal_ghost_box.get(pid).end())
911 {l_id = key->second;}
920 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" Critical, cannot unpack object, because received data cannot be interpreted\n";
927 size_t sub_id = ig_box.get(pid).bid.get(l_id).sub;
928 box -= gdb_ext.get(sub_id).origin.template convertPoint<size_t>();
931 auto sub2 = loc_grid.get(sub_id).getIterator(box.
getKP1(),box.
getKP2());
954 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
955 {loc_grid.get(i).clear();}
957 for (
size_t a = 0; a < m_oGrid_recv.size(); a++)
959 for (
size_t k = 0; k < m_oGrid_recv.get(a).size(); k++)
961 device_grid & g = m_oGrid_recv.get(a).template get<0>(k);
966 for (
size_t n = 0; n < dim; n++)
967 {p.
get(n) = g.getGrid().getBox().getHigh(n);}
970 for (
size_t n = 0; n < dim; n++)
971 {point.
get(n) = (b.getHigh(n) + b.getLow(n))/2;}
973 for (
size_t j = 0; j < gdb_ext.
size(); j++)
977 sub += gdb_ext.get(j).origin;
989 for(
size_t i = 0 ; i < dim ; i++)
994 box_src.setHigh(i,stop.
get(i)-start.
get(i));
997 loc_grid.get(j).copy_to(g,box_src,box_dst);
1032 for (
size_t i = 0; i < gdb_ext_old.size(); i++)
1036 sub_dom += gdb_ext_old.get(i).origin;
1038 for (
size_t j = 0; j < gdb_ext_global.
size(); j++)
1047 sub_dom_new += gdb_ext_global.get(j).origin;
1049 bool intersect =
false;
1052 intersect = sub_dom.
Intersect(sub_dom_new, inte_box);
1054 if (intersect ==
true)
1056 auto inte_box_cont = cd_sm.convertCellUnitsIntoDomainSpace(inte_box);
1060 for (
size_t n = 0; n < dim; n++)
1061 p.
get(n) = (inte_box_cont.getHigh(n) + inte_box_cont.getLow(n))/2;
1063 p_id = dec.processorID(p);
1067 auto inte_box_local = inte_box;
1069 inte_box_local -= gdb_ext_old.get(i).origin;
1076 for (
size_t l = 0; l < dim; l++)
1078 sz[l] = inte_box_local.getHigh(l) - inte_box_local.getLow(l) + 1;
1084 gr_send.setMemory();
1093 for(
size_t i = 0 ; i < dim ; i++)
1101 gr_send.copy_to(gr,box_src,box_dst);
1105 aggr.template get<0>() = gr_send;
1106 aggr.template get<1>() = inte_box;
1109 lbl_b.get(p_id).add(aggr);
1161 decltype(
m_oGrid) m_oGrid_new;
1165 {m_oGrid_new.add(
m_oGrid.get(i));}
1198 std::unordered_map<size_t,size_t> & g_id_to_external_ghost_box,
1201 #ifdef PROFILE_SCOREP 1202 SCOREP_USER_REGION(
"ghost_get",SCOREP_USER_REGION_TYPE_FUNCTION)
1206 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
1222 for (
int i = 0 ; i < loc_grid.
size() ; i++)
1223 {
opt &= (loc_grid.get(i).isSkipLabellingPossible())?(
int)-1:~SKIP_LABELLING;}
1225 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 1227 packing_time.
start();
1230 if (!(
opt & SKIP_LABELLING))
1234 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
1235 {loc_grid.get(i).packReset();}
1238 for (
size_t i = 0 ; i < ig_box.size() ; i++ )
1241 for (
size_t j = 0 ; j < ig_box.get(i).bid.
size() ; j++)
1244 size_t sub_id = ig_box.get(i).bid.get(j).sub;
1248 if (g_ig_box.
isValid() ==
false)
1251 g_ig_box -= gdb_ext.get(sub_id).origin.template convertPoint<size_t>();
1256 auto sub_it = loc_grid.get(sub_id).getIterator(g_ig_box.
getKP1(),g_ig_box.
getKP2(),
false);
1264 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
1281 for (
size_t i = 0 ; i < ig_box.size() ; i++ )
1288 if (
opt & RUN_ON_DEVICE)
1294 for (
size_t j = 0 ; j < ig_box.get(i).bid.
size() ; j++)
1297 if (ig_box.get(i).bid.get(j).box.isValid() ==
false)
1301 size_t sub_id = ig_box.get(i).bid.get(j).sub;
1304 g_ig_box -= gdb_ext.get(sub_id).origin.template convertPoint<size_t>();
1306 size_t g_id = ig_box.get(i).bid.get(j).g_id;
1312 auto sub_it = loc_grid.get(sub_id).getIterator(g_ig_box.
getKP1(),g_ig_box.
getKP2(),
false);
1320 if (
opt & RUN_ON_DEVICE)
1326 pointers2.add(pointer2);
1329 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
1331 rem_copy_opt opt_ = rem_copy_opt::NONE_OPT;
1332 if (
opt & SKIP_LABELLING)
1333 {opt_ = rem_copy_opt::KEEP_GEOMETRY;}
1335 loc_grid.get(i).template packFinalize<prp ...>(prAlloc_prp,sts,opt_,
true);
1339 delete &prAlloc_prp;
1349 for (
size_t i = 0 ; i < loc_grid.
size() ; i++)
1351 rem_copy_opt opt_ = rem_copy_opt::NONE_OPT;
1352 if (
opt & SKIP_LABELLING)
1353 {opt_ = rem_copy_opt::KEEP_GEOMETRY;}
1355 loc_grid.get(i).template packFinalize<prp ...>(prAlloc_prp,sts,opt_,
true);
1359 delete &prAlloc_prp;
1362 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 1363 packing_time.
stop();
1364 tot_pack += packing_time.
getwct();
1365 timer sendrecv_time;
1366 sendrecv_time.
start();
1369 for (
size_t i = 0 ; i < ig_box.size() ; i++ )
1372 send_or_queue(ig_box.get(i).prc,(
char *)
pointers.get(i),(
char *)pointers2.get(i));
1376 std::vector<size_t> prp_recv;
1385 queue_recv_data_get<prp_object>(eg_box,prp_recv,prRecv_prp);
1387 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 1388 sendrecv_time.
stop();
1389 tot_sendrecv += sendrecv_time.
getwct();
1390 timer merge_loc_time;
1391 merge_loc_time.
start();
1394 ghost_get_local<prp...>(loc_ig_box,loc_eg_box,gdb_ext,loc_grid,g_id_to_external_ghost_box,ginfo,use_bx_def,
opt);
1396 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 1397 merge_loc_time.
stop();
1398 tot_loc_merge += merge_loc_time.
getwct();
1403 for (
size_t i = 0 ; i < loc_grid.size() ; i++)
1404 {loc_grid.get(i).removeAddUnpackReset();}
1406 merge_received_data_get<prp ...>(loc_grid,eg_box,prp_recv,prRecv_prp,g_id_to_external_ghost_box,eb_gid_list,
opt);
1408 rem_copy_opt opt_ = rem_copy_opt::NONE_OPT;
1409 if (
opt & SKIP_LABELLING)
1410 {opt_ = rem_copy_opt::KEEP_GEOMETRY;}
1412 for (
size_t i = 0 ; i < loc_grid.size() ; i++)
1413 {loc_grid.get(i).template removeAddUnpackFinalize<prp ...>(
v_cl.
getmgpuContext(),opt_);}
1415 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 1417 tot_merge += merge_time.
getwct();
1420 prRecv_prp.decRef();
1438 template<
template<
typename,
typename>
class op,
int... prp>
1446 openfpm::vector<std::unordered_map<size_t,size_t>> & g_id_to_internal_ghost_box)
1449 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
1460 for (
size_t i = 0 ; i < eg_box.size() ; i++ )
1463 for (
size_t j = 0 ; j < eg_box.get(i).bid.
size() ; j++)
1466 size_t sub_id = eg_box.get(i).bid.get(j).sub;
1470 if (g_eg_box.
isValid() ==
false)
1473 g_eg_box -= gdb_ext.get(sub_id).origin.template convertPoint<size_t>();
1479 auto sub_it = loc_grid.get(sub_id).getIterator(g_eg_box.
getKP1(),g_eg_box.
getKP2());
1498 for (
size_t i = 0 ; i < eg_box.size() ; i++ )
1505 for (
size_t j = 0 ; j < eg_box.get(i).bid.
size() ; j++)
1508 if (eg_box.get(i).bid.get(j).g_e_box.isValid() ==
false)
1512 size_t sub_id = eg_box.get(i).bid.get(j).sub;
1515 g_eg_box -= gdb_ext.get(sub_id).origin.template convertPoint<size_t>();
1517 size_t g_id = eg_box.get(i).bid.get(j).g_id;
1522 auto sub_it = loc_grid.get(sub_id).getIterator(g_eg_box.
getKP1(),g_eg_box.
getKP2());
1531 send_or_queue(ig_box.get(i).prc,(
char *)pointer,(
char *)pointer2);
1535 std::vector<size_t> prp_recv;
1541 queue_recv_data_put<prp_object>(ig_box,prp_recv,prRecv_prp);
1546 ghost_put_local<op,prp...>(loc_ig_box,loc_eg_box,gdb_ext,loc_grid,g_id_to_internal_ghost_box);
1548 merge_received_data_put<op,prp ...>(dec,loc_grid,ig_box,prp_recv,prRecv_prp,gdb_ext,g_id_to_internal_ghost_box);
1550 prRecv_prp.decRef();
1552 delete &prAlloc_prp;
1561 :
v_cl(create_vcluster<Memory>())
size_t getOffset()
Return the actual counter.
This class represent an N-dimensional box.
static void call_unpack(ExtPreAlloc< Memory > &recv_buf, sub_it_type &sub2, device_grid &gd, Unpack_stat &ps)
Error i do not know how to unpack.
void clear()
Eliminate all elements.
void queue_recv_data_put(const openfpm::vector< ip_box_grid< dim >> &ig_box, std::vector< size_t > &prp_recv, ExtPreAlloc< Memory > &prRecv_prp)
virtual size_t size() const
Get the size of the LAST allocated memory.
Vcluster< Memory > & v_cl
VCluster.
openfpm::vector< size_t > send_prc_queue
List of processor to send to.
openfpm::vector< size_t > recv_sz_map
Stores the size of the elements added for each processor that communicate with us (local processor)
void sendrecvMultipleMessagesNBX(openfpm::vector< size_t > &prc, openfpm::vector< T > &data, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &recv_sz, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE)
Send and receive multiple messages.
This class is an helper for the communication of grid_dist_id.
virtual void deviceToHost()
Do nothing.
size_t size()
return the size of the vector
void ghost_put_(Decomposition &dec, const openfpm::vector< ip_box_grid< dim >> &ig_box, const openfpm::vector< ep_box_grid< dim >> &eg_box, const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< device_grid > &loc_grid, openfpm::vector< std::unordered_map< size_t, size_t >> &g_id_to_internal_ghost_box)
It merge the information in the ghost with the real information.
Memory g_send_prp_mem
Memory for the ghost sending buffer.
Memory g_recv_prp_mem
Memory for the ghost receiving buffer.
openfpm::vector_fr< BMemory< Memory > > recv_buffers
receiving buffers in case of dynamic
size_t opt
Receiving option.
virtual void * getPointer()
Return the pointer of the last allocation.
size_t getOffsetEnd()
Get offset.
For each external ghost id, it contain a set of sub-domain at which this external box is linked.
Per-processor Internal ghost box.
grid_dist_id_comm(const grid_dist_id_comm< dim, St, T, Decomposition, Memory, device_grid > &gc)
Copy constructor.
__device__ __host__ index_type get(index_type i) const
Get the i index.
void labelIntersectionGridsProcessor(Decomposition &dec, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm, openfpm::vector< device_grid > &loc_grid_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_global, openfpm::vector< openfpm::vector< aggregate< device_grid, SpaceBox< dim, long int >>>> &lbl_b, openfpm::vector< size_t > &prc_sz)
Label intersection grids for mappings.
This class implement the point shape in an N-dimensional space.
void grids_reconstruct(openfpm::vector< openfpm::vector< aggregate< device_grid, SpaceBox< dim, long int >>>> &m_oGrid_recv, openfpm::vector< device_grid > &loc_grid, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm)
Reconstruct the local grids.
__host__ __device__ bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
T getVolumeKey() const
Get the volume spanned by the Box P1 and P2 interpreted as grid key.
openfpm::vector_gpu< aggregate< void *, void *, int > > pointers_h
header unpacker info
bool send(size_t proc, size_t tag, const void *mem, size_t sz)
Send data to a processor.
double getwct()
Return the elapsed real time.
virtual bool allocate(size_t sz)
Allocate a chunk of memory.
T & last()
Get an element of the vector.
void resize(size_t sz)
resize the vector retaining the objects
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
This structure store the Box that define the domain inside the Ghost + domain box.
openfpm::vector< rp_id > recv_proc
receiving processors
void execute()
Execute all the requests.
This class define the domain decomposition interface.
Implementation of 1-D std::vector like structure.
void * getDevicePointerEnd()
Return the device end pointer of the previous allocated memory.
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
virtual void hostToDevice()
Return the pointer of the last allocation.
void swap(openfpm::vector_fr< T > &v)
static void unpacking(ExtPreAlloc< Memory > &recv_buf, sub_it_type &sub2, device_grid &dg, Unpack_stat &ps)
Unpack.
static size_t packRequest(const T &obj, size_t &req)
Error, no implementation.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
static void call_unpack(ExtPreAlloc< Memory > &recv_buf, sub_it_type &sub2, device_grid &gd, Unpack_stat &ps)
Unpack.
size_t getOffset()
Get offset.
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
static void call_unpack(ExtPreAlloc< Memory > &recv_buf, sub_it_type &sub2, device_grid &dg, Unpack_stat &ps)
Unpack.
void start()
Start the timer.
bool recv(size_t proc, size_t tag, void *v, size_t sz)
Recv data from a processor.
size_t getProcessingUnits()
Get the total number of processors.
void addOffset(size_t off)
Increment the offset pointer by off.
virtual void incRef()
Increment the reference counter.
These set of classes generate an array definition at compile-time.
void ghost_get_local(const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< device_grid > &loc_grid, std::unordered_map< size_t, size_t > &g_id_to_external_ghost_box, const grid_sm< dim, void > &ginfo, bool use_bx_def, size_t opt)
Sync the local ghost part.
mgpu::ofp_context_t & getmgpuContext(bool iw=true)
If nvidia cuda is activated return a mgpu context.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
bool isValid() const
Check if the Box is a valid box P2 >= P1.
openfpm::vector< openfpm::vector< aggregate< device_grid, SpaceBox< dim, long int > > > > m_oGrid
openfpm::vector< size_t > prc_recv_map
Stores the list of processors that communicate with us (local processor)
openfpm::vector< size_t > p_map_req
Maps the processor id with the communication request into map procedure.
Per-processor external ghost box.
It return true if the object T require complex serialization.
void map_(Decomposition &dec, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm, openfpm::vector< device_grid > &loc_grid, openfpm::vector< device_grid > &loc_grid_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_global)
Moves all the grids that does not belong to the local processor to the respective processor.
Per-processor external ghost box.
openfpm::vector< size_t > send_size
size to send
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
virtual void decRef()
Decrement the reference counter.
void add()
Add another element.
T getVolume() const
Get the volume of the box.
It create a boost::fusion vector with the selected properties.
void queue_recv_data_get(const openfpm::vector< ep_box_grid< dim >> &eg_box, std::vector< size_t > &prp_recv, ExtPreAlloc< Memory > &prRecv_prp)
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
void ghost_get_(const openfpm::vector< ip_box_grid< dim >> &ig_box, const openfpm::vector< ep_box_grid< dim >> &eg_box, const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, const openfpm::vector< e_box_multi< dim >> &eb_gid_list, bool use_bx_def, openfpm::vector< device_grid > &loc_grid, const grid_sm< dim, void > &ginfo, std::unordered_map< size_t, size_t > &g_id_to_external_ghost_box, size_t opt)
It fill the ghost part of the grids.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
openfpm::vector< void * > pointers
send pointers
openfpm::vector< void * > send_pointer
Pointer to the memory to send.
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
static size_t calculateMem(std::vector< size_t > &mm)
Calculate the total memory required to pack the message.
void * getPointerEnd()
Return the end pointer of the previous allocated memory.
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.
T & get(size_t id)
Get an element of the vector.
grid_dist_id_comm()
Constructor.
void ghost_put_local(const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< device_grid > &loc_grid, openfpm::vector< std::unordered_map< size_t, size_t >> &g_id_to_external_ghost_box)
Sync the local ghost part.
Class for cpu time benchmarking.
void stop()
Stop the timer.