Skip to content

Commit

Permalink
Updates for the tagging tape.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSagebaum committed Dec 27, 2024
1 parent 0dc6ac0 commit 8b1dd95
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
2 changes: 0 additions & 2 deletions include/codi/tapes/tagging/tagTapeReverse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ namespace codi {

/// Verify tag.
bool isIdentifierActive(Identifier const& index) const {
Base::verifyTag(index.tag);

return index.tag != Base::PassiveTag;
}

Expand Down
10 changes: 5 additions & 5 deletions include/codi/tools/helpers/preaccumulationHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,7 @@ namespace codi {
* and the outputs.
*/
template<typename T_Type>
struct PreaccumulationHelper<
T_Type, typename enable_if_same<typename T_Type::Tape,
TagTapeReverse<typename T_Type::Real, typename T_Type::Tape::Tag>>::type> {
struct PreaccumulationHelper<T_Type, TapeTraits::EnableIfTagTapeReverse<typename T_Type::Tape>> {
public:

using Type = CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION); ///< See PreaccumulationHelper.
Expand Down Expand Up @@ -668,8 +666,10 @@ namespace codi {
}

void handleInput(Type const& input) {
inputLocations.push_back(&input);
getTape().setTagOnVariable(input);
if (Type::getTape().getPassiveIndex() != input.getIdentifier()) {
inputLocations.push_back(&input);
getTape().setTagOnVariable(input);
}
}

/// Terminator for the recursive implementation.
Expand Down
45 changes: 45 additions & 0 deletions include/codi/traits/tapeTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,51 @@ namespace codi {
template<typename Tape>
using EnableIfNoEditing = typename std::enable_if<!SupportsEditing<Tape>::value>::type;


/// If the tape inherits from TagTapeBase.
template<typename Tape, typename = void>
struct IsTagTape : std::false_type {};

#ifndef DOXYGEN_DISABLE
template<typename Tape>
struct IsTagTape<Tape, typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
: std::true_type {};

template<typename Tape>
struct IsTagTape<Tape, typename enable_if_base_of<TagTapeForward<typename Tape::Real, typename Tape::Tag>, Tape>::type>
: std::true_type {};
#endif

#if CODI_IS_CPP14
/// Value entry of IsTagTape
template<typename Tape>
bool constexpr isTagTape = IsTagTape<Tape>::value;
#endif

/// Enable if wrapper for IsTagTape
template<typename Tape>
using EnableIfTagTape = typename std::enable_if<IsTagTape<Tape>::value>::type;

/// If the tape inherits from TagTapeReverse.
template<typename Tape, typename = void>
struct IsTagTapeReverse : std::false_type {};

#ifndef DOXYGEN_DISABLE
template<typename Tape>
struct IsTagTapeReverse<Tape, typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
: std::true_type {};
#endif

#if CODI_IS_CPP14
/// Value entry of IsTagTape
template<typename Tape>
bool constexpr isTagTapeReverse = IsTagTapeReverse<Tape>::value;
#endif

/// Enable if wrapper for IsTagTape
template<typename Tape>
using EnableIfTagTapeReverse = typename std::enable_if<IsTagTapeReverse<Tape>::value>::type;

/// @}
}
}

0 comments on commit 8b1dd95

Please sign in to comment.