13 #ifndef THRILL_API_ALL_GATHER_HEADER 14 #define THRILL_API_ALL_GATHER_HEADER 27 template <
typename ValueType>
30 static constexpr
bool debug =
false;
36 template <
typename ParentDIA>
38 std::vector<ValueType>* out_vector,
bool ownership)
39 :
Super(parent.ctx(),
"AllGather",
40 { parent.id() }, { parent.node() }),
43 auto pre_op_function = [
this](
const ValueType& input) {
49 auto lop_chain = parent.stack().push(pre_op_function).fold();
50 parent.node()->AddChild(
this, lop_chain);
62 void PreOp(
const ValueType& element) {
63 for (
size_t i = 0; i <
emitters_.size(); i++) {
71 <<
"AllGather rejected File from parent " 72 <<
"due to non-empty function stack.";
75 for (
size_t i = 0; i <
emitters_.size(); i++) {
88 auto reader =
stream_->GetCatReader(
true);
89 while (reader.HasNext()) {
90 out_vector_->push_back(reader.template Next<ValueType>());
95 const std::vector<ValueType>&
result() const final {
113 template <
typename ValueType,
typename Stack>
119 std::vector<ValueType> output;
121 auto node = tlx::make_counting<AllGatherNode>(
122 *
this, &output,
false);
129 template <
typename ValueType,
typename Stack>
135 auto node = tlx::make_counting<AllGatherNode>(
136 *
this, out_vector,
false);
141 template <
typename ValueType,
typename Stack>
148 std::vector<ValueType>* output =
new std::vector<ValueType>();
150 auto node = tlx::make_counting<AllGatherNode>(
151 *
this, output,
true);
159 #endif // !THRILL_API_ALL_GATHER_HEADER
data::CatStreamPtr stream_
std::vector< ValueType > AllGather() const
Returns the whole DIA in an std::vector on each worker.
const bool parent_stack_empty_
Whether the parent stack is empty.
void StartPreOp(size_t) final
Virtual method for preparing start of PushData.
A File is an ordered sequence of Block objects for storing items.
void PreOp(const ValueType &element)
bool OnPreOpFile(const data::File &file, size_t) final
void reset()
release contained pointer, frees object if this is the last reference.
static constexpr bool g_debug_push_file
AllGatherNode(const ParentDIA &parent, std::vector< ValueType > *out_vector, bool ownership)
bool ownership_
take ownership of vector
void Close()
custom destructor to close writers is a cyclic fashion
An extra class derived from std::vector<> for delivery of the BlockWriters of a Stream.
data::CatStreamPtr GetNewCatStream(size_t dia_id)
static constexpr bool debug
data::CatStream::Writers emitters_
const std::vector< ValueType > & result() const final
virtual method to return result via an ActionFuture
Future< std::vector< ValueType > > AllGatherFuture() const
Returns the whole DIA in an std::vector on each worker.
The return type class for all ActionFutures.
void StopPreOp(size_t) final
Virtual method for preparing end of PushData.
std::vector< ValueType > * out_vector_
Vector pointer to write elements to.
void Execute() final
Closes the output file.
Context & context_
associated Context
#define LOGC(cond)
Explicitly specify the condition for logging.