-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#410: term: generalize parent/child epoch relation
- Loading branch information
1 parent
24e01d5
commit ef9a5a7
Showing
6 changed files
with
205 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters