32 #ifndef MADNESS_WORLD_WORLDDC_H__INCLUDED
33 #define MADNESS_WORLD_WORLDDC_H__INCLUDED
54 template <
typename keyT,
typename valueT,
typename hashfunT>
57 template <
typename keyT,
typename valueT,
typename hashfunT>
58 class WorldContainerImpl;
60 template <
typename keyT,
typename valueT,
typename hashfunT>
61 void swap(WorldContainer<keyT, valueT, hashfunT> &, WorldContainer<keyT, valueT, hashfunT> &);
63 template <
typename keyT>
64 class WorldDCPmapInterface;
66 template <
typename keyT>
70 virtual std::size_t
size()
const = 0;
80 template <
typename keyT>
126 for (
typename std::set<ptrT>::iterator iter =
ptrs.begin();
130 (*iter)->redistribute_phase1(newpmap);
133 for (
typename std::set<ptrT>::iterator iter =
ptrs.begin();
137 (*iter)->redistribute_phase2();
138 newpmap->register_callback(*iter);
141 for (
typename std::set<ptrT>::iterator iter =
ptrs.begin();
145 (*iter)->redistribute_phase3();
149 newpmap->print_data_sizes(world,
"after redistributing");
168 for (
typename std::set<ptrT>::iterator iter =
ptrs.begin(); iter !=
ptrs.end(); ++iter)
170 sum += (*iter)->size();
182 std::vector<std::size_t> sizes(world.
size());
185 if (world.
rank() == 0)
189 std::cout <<
" procs: ";
190 for (
int i = 0; i < world.
size(); i++)
191 std::cout << sizes[i] <<
" ";
192 std::cout << std::endl;
201 template <
typename keyT,
typename hashfunT = Hash<keyT>>
225 template <
typename keyT,
typename hashfunT = Hash<keyT>>
242 template <
class internal_iteratorT>
247 typedef typename std::iterator_traits<internal_iteratorT>::value_type
value_type;
248 typedef typename std::iterator_traits<internal_iteratorT>::difference_type
difference_type;
249 typedef typename std::iterator_traits<internal_iteratorT>::pointer
pointer;
250 typedef typename std::iterator_traits<internal_iteratorT>::reference
reference;
253 internal_iteratorT
it;
279 template <
class iteratorT>
308 return !(*
this == other);
350 return value !=
nullptr;
353 template <
typename Archive>
360 template <
class iteratorT>
363 template <
class iteratorT>
366 if (
static_cast<const void *
>(
this) !=
static_cast<const void *
>(&other))
372 it = internal_iteratorT();
386 template <
typename keyT,
typename valueT,
typename hashfunT>
388 :
public WorldObject<WorldContainerImpl<keyT, valueT, hashfunT>>,
390 #ifndef MADNESS_DISABLE_SHARED_FROM_THIS
392 public std::enable_shared_from_this<WorldContainerImpl<keyT, valueT, hashfunT>>
396 typedef typename std::pair<const keyT, valueT>
pairT;
427 std::shared_ptr<WorldDCPmapInterface<keyT>>
pmap;
474 pmap->register_callback(
this);
479 pmap->deregister_callback(
this);
482 const std::shared_ptr<WorldDCPmapInterface<keyT>> &
get_pmap()
const
487 std::shared_ptr<WorldDCPmapInterface<keyT>> &
get_pmap()
494 pmap->deregister_callback(
this);
496 pmap->register_callback(
this);
505 pmap->deregister_callback(
this);
507 pmap->register_callback(
this);
513 std::size_t sz =
size();
516 for (
auto it =
begin(); it !=
end(); ++it)
518 keyT key = it->first;
519 valueT value = it->second;
528 for (
size_t i = 0; i < sz; i++)
551 return pmap->owner(key);
576 [[maybe_unused]]
auto inserted =
local.
insert(acc, datum.first);
577 acc->second = datum.second;
614 this->
send(dest, eraser, key);
618 template <
typename InIter>
626 template <
typename InIter>
627 void erase(InIter first, InIter last)
635 }
while (first != last);
699 template <
typename memfunT>
705 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
706 return (acc->second.*memfun)();
710 template <
typename memfunT,
typename arg1T>
712 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1)
716 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
717 return (acc->second.*memfun)(arg1);
721 template <
typename memfunT,
typename arg1T,
typename arg2T>
723 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2)
727 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
728 return (acc->second.*memfun)(arg1, arg2);
732 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T>
734 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3)
738 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
739 return (acc->second.*memfun)(arg1, arg2, arg3);
743 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T>
745 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4)
749 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
750 return (acc->second.*memfun)(arg1, arg2, arg3, arg4);
754 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T>
756 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5)
760 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
761 return (acc->second.*memfun)(arg1, arg2, arg3, arg4, arg5);
765 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T>
767 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6)
771 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
772 return (acc->second.*memfun)(arg1, arg2, arg3, arg4, arg5, arg6);
776 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T,
typename arg7T>
778 itemfun(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3,
779 const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const arg7T &arg7)
783 [[maybe_unused]]
auto inserted =
local.
insert(acc, key);
784 return (acc->second.*memfun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
864 template <
typename keyT,
typename valueT,
typename hashfunT = Hash<keyT>>
879 std::shared_ptr<implT>
p;
910 p->process_pending();
922 bool do_pending =
true,
923 const hashfunT &hf = hashfunT())
924 :
p(new
implT(world, pmap, hf))
927 p->process_pending();
958 return p->get_world();
961 std::shared_ptr<WorldDCPmapInterface<keyT>> &
get_impl()
990 return p->find(acc, key);
997 return p->find(acc, key);
1004 return p->insert_acc(acc, key);
1011 return p->insert_acc(acc, key);
1015 template <
typename input_iterator>
1019 using std::placeholders::_1;
1027 return p->probe(key);
1037 return p->owner(key);
1044 return p->is_local(key);
1055 return p->find(key);
1066 return const_cast<const implT *
>(
p.get())->
find(key);
1080 return const_cast<const implT *
>(
p.get())->
begin();
1094 return const_cast<const implT *
>(
p.get())->
end();
1122 p->erase(start, finish);
1142 inline const std::shared_ptr<WorldDCPmapInterface<keyT>> &
get_pmap()
const
1145 return p->get_pmap();
1151 p->reset_pmap_to_local();
1158 return p->get_hash();
1169 p->process_pending();
1181 template <
typename memfunT>
1183 send(
const keyT &key, memfunT memfun)
1187 (
implT::*itemfun)(
const keyT &, memfunT) = &implT::template itemfun<memfunT>;
1188 return p->send(
owner(key), itemfun, key, memfun);
1200 template <
typename memfunT,
typename arg1T>
1202 send(
const keyT &key,
const memfunT &memfun,
const arg1T &arg1)
1207 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &) = &implT::template itemfun<memfunT, arg1T>;
1208 return p->send(
owner(key), itemfun, key, memfun, arg1);
1223 template <
typename memfunT,
typename arg1T,
typename arg2T>
1225 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2)
1230 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &,
const arg2T &) = &implT::template itemfun<memfunT, arg1T, arg2T>;
1231 return p->send(
owner(key), itemfun, key, memfun, arg1, arg2);
1245 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T>
1247 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3)
1251 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &,
const arg2T &,
const arg3T &) = &implT::template itemfun<memfunT, arg1T, arg2T, arg3T>;
1252 return p->send(
owner(key), itemfun, key, memfun, arg1, arg2, arg3);
1264 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T>
1266 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4)
1270 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &,
const arg2T &,
const arg3T &,
const arg4T &) = &implT::template itemfun<memfunT, arg1T, arg2T, arg3T, arg4T>;
1271 return p->send(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4);
1283 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T>
1285 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5)
1289 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &,
const arg2T &,
const arg3T &,
const arg4T &,
const arg5T &) = &implT::template itemfun<memfunT, arg1T, arg2T, arg3T, arg4T, arg5T>;
1290 return p->send(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, arg5);
1302 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T>
1304 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6)
1308 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &,
const arg2T &,
const arg3T &,
const arg4T &,
const arg5T &,
const arg6T &) = &implT::template itemfun<memfunT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T>;
1309 return p->send(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, arg5, arg6);
1321 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T,
typename arg7T>
1323 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
1324 const arg5T &arg5,
const arg6T &arg6,
const arg7T &arg7)
1328 (
implT::*itemfun)(
const keyT &, memfunT,
const arg1T &,
const arg2T &,
const arg3T &,
const arg4T &,
const arg5T &,
const arg6T &,
const arg7T &) = &implT::template itemfun<memfunT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T>;
1329 return p->send(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
1335 template <
typename memfunT>
1337 send(
const keyT &key, memfunT memfun)
const
1345 template <
typename memfunT,
typename arg1T>
1347 send(
const keyT &key, memfunT memfun,
const arg1T &arg1)
const
1355 template <
typename memfunT,
typename arg1T,
typename arg2T>
1357 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2)
const
1359 return const_cast<containerT *
>(
this)->
send(key, memfun, arg1, arg2);
1365 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T>
1367 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3)
const
1369 return const_cast<containerT *
>(
this)->
send(key, memfun, arg1, arg2, arg3);
1375 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T>
1377 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4)
const
1379 return const_cast<containerT *
>(
this)->
send(key, memfun, arg1, arg2, arg3, arg4);
1385 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T>
1387 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5)
const
1389 return const_cast<containerT *
>(
this)->
send(key, memfun, arg1, arg2, arg3, arg4, arg5);
1395 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T>
1397 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
1398 const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6)
const
1400 return const_cast<containerT *
>(
this)->
send(key, memfun, arg1, arg2, arg3, arg4, arg5, arg6);
1406 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T,
typename arg7T>
1408 send(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
1409 const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6,
const arg7T &arg7)
const
1411 return const_cast<containerT *
>(
this)->
send(key, memfun, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
1424 template <
typename memfunT>
1430 (
implT::*itemfun)(
const keyT &, memfunT) = &implT::template itemfun<memfunT>;
1431 return p->task(
owner(key), itemfun, key, memfun, attr);
1444 template <
typename memfunT,
typename arg1T>
1451 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &) = &implT::template itemfun<memfunT, a1T>;
1452 return p->task(
owner(key), itemfun, key, memfun, arg1, attr);
1465 template <
typename memfunT,
typename arg1T,
typename arg2T>
1473 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &,
const a2T &) = &implT::template itemfun<memfunT, a1T, a2T>;
1474 return p->task(
owner(key), itemfun, key, memfun, arg1, arg2, attr);
1487 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T>
1496 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &,
const a2T &,
const a3T &) = &implT::template itemfun<memfunT, a1T, a2T, a3T>;
1497 return p->task(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, attr);
1510 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T>
1520 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &,
const a2T &,
const a3T &,
const a4T &) = &implT::template itemfun<memfunT, a1T, a2T, a3T, a4T>;
1521 return p->task(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, attr);
1534 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T>
1536 task(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const TaskAttributes &attr =
TaskAttributes())
1545 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &,
const a2T &,
const a3T &,
const a4T &,
const a5T &) = &implT::template itemfun<memfunT, a1T, a2T, a3T, a4T, a5T>;
1546 return p->task(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, arg5, attr);
1559 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T>
1561 task(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6,
const TaskAttributes &attr =
TaskAttributes())
1571 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &,
const a2T &,
const a3T &,
const a4T &,
const a5T &,
const a6T &) = &implT::template itemfun<memfunT, a1T, a2T, a3T, a4T, a5T, a6T>;
1572 return p->task(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, arg5, arg6, attr);
1585 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T,
typename arg7T>
1587 task(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6,
const arg7T &arg7,
const TaskAttributes &attr =
TaskAttributes())
1598 (
implT::*itemfun)(
const keyT &, memfunT,
const a1T &,
const a2T &,
const a3T &,
const a4T &,
const a5T &,
const a6T &,
const a7T &) = &implT::template itemfun<memfunT, a1T, a2T, a3T, a4T, a5T, a6T, a7T>;
1599 return p->task(
owner(key), itemfun, key, memfun, arg1, arg2, arg3, arg4, arg5, arg6, arg7, attr);
1605 template <
typename memfunT>
1615 template <
typename memfunT,
typename arg1T>
1619 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, attr);
1625 template <
typename memfunT,
typename arg1T,
typename arg2T>
1629 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, arg2, attr);
1635 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T>
1639 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, arg2, arg3, attr);
1645 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T>
1649 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, arg2, arg3, arg4, attr);
1655 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T>
1657 task(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const TaskAttributes &attr =
TaskAttributes())
const
1659 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, arg2, arg3, arg4, arg5, attr);
1665 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T>
1667 task(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6,
const TaskAttributes &attr =
TaskAttributes())
const
1669 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, arg2, arg3, arg4, arg5, arg6, attr);
1675 template <
typename memfunT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
typename arg5T,
typename arg6T,
typename arg7T>
1677 task(
const keyT &key, memfunT memfun,
const arg1T &arg1,
const arg2T &arg2,
const arg3T &arg3,
const arg4T &arg4,
const arg5T &arg5,
const arg6T &arg6,
const arg7T &arg7,
const TaskAttributes &attr =
TaskAttributes())
const
1679 return const_cast<containerT *
>(
this)->
task(key, memfun, arg1, arg2, arg3, arg4, arg5, arg6, arg7, attr);
1685 template <
typename Archive>
1692 const long magic = 5881828;
1693 unsigned long count = 0;
1696 if (Archive::is_output_archive)
1738 #ifdef MADNESS_DISABLE_SHARED_FROM_THIS
1739 p.reset(
static_cast<implT *
>(ptr), [](
implT *p_) ->
void{});
1741 p =
static_cast<implT *
>(ptr)->shared_from_this();
1764 template <
typename keyT,
typename valueT,
typename hashfunT>
1778 template <
class keyT,
class valueT>
1784 const long magic = -5881828;
1786 using const_iterator =
typename dcT::const_iterator;
1787 int count = t.
size();
1801 const_iterator start, end;
1805 op_inspector(const_iterator start, const_iterator end,
size_t &size)
1806 : start(start), end(end), size(size) {}
1810 for (const_iterator it = start; it != end; ++it)
1818 const_iterator start, end;
1823 op_executor(const_iterator start, const_iterator end,
unsigned char *buf,
size_t size)
1824 : start(start), end(end), buf(buf), size(size) {}
1828 for (const_iterator it = start; it != end; ++it)
1839 size_t local_size = 0;
1840 double wall1 = wall0;
1841 unsigned char* buf = 0;
1844 const size_t max_items_per_task = (
std::max(1, count) - 1) / ntasks + 1;
1846 const_iterator starts[ntasks], ends[ntasks];
1847 size_t local_sizes[ntasks];
1848 const_iterator start = t.
begin();
1849 size_t nleft = count;
1850 for (
size_t taskid = 0; taskid < ntasks; taskid++)
1852 const_iterator end = start;
1853 if (taskid == (ntasks - 1))
1859 size_t nitems = std::min(max_items_per_task, nleft);
1863 starts[taskid] = start;
1865 world->
taskq.
add(
new op_inspector(start, end, local_sizes[taskid]));
1875 for (
size_t taskid = 0; taskid < ntasks; taskid++)
1877 local_size += local_sizes[taskid];
1882 buf =
new unsigned char[local_size];
1886 for (
size_t taskid = 0; taskid < ntasks; taskid++)
1888 world->
taskq.
add(
new op_executor(starts[taskid], ends[taskid], buf +
offset, local_sizes[taskid]));
1889 offset += local_sizes[taskid];
1910 const int size = local_size;
1911 std::vector<int> sizes(world->
size());
1917 std::vector<int> offsets(world->
size());
1919 for (
int i = 1; i < world->
size(); ++i)
1920 offsets[i] = offsets[i - 1] + sizes[i - 1];
1921 size_t total_size = offsets.back() + sizes.back();
1927 unsigned char *all_data = 0;
1928 if (world->
rank() == 0)
1930 all_data =
new unsigned char[total_size];
1942 if (world->
rank() == 0)
1945 localar & magic & 1;
1948 localar & -magic &(
unsigned long)(count);
1949 localar.store(all_data, total_size);
1979 template <
class keyT,
class valueT,
class localarchiveT>
1984 const long magic = -5881828;
1987 typedef typename dcT::pairT pairT;
2008 unsigned long count = 0ul;
2013 localar & cookie & count;
2039 template <
class keyT,
class valueT,
class localarchiveT>
2053 const long magic = -5881828;
2065 localar & cookie & nclient;
int unique_tag()
Returns a unique tag for temporary use (1023<tag<4095)
Definition: safempi.h:830
MPI_Comm & Get_mpi_comm() const
Definition: safempi.h:709
size_t size() const
Definition: worldhashmap.h:560
hashfunT & get_hash() const
Definition: worldhashmap.h:595
std::pair< iterator, bool > insert(const datumT &datum)
Definition: worldhashmap.h:468
iterator begin()
Definition: worldhashmap.h:571
void erase(const iterator &it)
Definition: worldhashmap.h:507
bool try_erase(const keyT &key)
Definition: worldhashmap.h:502
iterator end()
Definition: worldhashmap.h:583
iterator find(const keyT &key)
Definition: worldhashmap.h:524
void clear()
Definition: worldhashmap.h:556
Implements the functionality of futures.
Definition: future.h:74
A future is a possibly yet unevaluated value.
Definition: future.h:373
remote_refT remote_ref(World &world) const
Returns a structure used to pass references to another process.
Definition: future.h:675
Definition: worldhashmap.h:330
iterator for hash
Definition: worldhashmap.h:188
Range, vaguely a la Intel TBB, to encapsulate a random-access, STL-like start and end iterator with c...
Definition: range.h:64
iteratorT iterator
Alias for the iterator type.
Definition: range.h:71
Simple structure used to manage references/pointers to remote instances.
Definition: worldref.h:395
Contains attributes of a task.
Definition: thread.h:323
All world tasks must be derived from this public interface.
Definition: taskfn.h:69
static std::size_t size()
Returns the number of threads in the pool.
Definition: thread.h:1413
Internal implementation of distributed container to facilitate shallow copy.
Definition: worlddc.h:394
void erase(const keyT &key)
Definition: worlddc.h:603
WorldContainerIterator< internal_iteratorT > iterator
Definition: worlddc.h:409
bool find(const_accessor &acc, const keyT &key) const
Definition: worlddc.h:691
internal_containerT::accessor accessor
Definition: worlddc.h:406
void find_handler(ProcessID requestor, const keyT &key, const RemoteReference< FutureImpl< iterator >> &ref)
Handles find request.
Definition: worlddc.h:433
bool probe(const keyT &key) const
Definition: worlddc.h:554
std::pair< const keyT, valueT > pairT
Definition: worlddc.h:396
hashfunT & get_hash() const
Definition: worlddc.h:542
bool insert_const_acc(const_accessor &acc, const keyT &key)
Definition: worlddc.h:592
WorldContainerIterator< internal_const_iteratorT > const_iteratorT
Definition: worlddc.h:410
bool find(accessor &acc, const keyT &key)
Definition: worlddc.h:684
WorldContainerImpl(World &world, const std::shared_ptr< WorldDCPmapInterface< keyT >> &pm, const hashfunT &hf)
Definition: worlddc.h:469
void redistribute_phase1(const std::shared_ptr< WorldDCPmapInterface< keyT >> &newpmap)
Definition: worlddc.h:788
void find_failure_handler(const RemoteReference< FutureImpl< iterator >> &ref)
Handles unsuccessful find response.
Definition: worlddc.h:459
void redistribute_phase2()
Definition: worlddc.h:819
void insert(const pairT &datum)
Definition: worlddc.h:568
WorldContainerIterator< internal_iteratorT > iteratorT
Definition: worlddc.h:408
void clear()
Definition: worlddc.h:598
bool insert_acc(accessor &acc, const keyT &key)
Definition: worlddc.h:586
void reset_pmap_to_local()
Definition: worlddc.h:492
itemfun(const keyT &key, memfunT memfun)
Definition: worlddc.h:701
const pairT const_pairT
Definition: worlddc.h:397
std::vector< keyT > * move_list
Tempoary used to record data that needs redistributing.
Definition: worlddc.h:430
internal_containerT::iterator internal_iteratorT
Definition: worlddc.h:404
WorldContainerImpl< keyT, valueT, hashfunT > implT
Definition: worlddc.h:398
std::size_t size() const
Definition: worlddc.h:563
std::shared_ptr< WorldDCPmapInterface< keyT > > & get_pmap()
Definition: worlddc.h:487
internal_containerT::const_iterator internal_const_iteratorT
Definition: worlddc.h:405
std::shared_ptr< WorldDCPmapInterface< keyT > > pmap
Function/class to map from keys to owning process.
Definition: worlddc.h:427
virtual ~WorldContainerImpl()
Definition: worlddc.h:477
internal_containerT local
Locally owned data.
Definition: worlddc.h:429
ConcurrentHashMap< keyT, valueT, hashfunT > internal_containerT
Definition: worlddc.h:400
Future< iterator > find(const keyT &key)
Definition: worlddc.h:669
const std::shared_ptr< WorldDCPmapInterface< keyT > > & get_pmap() const
Definition: worlddc.h:482
const_iterator begin() const
Definition: worlddc.h:643
void erase(InIter it)
Definition: worlddc.h:619
void replicate(bool fence)
Definition: worlddc.h:501
const_iterator end() const
Definition: worlddc.h:653
bool is_local(const keyT &key) const
Definition: worlddc.h:544
void redistribute_phase3()
Definition: worlddc.h:833
ProcessID owner(const keyT &key) const
Definition: worlddc.h:549
void erase(InIter first, InIter last)
Definition: worlddc.h:627
iterator begin()
Definition: worlddc.h:638
const ProcessID me
My MPI rank.
Definition: worlddc.h:428
iterator end()
Definition: worlddc.h:648
void find_success_handler(const RemoteReference< FutureImpl< iterator >> &ref, const pairT &datum)
Handles successful find response.
Definition: worlddc.h:449
WorldContainerIterator< internal_const_iteratorT > const_iterator
Definition: worlddc.h:411
Future< const_iterator > find(const keyT &key) const
Definition: worlddc.h:658
internal_containerT::const_accessor const_accessor
Definition: worlddc.h:407
Iterator for distributed container wraps the local iterator.
Definition: worlddc.h:244
WorldContainerIterator(const WorldContainerIterator &other)
Definition: worlddc.h:273
WorldContainerIterator(const internal_iteratorT &it)
Initializes from a local iterator.
Definition: worlddc.h:263
WorldContainerIterator & operator=(const WorldContainerIterator &other)
Assignment.
Definition: worlddc.h:292
std::iterator_traits< internal_iteratorT >::iterator_category iterator_category
Definition: worlddc.h:246
void copy(const WorldContainerIterator< iteratorT > &other)
Definition: worlddc.h:364
std::iterator_traits< internal_iteratorT >::pointer pointer
Definition: worlddc.h:249
bool operator==(const WorldContainerIterator &other) const
Determines if two iterators are identical.
Definition: worlddc.h:299
value_type * value
holds the remote values
Definition: worlddc.h:255
bool is_cached() const
Returns true if this is non-local or cached value.
Definition: worlddc.h:348
WorldContainerIterator operator++(int)
Definition: worlddc.h:321
WorldContainerIterator & operator++()
Pre-increment of an iterator (i.e., ++it) — local iterators only.
Definition: worlddc.h:314
WorldContainerIterator(const value_type &v)
Initializes to cache a remote value.
Definition: worlddc.h:267
pointer operator->() const
Iterators dereference to std::pair<const keyT,valueT>
Definition: worlddc.h:330
std::iterator_traits< internal_iteratorT >::reference reference
Definition: worlddc.h:250
void serialize(const Archive &)
Definition: worlddc.h:354
std::iterator_traits< internal_iteratorT >::value_type value_type
Definition: worlddc.h:247
WorldContainerIterator(const WorldContainerIterator< iteratorT > &other)
Definition: worlddc.h:280
WorldContainerIterator()
Default constructor makes a local uninitialized value.
Definition: worlddc.h:259
internal_iteratorT it
Iterator from local container.
Definition: worlddc.h:253
const internal_iteratorT & get_internal_iterator() const
Private: (or should be) Returns iterator of internal container.
Definition: worlddc.h:342
reference operator*() const
Iterators dereference to std::pair<const keyT,valueT>
Definition: worlddc.h:336
std::iterator_traits< internal_iteratorT >::difference_type difference_type
Definition: worlddc.h:248
bool operator!=(const WorldContainerIterator &other) const
Determines if two iterators are different.
Definition: worlddc.h:306
~WorldContainerIterator()
Definition: worlddc.h:286
Makes a distributed container with specified attributes.
Definition: worlddc.h:866
void process_pending()
Process pending messages.
Definition: worlddc.h:1166
WorldContainer(World &world, bool do_pending=true, const hashfunT &hf=hashfunT())
Makes an initialized, empty container with default data distribution (no communication)
Definition: worlddc.h:904
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4)
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T)" to item (non-blocking comm if remote)
Definition: worlddc.h:1266
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5)
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T)" to item (non-blocking comm if remote)
Definition: worlddc.h:1285
bool find(accessor &acc, const keyT &key)
Write access to LOCAL value by key. Returns true if found, false otherwise (always false for remote).
Definition: worlddc.h:987
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const arg7T &arg7) const
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T) const" to item (non-blocking...
Definition: worlddc.h:1408
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T,arg2T)" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1467
bool probe(const keyT &key) const
Returns true if local data is immediately available (no communication)
Definition: worlddc.h:1024
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5) const
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T) const" to item (non-blocking comm if rem...
Definition: worlddc.h:1387
const_iterator begin() const
Returns an iterator to the beginning of the local data (no communication)
Definition: worlddc.h:1077
void replace(const keyT &key, const valueT &value)
Inserts/replaces key+value pair (non-blocking communication if key not local)
Definition: worlddc.h:981
bool insert(const_accessor &acc, const keyT &key)
Read access to LOCAL value by key. Returns true if inserted, false if already exists (throws if remot...
Definition: worlddc.h:1008
iterator begin()
Returns an iterator to the beginning of the local data (no communication)
Definition: worlddc.h:1070
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T,arg2T) const" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1627
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T) const" in process owning item (non-blo...
Definition: worlddc.h:1667
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun) const
Sends message "resultT memfun() const" to item (non-blocking comm if remote)
Definition: worlddc.h:1337
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3)
Sends message "resultT memfun(arg1T,arg2T,arg3T)" to item (non-blocking comm if remote)
Definition: worlddc.h:1247
Future< const_iterator > const_futureT
Definition: worlddc.h:876
ProcessID owner(const keyT &key) const
Returns processor that logically owns key (no communication)
Definition: worlddc.h:1034
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3) const
Sends message "resultT memfun(arg1T,arg2T,arg3T) const" to item (non-blocking comm if remote)
Definition: worlddc.h:1367
implT::const_iterator const_iterator
Definition: worlddc.h:872
WorldContainer()
Makes an uninitialized container (no communication)
Definition: worlddc.h:892
void serialize(const archive::BufferOutputArchive &ar)
(de)Serialize — !! ONLY for purpose of interprocess communication
Definition: worlddc.h:1723
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, const memfunT &memfun, const arg1T &arg1)
Sends message "resultT memfun(arg1T)" to item (non-blocking comm if remote)
Definition: worlddc.h:1202
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4) const
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T) const" to item (non-blocking comm if remote)
Definition: worlddc.h:1377
void replicate(bool fence=true)
replicates this WorldContainer on all ProcessIDs
Definition: worlddc.h:968
virtual ~WorldContainer()
Destructor passes ownership of implementation to world for deferred cleanup.
Definition: worlddc.h:1753
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2) const
Sends message "resultT memfun(arg1T,arg2T) const" to item (non-blocking comm if remote)
Definition: worlddc.h:1357
const std::shared_ptr< WorldDCPmapInterface< keyT > > & get_pmap() const
Returns shared pointer to the process mapping.
Definition: worlddc.h:1142
void erase(const keyT &key)
Erases entry from container (non-blocking comm if remote)
Definition: worlddc.h:1105
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T,arg2T,arg3T)" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1489
void reset_pmap_to_local()
Returns shared pointer to the process mapping.
Definition: worlddc.h:1149
std::shared_ptr< WorldDCPmapInterface< keyT > > & get_impl()
Definition: worlddc.h:961
Future< iterator > find(const keyT &key)
Returns a future iterator (non-blocking communication if key not local)
Definition: worlddc.h:1052
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2)
Sends message "resultT memfun(arg1T,arg2T)" to item (non-blocking comm if remote)
Definition: worlddc.h:1225
WorldContainerImpl< keyT, valueT, hashfunT > implT
Definition: worlddc.h:869
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T)" in process owning item (non-blocking ...
Definition: worlddc.h:1561
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T)" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1446
void replace(const pairT &datum)
Inserts/replaces key+value pair (non-blocking communication if key not local)
Definition: worlddc.h:974
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun() const" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1607
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T) const" in process owning item (non-blocking ...
Definition: worlddc.h:1657
iterator end()
Returns an iterator past the end of the local data (no communication)
Definition: worlddc.h:1084
WorldContainer(World &world, const std::shared_ptr< WorldDCPmapInterface< keyT >> &pmap, bool do_pending=true, const hashfunT &hf=hashfunT())
Makes an initialized, empty container (no communication)
Definition: worlddc.h:920
void replace(input_iterator &start, input_iterator &end)
Inserts pairs (non-blocking communication if key(s) not local)
Definition: worlddc.h:1016
bool insert(accessor &acc, const keyT &key)
Write access to LOCAL value by key. Returns true if inserted, false if already exists (throws if remo...
Definition: worlddc.h:1001
Future< iterator > futureT
Definition: worlddc.h:875
Future< const_iterator > find(const keyT &key) const
Returns a future iterator (non-blocking communication if key not local)
Definition: worlddc.h:1063
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun()" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1426
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const arg7T &arg7)
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T)" to item (non-blocking comm ...
Definition: worlddc.h:1323
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T) const" in process owning item (non-blocking comm if remote)
Definition: worlddc.h:1617
void erase(const iterator &it)
Erases entry corresponding to local iterator (no communication)
Definition: worlddc.h:1112
void erase(const iterator &start, const iterator &finish)
Erases range defined by local iterators (no communication)
Definition: worlddc.h:1119
WorldContainer(const WorldContainer &other)
Copy constructor is shallow (no communication)
Definition: worlddc.h:934
World & get_world() const
Returns the world associated with this container.
Definition: worlddc.h:955
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T,arg2T,arg3T) const" in process owning item (non-blocking comm if remo...
Definition: worlddc.h:1637
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T)" in process owning item (non-blocking comm i...
Definition: worlddc.h:1536
implT::iterator iterator
Definition: worlddc.h:871
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T,arg2T,arg3T, arg4T) const" in process owning item (non-blocking comm ...
Definition: worlddc.h:1647
implT::pairT pairT
Definition: worlddc.h:870
std::size_t size() const
Returns the number of local entries (no communication)
Definition: worlddc.h:1135
hashfunT & get_hash() const
Returns a reference to the hashing functor.
Definition: worlddc.h:1155
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1) const
Sends message "resultT memfun(arg1T) const" to item (non-blocking comm if remote)
Definition: worlddc.h:1347
bool find(const_accessor &acc, const keyT &key) const
Read access to LOCAL value by key. Returns true if found, false otherwise (always false for remote).
Definition: worlddc.h:994
void serialize(const archive::BufferInputArchive &ar)
(de)Serialize — !! ONLY for purpose of interprocess communication
Definition: worlddc.h:1732
bool is_local(const keyT &key) const
Returns true if the key maps to the local processor (no communication)
Definition: worlddc.h:1041
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6) const
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T) const" to item (non-blocking comm ...
Definition: worlddc.h:1397
const uniqueidT & id() const
Returns the associated unique id ... must be initialized.
Definition: worlddc.h:1746
const_iterator end() const
Returns an iterator past the end of the local data (no communication)
Definition: worlddc.h:1091
void serialize(const Archive &ar)
(de)Serialize — Local data only to/from anything except Buffer*Archive and Parallel*Archive
Definition: worlddc.h:1686
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const arg7T &arg7, const TaskAttributes &attr=TaskAttributes()) const
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T) const" in process owning item (n...
Definition: worlddc.h:1677
containerT & operator=(const containerT &other)
Assignment is shallow (no communication)
Definition: worlddc.h:944
void clear()
Clears all local data (no communication)
Definition: worlddc.h:1128
implT::const_accessor const_accessor
Definition: worlddc.h:874
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T)" in process owning item (non-blocking comm if remo...
Definition: worlddc.h:1512
std::shared_ptr< implT > p
Definition: worlddc.h:879
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6, const arg7T &arg7, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T)" in process owning item (non-blo...
Definition: worlddc.h:1587
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> send(const keyT &key, memfunT memfun, const arg1T &arg1, const arg2T &arg2, const arg3T &arg3, const arg4T &arg4, const arg5T &arg5, const arg6T &arg6)
Sends message "resultT memfun(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T)" to item (non-blocking comm if rem...
Definition: worlddc.h:1304
void check_initialized() const
Definition: worlddc.h:881
Future< MEMFUN_RETURNT(memfunT)> send(const keyT &key, memfunT memfun)
Sends message "resultT memfun()" to item (non-blocking comm if remote)
Definition: worlddc.h:1183
WorldContainer< keyT, valueT, hashfunT > containerT
Definition: worlddc.h:868
implT::accessor accessor
Definition: worlddc.h:873
Default process map is "random" using madness::hash(key)
Definition: worlddc.h:203
ProcessID owner(const keyT &key) const
Maps key to processor.
Definition: worlddc.h:214
WorldDCDefaultPmap(World &world, const hashfunT &hf=hashfunT())
Definition: worlddc.h:209
const int nproc
Definition: worlddc.h:205
hashfunT hashfun
Definition: worlddc.h:206
Local process map will always return the current process as owner.
Definition: worlddc.h:227
WorldDCLocalPmap(World &world)
Definition: worlddc.h:232
ProcessID me
Definition: worlddc.h:229
ProcessID owner(const keyT &key) const
Maps key to processor.
Definition: worlddc.h:233
Interface to be provided by any process map.
Definition: worlddc.h:82
void print_data_sizes(World &world, const std::string msg="") const
Prints size info to std::cout.
Definition: worlddc.h:178
std::size_t global_size(World &world) const
Counts global number of entries in all containers associated with this process map.
Definition: worlddc.h:155
virtual ProcessID owner(const keyT &key) const =0
Maps key to processor.
void deregister_callback(ptrT ptr)
Deregisters object for receipt of redistribute callbacks.
Definition: worlddc.h:111
void register_callback(ptrT ptr)
Registers object for receipt of redistribute callbacks.
Definition: worlddc.h:103
virtual void print() const
Definition: worlddc.h:98
std::size_t local_size() const
Counts local number of entries in all containers associated with this process map.
Definition: worlddc.h:165
std::set< ptrT > ptrs
Definition: worlddc.h:87
void redistribute(World &world, const std::shared_ptr< WorldDCPmapInterface< keyT >> &newpmap)
Invoking this switches all registered objects from this process map to the new one.
Definition: worlddc.h:122
virtual ~WorldDCPmapInterface()
Definition: worlddc.h:96
WorldDCRedistributeInterface< keyT > * ptrT
Definition: worlddc.h:84
virtual void redistribute_phase3()=0
virtual std::size_t size() const =0
virtual void redistribute_phase2()=0
virtual void redistribute_phase1(const std::shared_ptr< WorldDCPmapInterface< keyT >> &newmap)=0
virtual ~WorldDCRedistributeInterface()
Definition: worlddc.h:74
void broadcast_serializable(objT &obj, ProcessID root)
Broadcast a serializable object.
Definition: worldgop.h:754
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition: worldgop.cc:161
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks.
Definition: worldgop.h:870
void Send(const T *buf, long lenbuf, int dest, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Send array of lenbuf elements to process dest.
Definition: worldmpi.h:347
void Recv(T *buf, long lenbuf, int src, int tag) const
Receive data of up to lenbuf elements from process src.
Definition: worldmpi.h:374
SafeMPI::Intracomm & comm()
Returns the associated SafeMPI communicator.
Definition: worldmpi.h:286
Implements most parts of a globally addressable object (via unique ID).
Definition: world_object.h:364
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn) const
Definition: world_object.h:731
World & world
The World this object belongs to. (Think globally, act locally).
Definition: world_object.h:381
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)().
Definition: world_object.h:1005
World & get_world() const
Returns a reference to the world.
Definition: world_object.h:717
Future< bool > for_each(const rangeT &range, const opT &op)
Apply op(item) on all items in range.
Definition: world_task_queue.h:572
void add(TaskInterface *t)
Add a new local task, taking ownership of the pointer.
Definition: world_task_queue.h:466
void fence()
Returns after all local tasks have completed.
Definition: world_task_queue.h:1384
A parallel world class.
Definition: world.h:132
WorldTaskQueue & taskq
Task queue.
Definition: world.h:204
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition: world.h:318
WorldMpiInterface & mpi
MPI interface.
Definition: world.h:202
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition: world.h:328
WorldGopInterface & gop
Global operations.
Definition: world.h:205
bool dofence() const
Check if we should fence around a read/write operation.
Definition: parallel_archive.h:295
Archive & local_archive() const
Returns a reference to the local archive.
Definition: parallel_archive.h:248
World * get_world() const
Returns a pointer to the world.
Definition: parallel_archive.h:130
bool is_io_node() const
Returns true if this node is doing physical I/O.
Definition: parallel_archive.h:122
int num_io_clients() const
Returns the number of I/O clients for this node, including self (zero if not an I/O node).
Definition: parallel_archive.h:114
ProcessID io_node(ProcessID rank) const
Returns the process doing I/O for given node.
Definition: parallel_archive.h:99
ProcessID my_io_node() const
Returns the process doing I/O for this node.
Definition: parallel_archive.h:106
Wraps an archive around a memory buffer for output.
Definition: buffer_archive.h:59
std::size_t size() const
Return the amount of data stored (counted) in the buffer.
Definition: buffer_archive.h:123
Archive allowing buffering, serialization of data, and point-to-point communication between processes...
Definition: mpi_archive.h:118
void flush() const
Send all data in the buffer to the destination process.
Definition: mpi_archive.h:158
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition: parallel_archive.h:321
Objects that implement their own parallel archive interface should derive from this class.
Definition: parallel_archive.h:58
Wraps an archive around an STL vector for output.
Definition: vector_archive.h:55
Class for unique global IDs.
Definition: uniqueid.h:53
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition: derivatives.cc:72
void run(World &world, ansatzT ansatz, const int nuclear_charge, const commandlineparser &parser, const int nstates)
Definition: dirac-hatom.cc:1388
void swap(WorldContainer< keyT, valueT, hashfunT > &, WorldContainer< keyT, valueT, hashfunT > &)
Swaps the content of two WorldContainer objects. It should be called on all nodes.
Definition: worlddc.h:1765
static void load(const ParallelInputArchive< localarchiveT > &ar, WorldContainer< keyT, valueT > &t)
Read container from parallel archive.
Definition: worlddc.h:2051
static const double v
Definition: hatom_sf_dirac.cc:20
#define max(a, b)
Definition: lda.h:51
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition: madness_exception.h:190
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
Implements archives to serialize data for MPI.
void deferred_cleanup(World &world, const std::shared_ptr< objT > &p, bool assume_p_is_unique=false)
Defer the cleanup of a shared pointer to the end of the next fence.
Definition: deferred_cleanup.h:135
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition: print.h:225
Function< T, NDIM > sum(World &world, const std::vector< Function< T, NDIM > > &f, bool fence=true)
Returns new function — q = sum_i f[i].
Definition: vmra.h:1421
NDIM & f
Definition: mra.h:2416
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition: timers.cc:48
void swap(Vector< T, N > &l, Vector< T, N > &r)
Swap the contents of two Vectors.
Definition: vector.h:497
void advance(madness::Hash_private::HashIterator< hashT > &it, const distT &dist)
Definition: worldhashmap.h:610
Implements ParallelInputArchive and ParallelOutputArchive for parallel serialization of data.
Definition: worlddc.h:800
bool operator()(typename rangeT::iterator &iterator) const
Definition: worlddc.h:805
implT * impl
Definition: worlddc.h:801
P2Op(const P2Op &p)
Definition: worlddc.h:804
P2Op(implT *impl)
Definition: worlddc.h:803
Range< typename std::vector< keyT >::const_iterator > rangeT
Definition: worlddc.h:802
Default load of an object via serialize(ar, t).
Definition: archive.h:666
static void postamble_store(const Archive &)
By default there is no postamble.
Definition: archive.h:545
static void preamble_store(const Archive &ar)
Serialize a cookie for type checking.
Definition: archive.h:535
static void store(const ParallelOutputArchive< VectorOutputArchive > &ar, const WorldContainer< keyT, valueT > &t)
Definition: worlddc.h:1781
static void store(const ParallelOutputArchive< localarchiveT > &ar, const WorldContainer< keyT, valueT > &t)
Definition: worlddc.h:1982
Default store of an object via serialize(ar, t).
Definition: archive.h:611
#define MPI_INT
Definition: stubmpi.h:78
#define MPI_BYTE
Definition: stubmpi.h:74
std::pair< int, double > valueT
Definition: test_binsorter.cc:6
int me
Definition: test_binsorter.cc:10
const double offset
Definition: testfuns.cc:143
double source(const coordT &r)
Definition: testperiodic.cc:48
#define REMFUTURE(T)
Macro to determine type of future (by removing wrapping Future template).
Definition: type_traits.h:162
#define MEMFUN_RETURNT(MEMFUN)
Macro to make member function type traits easier to use.
Definition: type_traits.h:697
Defines and implements WorldObject.
Defines and implements a concurrent hashmap.
int ProcessID
Used to clearly identify process number/rank.
Definition: worldtypes.h:43
int Tag
Used to clearly identify message tag/type.
Definition: worldtypes.h:44