Skip to content

Commit

Permalink
#410: term: generalize parent/child epoch relation
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Jun 19, 2019
1 parent 24e01d5 commit ef9a5a7
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 78 deletions.
37 changes: 3 additions & 34 deletions src/vt/termination/dijkstra-scholten/ds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,11 @@

namespace vt { namespace term { namespace ds {

template <typename CommType>
void TermDS<CommType>::addParentEpoch(EpochType const in_parent) {
debug_print(
termds, node,
"addParentEpoch: epoch_={:x}, parent={:x}\n", epoch_, in_parent
);

// Produce a single work unit for the parent epoch so it can not finish while
// this epoch is live
theTerm()->produce(in_parent,1);
parents_.push_back(in_parent);
}

template <typename CommType>
void TermDS<CommType>::clearParents() {
debug_print(
termds, node,
"clearParents: epoch={:x}, parents_.size()={}\n", epoch_,
parents_.size()
);

for (auto&& in_parent : parents_) {
debug_print(
termds, node,
"clearParents: epoch={:x}, parent={:x}\n", epoch_, in_parent
);
theTerm()->consume(in_parent,1);
}
parents_.clear();
}

template <typename CommType>
TermDS<CommType>::TermDS(EpochType in_epoch, bool isRoot_, NodeType self_)
: parent(-1), self(self_), C(0), ackedArbitrary(0), ackedParent(0),
reqedParent(0), engagementMessageCount(0), D(0), processedSum(C),
epoch_(in_epoch)
: EpochRelation(in_epoch, true),
parent(-1), self(self_), C(0), ackedArbitrary(0), ackedParent(0),
reqedParent(0), engagementMessageCount(0), D(0), processedSum(C)
{
setRoot(isRoot_);
}
Expand Down
9 changes: 2 additions & 7 deletions src/vt/termination/dijkstra-scholten/ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "vt/config.h"
#include "vt/termination/dijkstra-scholten/ack_request.h"
#include "vt/termination/dijkstra-scholten/comm.fwd.h"
#include "vt/termination/term_parent.h"

#include <cstdlib>
#include <map>
Expand Down Expand Up @@ -75,7 +76,7 @@ namespace vt { namespace term { namespace ds {
*/

template <typename CommType>
struct TermDS {
struct TermDS : EpochRelation {
using CountType = int64_t;
using AckReqListType = std::list<AckRequest>;

Expand All @@ -98,10 +99,6 @@ struct TermDS {
private:
void tryLast();

public:
void addParentEpoch(EpochType const in_parent);
void clearParents();

protected:
NodeType parent = uninitialized_destination;
NodeType self = uninitialized_destination;
Expand All @@ -112,11 +109,9 @@ struct TermDS {
CountType engagementMessageCount = 0;
CountType D = 0;
CountType processedSum = 0;
EpochType epoch_ = no_epoch;
CountType lC = 0;
CountType lD = 0;
AckReqListType outstanding = {};
std::vector<EpochType> parents_ = {};
};

}}} /* end namespace vt::term::ds */
Expand Down
115 changes: 115 additions & 0 deletions src/vt/termination/term_parent.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
//@HEADER
// ************************************************************************
//
// term_parent.cc
// vt (Virtual Transport)
// Copyright (C) 2018 NTESS, LLC
//
// Under the terms of Contract DE-NA-0003525 with NTESS, LLC,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact [email protected]
//
// ************************************************************************
//@HEADER
*/

#include "vt/config.h"
#include "vt/termination/termination.h"

namespace vt { namespace term {

void EpochRelation::addParentEpoch(EpochType const in_parent) {
if (is_ds_) {
debug_print(
termds, node,
"addParentEpoch: epoch_={:x}, parent={:x}\n", epoch_, in_parent
);
} else {
debug_print(
term, node,
"addParentEpoch: epoch_={:x}, parent={:x}\n", epoch_, in_parent
);
}

// Produce a single work unit for the parent epoch so it can not finish while
// this epoch is live
theTerm()->produce(in_parent,1);
parents_.insert(in_parent);
}

void EpochRelation::clearParents() {
if (is_ds_) {
debug_print(
termds, node,
"clearParents: epoch={:x}, parents_.size()={}\n", epoch_,
parents_.size()
);
} else {
debug_print(
term, node,
"clearParents: epoch={:x}, parents_.size()={}\n", epoch_,
parents_.size()
);
}

for (auto&& parent : parents_) {
if (is_ds_) {
debug_print(
termds, node,
"clearParents: epoch={:x}, parent={:x}\n", epoch_, parent
);
} else {
debug_print(
term, node,
"clearParents: epoch={:x}, parent={:x}\n", epoch_,parent
);
}

// Consume the parent epoch to release it so it can now possibly complete
// since the child is terminated
theTerm()->consume(parent,1);
}

// Clear the parent list
parents_.clear();
}

bool EpochRelation::hasParent() const {
return parents_.size() > 0;
}

std::size_t EpochRelation::numParents() const {
return parents_.size();
}


}} /* end namespace vt::term */
79 changes: 79 additions & 0 deletions src/vt/termination/term_parent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
//@HEADER
// ************************************************************************
//
// term_parent.h
// vt (Virtual Transport)
// Copyright (C) 2018 NTESS, LLC
//
// Under the terms of Contract DE-NA-0003525 with NTESS, LLC,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact [email protected]
//
// ************************************************************************
//@HEADER
*/

#if !defined INCLUDED_VT_TERMINATION_TERM_PARENT_H
#define INCLUDED_VT_TERMINATION_TERM_PARENT_H

#include "vt/config.h"
#include "vt/epoch/epoch.h"

#include <unordered_set>

namespace vt { namespace term {

struct EpochRelation {

EpochRelation(EpochType in_epoch, bool in_is_ds)
: epoch_(in_epoch), is_ds_(in_is_ds)
{ }

void addParentEpoch(EpochType const in_parent);
void clearParents();
bool hasParent() const;
std::size_t numParents() const;

protected:
// The epoch for the this relation
EpochType epoch_ = no_epoch;

private:
// Is this a DS-epoch
bool is_ds_ = false;
// The parent epochs for a given epoch
std::unordered_set<EpochType> parents_ = {};
};

}} /* end namespace vt::term */

#endif /*INCLUDED_VT_TERMINATION_TERM_PARENT_H*/
36 changes: 4 additions & 32 deletions src/vt/termination/term_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,6 @@

namespace vt { namespace term {

void TermState::addParentEpoch(EpochType const parent) {
debug_print(
term, node,
"addParentEpoch: epoch={:x}, parent={:x}\n", epoch_, parent
);

// Produce a single work unit on the parent epoch so it can not finish while
// this epoch is live
theTerm()->produce(parent,1);
parents_.push_back(parent);
}

void TermState::clearParents() {
debug_print(
term, node,
"clearParents: epoch={:x}, parents_.size()={}\n", epoch_,
parents_.size()
);

for (auto&& parent : parents_) {
debug_print(
term, node,
"clearParents: epoch={:x}, parent={:x}\n", epoch_, parent
);
theTerm()->consume(parent,1);
}
parents_.clear();
}

TermWaveType TermState::getCurWave() const {
return cur_wave_;
}
Expand Down Expand Up @@ -169,8 +140,9 @@ TermState::TermState(
EpochType const& in_epoch, bool const in_local_terminated, bool const active,
NodeType const& children
)
: local_terminated_(in_local_terminated), epoch_active_(active),
num_children_(children), epoch_(in_epoch)
: EpochRelation(in_epoch, false),
local_terminated_(in_local_terminated), epoch_active_(active),
num_children_(children)
{
debug_print(
term, node,
Expand All @@ -181,7 +153,7 @@ TermState::TermState(
}

TermState::TermState(EpochType const& in_epoch, NodeType const& children)
: num_children_(children), epoch_(in_epoch)
: EpochRelation(in_epoch, false), num_children_(children)
{
debug_print(
term, node,
Expand Down
7 changes: 2 additions & 5 deletions src/vt/termination/term_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@
#include "vt/config.h"
#include "vt/context/context.h"
#include "vt/termination/term_common.h"
#include "vt/termination/term_parent.h"

#include <vector>
#include <cstdlib>
#include <cassert>

namespace vt { namespace term {

struct TermState {
struct TermState : EpochRelation {
using EventCountType = int32_t;

void notifyChildReceive();
Expand All @@ -72,8 +73,6 @@ struct TermState {
void setCurWave(TermWaveType const& wave);
NodeType getNumChildren() const;
bool noLocalUnits() const;
void addParentEpoch(EpochType const epoch);
void clearParents();

TermState(
EpochType const& in_epoch, bool const in_local_terminated, bool const active,
Expand Down Expand Up @@ -105,10 +104,8 @@ struct TermState {

EventCountType recv_child_count_ = 0;
NodeType num_children_ = uninitialized_destination;
EpochType epoch_ = no_epoch;
TermWaveType cur_wave_ = 0;
TermWaveType submitted_wave_ = -1;
std::vector<EpochType> parents_ = {};
};

}} //end namespace vt::term
Expand Down

0 comments on commit ef9a5a7

Please sign in to comment.