From f24b03fc7f9cf6c09607a1ffca6af2f893e3da09 Mon Sep 17 00:00:00 2001 From: Max Sagebaum Date: Wed, 3 Apr 2024 13:58:53 +0200 Subject: [PATCH 1/2] Bugfix for false positive of the tagging tape for MPI reduce operations. --- include/codi/tapes/tagging/tagTapeBase.hpp | 5 +++-- include/codi/tapes/tagging/tagTapeReverse.hpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/codi/tapes/tagging/tagTapeBase.hpp b/include/codi/tapes/tagging/tagTapeBase.hpp index c203490a..60a564e0 100644 --- a/include/codi/tapes/tagging/tagTapeBase.hpp +++ b/include/codi/tapes/tagging/tagTapeBase.hpp @@ -85,7 +85,8 @@ namespace codi { /// Callback for a tag error. using TagErrorCallback = void (*)(Tag const& correctTag, Tag const& wrongTag, void* userData); - static Tag constexpr PassiveTag = Tag(0); ///< Tag indicating an inactive value. + static Tag constexpr PassiveTag = Tag(0); ///< Tag indicating an inactive value. + static Tag constexpr InvalidTag = Tag(-1); ///< Tag indicating an invalid value. protected: @@ -223,7 +224,7 @@ namespace codi { /// Checks if the tag is correct. Errors are set on the ValidationIndicator object. CODI_INLINE void verifyTag(ValidationIndicator& vi, Tag const& tag) const { - if (PassiveTag != tag) { + if (PassiveTag != tag && InvalidTag != tag) { vi.isActive = true; if (tag != curTag) { vi.hasError = true; diff --git a/include/codi/tapes/tagging/tagTapeReverse.hpp b/include/codi/tapes/tagging/tagTapeReverse.hpp index 251dd3f1..2eda2ed1 100644 --- a/include/codi/tapes/tagging/tagTapeReverse.hpp +++ b/include/codi/tapes/tagging/tagTapeReverse.hpp @@ -250,7 +250,7 @@ namespace codi { /// -1 tag. Identifier getInvalidIndex() const { - return Identifier(-1); + return Identifier(Base::InvalidTag); } /// Verify tag. From 22507e9ee60c28c46fd976fdf442f21fd4b79cbf Mon Sep 17 00:00:00 2001 From: juanlucasrey Date: Mon, 8 Jul 2024 18:22:21 +0100 Subject: [PATCH 2/2] rsat fixes --- include/codi/tapes/commonTapeImplementation.hpp | 4 ++-- include/codi/tapes/jacobianBaseTape.hpp | 2 +- include/codi/tapes/jacobianLinearTape.hpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/codi/tapes/commonTapeImplementation.hpp b/include/codi/tapes/commonTapeImplementation.hpp index e02adc9b..960fe854 100644 --- a/include/codi/tapes/commonTapeImplementation.hpp +++ b/include/codi/tapes/commonTapeImplementation.hpp @@ -535,9 +535,9 @@ namespace codi { func.template call(&impl, dataView, std::forward(args)...); codiAssert(endPos == dataView.getPosition()); - } else if (LowLevelFunctionEntryCallKind::Delete == callType) CODI_Unlikely { + } else CODI_Unlikely if (LowLevelFunctionEntryCallKind::Delete == callType) { // No delete registered. Data is skiped by the curLLFByteDataPos update. - } else CODI_Unlikely { + } else { CODI_EXCEPTION("Requested call is not supported for low level function with token '%d'.", (int)id); } diff --git a/include/codi/tapes/jacobianBaseTape.hpp b/include/codi/tapes/jacobianBaseTape.hpp index cf43d0ed..16778ce0 100644 --- a/include/codi/tapes/jacobianBaseTape.hpp +++ b/include/codi/tapes/jacobianBaseTape.hpp @@ -867,7 +867,7 @@ namespace codi { CODI_NO_INLINE void internalResizeAdjointsVector() { // overallocate as next multiple of Config::ChunkSize - adjoints.resize(getNextMultiple((size_t)indexManager.get().getLargestCreatedIndex() + 1, Config::ChunkSize)); + adjoints.resize(getNextMultiple(indexManager.get().getLargestCreatedIndex() + 1, (Identifier)Config::ChunkSize)); } }; } diff --git a/include/codi/tapes/jacobianLinearTape.hpp b/include/codi/tapes/jacobianLinearTape.hpp index e46ce4e9..6552549b 100644 --- a/include/codi/tapes/jacobianLinearTape.hpp +++ b/include/codi/tapes/jacobianLinearTape.hpp @@ -200,7 +200,7 @@ namespace codi { // curAdjointPos at the end of the loop. EventSystem::notifyStatementEvaluateListeners( - tape, curAdjointPos, GradientTraits::dim(), GradientTraits::toArray(lhsAdjoint).data()); + tape, (Identifier)curAdjointPos, GradientTraits::dim(), GradientTraits::toArray(lhsAdjoint).data()); if (Config::ReversalZeroesAdjoints) { adjointVector[curAdjointPos] = Adjoint();