35 #ifndef MADNESS_WORLD_GROUP_H__INCLUDED 
   36 #define MADNESS_WORLD_GROUP_H__INCLUDED 
   59             std::vector<ProcessID> group_to_world_map_; 
 
   70             template <
typename T, std::
size_t N>
 
   71             static T* begin(
T (&
a)[
N]) { 
return a; }
 
   79             template <
typename T, std::
size_t N>
 
   80             static T* end(
T (&
a)[N]) { 
return (
a + N); }
 
   88             template <
typename T, std::
size_t N>
 
   89             static std::size_t 
size(
T (&)[N]) { 
return N; }
 
   96             template <
typename vectorT>
 
   97             static typename vectorT::const_iterator begin(
const vectorT &v) {
 
  106             template <
typename vectorT>
 
  107             static typename vectorT::const_iterator end(
const vectorT &v) {
 
  116             template <
typename vectorT>
 
  118             size(
const vectorT &v) { 
return v.size(); }
 
  127             template <
typename A>
 
  129                 world_(world), did_(did),
 
  130                 group_to_world_map_(begin(group), end(group)),
 
  131                 group_rank_(-1), local_count_(), remote_count_()
 
  134                 MADNESS_ASSERT(
size(group) > 0ul);
 
  137                 std::sort(group_to_world_map_.begin(), group_to_world_map_.end());
 
  138                 group_to_world_map_.erase(std::unique(group_to_world_map_.begin(),
 
  139                         group_to_world_map_.end()), group_to_world_map_.end());
 
  142                 MADNESS_ASSERT(group_to_world_map_.front() >= 0);
 
  143                 MADNESS_ASSERT(group_to_world_map_.back() < world_.
size());
 
  147                 MADNESS_ASSERT(group_rank_ != -1);
 
  176                         std::find(group_to_world_map_.begin(), group_to_world_map_.end(),
 
  178                 if(static_cast<std::size_t>(result) == group_to_world_map_.size())
 
  186             ProcessID size()
 const { 
return group_to_world_map_.size(); }
 
  192                 MADNESS_ASSERT(group_rank >= 0);
 
  193                 MADNESS_ASSERT(group_rank < 
ProcessID(group_to_world_map_.size()));
 
  194                 return group_to_world_map_[group_rank];
 
  206                 const ProcessID group_size = group_to_world_map_.size();
 
  209                 MADNESS_ASSERT(group_root >= 0);
 
  210                 MADNESS_ASSERT(group_root < group_size);
 
  213                 const ProcessID me = (group_rank_ + group_size - group_root) % group_size;
 
  216                 parent = (me == 0 ? -1 : group_to_world_map_[(((me - 1) >> 1) + group_root) % group_size]);
 
  219                 child0 = (me << 1) + 1 + group_root;
 
  222                 const ProcessID end = group_size + group_root;
 
  224                     child0 = group_to_world_map_[child0 % group_size];
 
  228                     child1 = group_to_world_map_[child1 % group_size];
 
  247                 const int count = (remote_count_ += n);
 
  249                     Group::unregister_group(did_);
 
  256             static void deleter(Impl* pimpl) {
 
  261                 pimpl->remote_update(-(pimpl->local_count_));
 
  275         void register_group() 
const;
 
  284         Group(Impl* pimpl) : pimpl_(pimpl) { }
 
  307         template <
typename A>
 
  309             pimpl_(new Impl(world, group, did), Impl::deleter)
 
  323         template <
typename A>
 
  340         template <
typename A>
 
  342             pimpl_(new Impl(world, group, 
DistributedID(uid, tag)), Impl::deleter)
 
  352             pimpl_ = other.pimpl_;
 
  373             MADNESS_ASSERT(pimpl_);
 
  374             pimpl_->local_update();
 
  387             MADNESS_ASSERT(pimpl_);
 
  388             pimpl_->remote_update(1);
 
  394         bool empty()
 const { 
return !pimpl_; }
 
  400             MADNESS_ASSERT(pimpl_);
 
  408             MADNESS_ASSERT(pimpl_);
 
  409             return pimpl_->get_world();
 
  416             MADNESS_ASSERT(pimpl_);
 
  417             return pimpl_->rank();
 
  425             MADNESS_ASSERT(pimpl_);
 
  426             return pimpl_->rank(world_rank);
 
  433             return (pimpl_ ? pimpl_->size() : 0);
 
  441             MADNESS_ASSERT(pimpl_);
 
  442             return pimpl_->world_rank(group_rank);
 
  455             MADNESS_ASSERT(pimpl_);
 
  456             pimpl_->make_tree(group_root, parent, child1, child2);
 
  459         template <
typename Archive>
 
  461             MADNESS_ASSERT(
false); 
 
  467 #endif // MADNESS_WORLD_GROUP_H__INCLUDED 
void serialize(const Archive &)
Definition: group.h:460
Group(World &world, const A &group, const DistributedID &did)
Create a new group. 
Definition: group.h:308
Definition: uniqueid.h:46
void local_update() const 
Update local usage count. 
Definition: group.h:372
ProcessID size() const 
Returns the number of processes in this world (same as MPI_Comm_size()) 
Definition: worldfwd.h:533
ProcessID rank(const ProcessID world_rank) const 
Map world rank to group rank. 
Definition: group.h:424
void remote_update() const 
Update remote usage count. 
Definition: group.h:386
ProcessID rank() const 
Group rank accessor. 
Definition: group.h:415
disable_if from Boost for conditionally instantiating templates based on type 
Definition: enable_if.h:78
bool empty() const 
Quary empty group. 
Definition: group.h:394
ProcessID world_rank(const ProcessID group_rank) const 
Map group rank to world rank. 
Definition: group.h:440
Group(const Group &other)
Copy constructor. 
Definition: group.h:297
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
const double N
Definition: navstokes_cosines.cc:94
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
Group()
Default constructor. 
Definition: group.h:291
ProcessID size() const 
Group size accessor. 
Definition: group.h:432
An integer with atomic set, get, read+inc, read+dec, dec+test operations. 
Definition: atomicint.h:73
World & get_world() const 
Parent world accessor. 
Definition: group.h:407
A parallel world with full functionality wrapping an MPI communicator. 
Definition: worldfwd.h:416
void make_tree(const ProcessID group_root, ProcessID &parent, ProcessID &child1, ProcessID &child2) const 
Compute the binary tree parents and children. 
Definition: group.h:452
const DistributedID & id() const 
Group id accessor. 
Definition: group.h:399
int ProcessID
Used to clearly identify process number/rank. 
Definition: worldtypes.h:37
int distance(const madness::Hash_private::HashIterator< hashT > &it, const madness::Hash_private::HashIterator< hashT > &jt)
Definition: worldhashmap.h:608
std::pair< uniqueidT, std::size_t > DistributedID
Distributed ID which is used to identify objects. 
Definition: dist_keys.h:44
ProcessID rank() const 
Returns the process rank in this world (same as MPI_Comm_rank())) 
Definition: worldfwd.h:526
static madness::Future< Group > get_group(const DistributedID &did)
Get group from the registry. 
Definition: group.cc:89
A collection of processes. 
Definition: group.h:52
Group(World &world, const A &group, const uniqueidT &uid, const std::size_t tag)
Create a new group. 
Definition: group.h:341
Defines TaskInterface and implements WorldTaskQueue and associated stuff. 
Group & operator=(const Group &other)
Copy assignment operator. 
Definition: group.h:351
A future is a possibly yet unevaluated value. 
Definition: ref.h:210
Implements MadnessException. 
Group(World &world, const A &group, const std::size_t tag)
Create a new group. 
Definition: group.h:324
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces. 
Definition: chem/atomutil.cc:45