From 8b1dd955bb59f5a1d05a11acfd6fb82899a78c07 Mon Sep 17 00:00:00 2001 From: Max Sagebaum Date: Fri, 27 Dec 2024 12:23:13 +0100 Subject: [PATCH] Updates for the tagging tape. --- include/codi/tapes/tagging/tagTapeReverse.hpp | 2 - .../tools/helpers/preaccumulationHelper.hpp | 10 ++--- include/codi/traits/tapeTraits.hpp | 45 +++++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/include/codi/tapes/tagging/tagTapeReverse.hpp b/include/codi/tapes/tagging/tagTapeReverse.hpp index 4942e096..8c50d9bb 100644 --- a/include/codi/tapes/tagging/tagTapeReverse.hpp +++ b/include/codi/tapes/tagging/tagTapeReverse.hpp @@ -269,8 +269,6 @@ namespace codi { /// Verify tag. bool isIdentifierActive(Identifier const& index) const { - Base::verifyTag(index.tag); - return index.tag != Base::PassiveTag; } diff --git a/include/codi/tools/helpers/preaccumulationHelper.hpp b/include/codi/tools/helpers/preaccumulationHelper.hpp index f5d606bb..95c9b7e1 100644 --- a/include/codi/tools/helpers/preaccumulationHelper.hpp +++ b/include/codi/tools/helpers/preaccumulationHelper.hpp @@ -560,9 +560,7 @@ namespace codi { * and the outputs. */ template - struct PreaccumulationHelper< - T_Type, typename enable_if_same>::type> { + struct PreaccumulationHelper> { public: using Type = CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION); ///< See PreaccumulationHelper. @@ -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. diff --git a/include/codi/traits/tapeTraits.hpp b/include/codi/traits/tapeTraits.hpp index 134e15ae..b526c5c8 100644 --- a/include/codi/traits/tapeTraits.hpp +++ b/include/codi/traits/tapeTraits.hpp @@ -183,6 +183,51 @@ namespace codi { template using EnableIfNoEditing = typename std::enable_if::value>::type; + + /// If the tape inherits from TagTapeBase. + template + struct IsTagTape : std::false_type {}; + +#ifndef DOXYGEN_DISABLE + template + struct IsTagTape, Tape>::type> + : std::true_type {}; + + template + struct IsTagTape, Tape>::type> + : std::true_type {}; +#endif + +#if CODI_IS_CPP14 + /// Value entry of IsTagTape + template + bool constexpr isTagTape = IsTagTape::value; +#endif + + /// Enable if wrapper for IsTagTape + template + using EnableIfTagTape = typename std::enable_if::value>::type; + + /// If the tape inherits from TagTapeReverse. + template + struct IsTagTapeReverse : std::false_type {}; + +#ifndef DOXYGEN_DISABLE + template + struct IsTagTapeReverse, Tape>::type> + : std::true_type {}; +#endif + +#if CODI_IS_CPP14 + /// Value entry of IsTagTape + template + bool constexpr isTagTapeReverse = IsTagTapeReverse::value; +#endif + + /// Enable if wrapper for IsTagTape + template + using EnableIfTagTapeReverse = typename std::enable_if::value>::type; + /// @} } }