Beispiel #1
0
    GatherNode(const ParentDIA& parent,
               size_t target_id,
               std::vector<ValueType>* out_vector,
               StatsNode* stats_node)
        : ActionNode(parent.ctx(), { parent.node() }, stats_node),
          target_id_(target_id),
          out_vector_(out_vector),
          stream_(parent.ctx().GetNewCatStream()),
          emitters_(stream_->OpenWriters())
    {
        assert(target_id_ < context_.num_workers());

        auto pre_op_function =
            [=](const ValueType& input) {
                emitters_[target_id_](input);
            };

        // close the function stack with our pre op and register it at parent
        // node for output
        auto lop_chain = parent.stack().push(pre_op_function).emit();
        parent.node()->RegisterChild(lop_chain, this->type());

        // close all but the target
        for (size_t i = 0; i < emitters_.size(); i++) {
            if (i == target_id_) continue;
            emitters_[i].Close();
        }
    }
Beispiel #2
0
 explicit CollapseNode(const ParentDIA& parent)
     : Super(parent.ctx(), "Collapse", { parent.id() }, { parent.node() }),
       parent_stack_empty_(ParentDIA::stack_empty) {
     auto propagate_fn = [this](const ValueType& input) {
                             this->PushItem(input);
                         };
     auto lop_chain = parent.stack().push(propagate_fn).fold();
     parent.node()->AddChild(this, lop_chain);
 }
Beispiel #3
0
    explicit RebalanceNode(const ParentDIA& parent)
        : Super(parent.ctx(), "Rebalance", { parent.id() }, { parent.node() }),
          parent_stack_empty_(ParentDIA::stack_empty) {

        auto save_fn = [this](const ValueType& input) {
                           writer_.Put(input);
                       };
        auto lop_chain = parent.stack().push(save_fn).fold();
        parent.node()->AddChild(this, lop_chain);
    }
Beispiel #4
0
    /*!
     * Constructor for a LOpNode. Sets the Context, parents and stack.
     *
     * \param parent Parent DIA.
     */
    CollapseNode(const ParentDIA& parent,
                 StatsNode* stats_node)
        : DIANode<ValueType>(parent.ctx(), { parent.node() }, stats_node)
    {
        // CollapseNodes are kept by default.
        Super::consume_on_push_data_ = false;

        auto propagate_fn = [=](const ValueType& input) {
                                this->PushItem(input);
                            };
        auto lop_chain = parent.stack().push(propagate_fn).emit();
        parent.node()->RegisterChild(lop_chain, this->type());
    }
Beispiel #5
0
    SumNode(const ParentDIA& parent,
            const SumFunction& sum_function,
            const ValueType& initial_value,
            StatsNode* stats_node)
        : ActionNode(parent.ctx(), { parent.node() }, stats_node),
          sum_function_(sum_function),
          local_sum_(initial_value)
    {
        // Hook PreOp(s)
        auto pre_op_fn = [=](const ValueType& input) {
                             PreOp(input);
                         };

        auto lop_chain = parent.stack().push(pre_op_fn).emit();
        parent.node()->RegisterChild(lop_chain, this->type());
    }
Beispiel #6
0
    PrefixSumNode(const ParentDIA& parent,
                  const char* label,
                  const SumFunction& sum_function,
                  const ValueType& initial_element)
        : Super(parent.ctx(), label, { parent.id() }, { parent.node() }),
          sum_function_(sum_function),
          local_sum_(),
          initial_element_(initial_element),
          parent_stack_empty_(ParentDIA::stack_empty) {
        // Hook PreOp(s)
        auto pre_op_fn = [this](const ValueType& input) {
                             PreOp(input);
                         };

        auto lop_chain = parent.stack().push(pre_op_fn).fold();
        parent.node()->AddChild(this, lop_chain);
    }
Beispiel #7
0
    GatherNode(const ParentDIA& parent, const char* label,
               size_t target_id,
               std::vector<ValueType>* out_vector)
        : Super(parent.ctx(), label,
                { parent.id() }, { parent.node() }),
          target_id_(target_id),
          out_vector_(out_vector)
    {
        assert(target_id_ < context_.num_workers());

        auto pre_op_fn = [this](const ValueType& input) {
                             emitters_[target_id_].Put(input);
                         };

        // close the function stack with our pre op and register it at parent
        // node for output
        auto lop_chain = parent.stack().push(pre_op_fn).fold();
        parent.node()->AddChild(this, lop_chain);
    }
Beispiel #8
0
    WriteLinesNode(const ParentDIA& parent,
                   const std::string& path_out,
                   StatsNode* stats_node)
        : ActionNode(parent.ctx(), { parent.node() }, stats_node),
          path_out_(path_out),
          file_(path_out_, std::ios::binary),
          temp_file_(context_.GetFile()),
          writer_(&temp_file_)
    {
        sLOG << "Creating write node.";

        auto pre_op_fn = [=](const Input& input) {
                             PreOp(input);
                         };
        // close the function stack with our pre op and register it at parent
        // node for output
        auto lop_chain = parent.stack().push(pre_op_fn).emit();
        parent.node()->RegisterChild(lop_chain, this->type());
    }