16 incoming_(&master__->incoming(gid__)),
17 outgoing_(&master__->outgoing(gid__)),
20 int gid()
const {
return gid_; }
28 { OutgoingQueues& out = *outgoing_;
save(out[to], x); }
46 { IncomingQueues&
in = *incoming_;
load(in[from], x); }
58 EnqueueIterator<T> enqueuer(
const T& x,
60 {
return EnqueueIterator<T>(
this, x,
save); }
62 IncomingQueues* incoming()
const {
return incoming_; }
63 MemoryBuffer& incoming(
int from)
const {
return (*incoming_)[from]; }
64 inline void incoming(std::vector<int>& v)
const;
66 OutgoingQueues* outgoing()
const {
return outgoing_; }
67 MemoryBuffer& outgoing(
const BlockID& to)
const {
return (*outgoing_)[to]; }
76 template<
class T,
class Op>
85 inline T
read()
const;
94 inline void scratch(
const T&
in)
const;
102 Master* master()
const {
return master_; }
107 IncomingQueues* incoming_;
108 OutgoingQueues* outgoing_;
109 CollectivesList* collectives_;
113 struct Master::Proxy::EnqueueIterator:
114 public std::iterator<std::output_iterator_tag, void, void, void, void>
116 typedef void (*SaveT)(BinaryBuffer&,
const T&);
118 EnqueueIterator(
const Proxy* proxy,
const T& x,
119 SaveT
save = &::diy::save<T>):
120 proxy_(proxy), x_(x), save_(
save) {}
122 EnqueueIterator& operator=(
const BlockID& to) { proxy_->
enqueue(to, x_, save_);
return *
this; }
123 EnqueueIterator& operator*() {
return *
this; }
124 EnqueueIterator& operator++() {
return *
this; }
125 EnqueueIterator& operator++(
int) {
return *
this; }
143 Link* link()
const {
return link_; }
144 void* block()
const {
return block_; }
155 incoming(std::vector<int>& v)
const
157 for (IncomingQueues::const_iterator it = incoming_->begin(); it != incoming_->end(); ++it)
158 v.push_back(it->first);
161 template<
class T,
class Op>
166 collectives_->push_back(
Collective(
new detail::AllReduceOp<T,Op>(in, op)));
175 collectives_->front().result_out(&res);
185 collectives_->pop_front();
192 scratch(
const T&
in)
const
194 collectives_->push_back(
Collective(
new detail::Scratch<T>(in)));
203 OutgoingQueues& out = *outgoing_;
208 for (
size_t i = 0; i < n; ++i)
218 IncomingQueues& in = *incoming_;
220 if (load == (
void (*)(
BinaryBuffer&, T&)) &::diy::load<T>)
223 for (
size_t i = 0; i < n; ++i)
void load(BinaryBuffer &bb, T &x)
Loads x from bb by calling diy::Serialization<T>::load(bb,x).
Definition: serialization.hpp:106
void dequeue(int from, T &x, void(*load)(BinaryBuffer &, T &)=&::diy::load< T >) const
Dequeue data whose size can be determined automatically (e.g., STL vector) and that was previously en...
Definition: proxy.hpp:42
Definition: master.hpp:356
T get() const
Return the result of a proxy collective; result is popped off the collectives list.
Definition: proxy.hpp:182
Definition: proxy.hpp:134
void all_reduce(const T &in, Op op) const
Post an all-reduce collective using an existing communication proxy. Available operators are: maximum...
Definition: proxy.hpp:164
void save(BinaryBuffer &bb, const T &x)
Saves x to bb by calling diy::Serialization<T>::save(bb,x).
Definition: serialization.hpp:102
void in(const RegularLink< Bounds > &link, const Point &p, OutIter out, const Bounds &domain)
Finds the neighbor(s) containing the target point.
Definition: pick.hpp:102
Definition: master.hpp:35
Communication proxy, used for enqueueing and dequeueing items for future exchange.
Definition: proxy.hpp:8
T read() const
Return the result of a proxy collective without popping it off the collectives list (same result woul...
Definition: proxy.hpp:172
A serialization buffer.
Definition: serialization.hpp:19
CollectivesList * collectives() const
Return the list of proxy collectives (values and operations)
Definition: proxy.hpp:100
void enqueue(const BlockID &to, const T &x, void(*save)(BinaryBuffer &, const T &)=&::diy::save< T >) const
Enqueue data whose size can be determined automatically, e.g., an STL vector.
Definition: proxy.hpp:24