CoDiPack  2.3.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
primalValueReuseTape.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include <algorithm>
38#include <functional>
39#include <type_traits>
40
41#include "../config.h"
42#include "../expressions/lhsExpressionInterface.hpp"
43#include "../expressions/logic/compileTimeTraversalLogic.hpp"
44#include "../expressions/logic/constructStaticContext.hpp"
45#include "../expressions/logic/traversalLogic.hpp"
46#include "../misc/macros.hpp"
47#include "../misc/memberStore.hpp"
48#include "../traits/expressionTraits.hpp"
49#include "data/chunk.hpp"
50#include "indices/indexManagerInterface.hpp"
51#include "primalValueBaseTape.hpp"
52
54namespace codi {
55
63 template<typename T_TapeTypes>
64 struct PrimalValueReuseTape : public PrimalValueBaseTape<T_TapeTypes, PrimalValueReuseTape<T_TapeTypes>> {
65 public:
66
67 using TapeTypes =
68 CODI_DD(T_TapeTypes,
71
73 friend Base;
74
75 using Real = typename TapeTypes::Real;
76 using Gradient = typename TapeTypes::Gradient;
77 using Identifier = typename TapeTypes::Identifier;
79 using StatementEvaluator = typename TapeTypes::StatementEvaluator;
80 using EvalHandle = typename TapeTypes::EvalHandle;
81 using Position = typename Base::Position;
82
83 using StatementData = typename TapeTypes::StatementData;
84
87
89
93 void clearAdjoints(Position const& start, Position const& end,
95 CODI_UNUSED(adjointsManagement);
96
97 auto clearFunc = [this](Identifier* lhsIndex, Config::ArgumentSize* passiveArgs, Real* oldPrimal,
98 EvalHandle* evalHandle) {
99 CODI_UNUSED(passiveArgs, oldPrimal, evalHandle);
100
101 if (*lhsIndex < (Identifier)this->adjoints.size()) {
102 this->adjoints[*lhsIndex] = Gradient();
103 }
104 };
105
106 using StmtPosition = typename StatementData::Position;
107 StmtPosition startStmt = this->llfByteData.template extractPosition<StmtPosition>(start);
108 StmtPosition endStmt = this->llfByteData.template extractPosition<StmtPosition>(end);
109
110 this->statementData.forEachReverse(startStmt, endStmt, clearFunc);
111 }
112
114 template<typename AdjointVector>
115 void clearCustomAdjoints(Position const& start, Position const& end, AdjointVector data) {
116 auto clearFunc = [&data](Identifier* lhsIndex, Config::ArgumentSize* passiveArgs, Real* oldPrimal,
117 EvalHandle* evalHandle) {
118 CODI_UNUSED(passiveArgs, oldPrimal, evalHandle);
119
121 };
122
123 using StmtPosition = typename StatementData::Position;
124 StmtPosition startStmt = this->llfByteData.template extractPosition<StmtPosition>(start);
125 StmtPosition endStmt = this->llfByteData.template extractPosition<StmtPosition>(end);
126
127 this->statementData.forEachReverse(startStmt, endStmt, clearFunc);
128 }
129
130 protected:
131
134 /* data from call */
135 PrimalValueReuseTape& tape, Real* primalVector, ADJOINT_VECTOR_TYPE* adjointVector,
136 /* data from low level function byte data vector */
137 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
138 /* data from low level function info data vector */
139 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
140 Config::LowLevelFunctionDataSize* const dataSizePtr,
141 /* data from constantValueData */
142 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
143 /* data from passiveValueData */
144 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
145 /* data from rhsIdentifiersData */
146 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
147 /* data from statementData */
148 size_t& curStatementPos, size_t const& endStatementPos, Identifier const* const lhsIdentifiers,
149 Config::ArgumentSize const* const numberOfPassiveArguments, Real* const oldPrimalValues,
150 EvalHandle const* const stmtEvalHandle) {
151 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos);
152
153#if !CODI_VariableAdjointInterfaceInPrimalTapes
154 typename Base::template VectorAccess<Gradient*> vectorAccess(adjointVector, primalVector);
155#endif
156
157 while (curStatementPos < endStatementPos) CODI_Likely {
158 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
159
161 Base::template callLowLevelFunction<LowLevelFunctionEntryCallKind::Forward>(
162 tape, true, curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr,
164 adjointVector
165#else
166 &vectorAccess
167#endif
168 );
169 } else CODI_Likely {
170 Identifier const lhsIdentifier = lhsIdentifiers[curStatementPos];
171
172 Gradient lhsTangent = Gradient();
173
174 oldPrimalValues[curStatementPos] = primalVector[lhsIdentifier];
175 primalVector[lhsIdentifier] = StatementEvaluator::template callForward<PrimalValueReuseTape>(
176 stmtEvalHandle[curStatementPos], primalVector, adjointVector, lhsTangent, nPassiveValues,
177 curConstantPos, constantValues, curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
178
179#if CODI_VariableAdjointInterfaceInPrimalTapes
180 adjointVector->setLhsTangent(lhsIdentifier);
182 tape, lhsIdentifier, adjointVector->getVectorSize(), adjointVector->getAdjointVec(lhsIdentifier));
183#else
184 adjointVector[lhsIdentifier] = lhsTangent;
186 tape, lhsIdentifier, GradientTraits::dim<Gradient>(), GradientTraits::toArray(lhsTangent).data());
187#endif
189 primalVector[lhsIdentifier]);
190 }
191
192 curStatementPos += 1;
193 }
194 }
195
198 /* data from call */
199 PrimalValueReuseTape& tape, Real* primalVector,
200 /* data from low level function byte data vector */
201 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
202 /* data from low level function info data vector */
203 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
204 Config::LowLevelFunctionDataSize* const dataSizePtr,
205 /* data from constantValueData */
206 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
207 /* data from passiveValueData */
208 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
209 /* data from rhsIdentifiersData */
210 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
211 /* data from statementData */
212 size_t& curStatementPos, size_t const& endStatementPos, Identifier const* const lhsIdentifiers,
213 Config::ArgumentSize const* const numberOfPassiveArguments, Real* const oldPrimalValues,
214 EvalHandle const* const stmtEvalHandle) {
215 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos);
216
217 typename Base::template VectorAccess<Gradient*> vectorAccess(nullptr, primalVector);
218
219 while (curStatementPos < endStatementPos) CODI_Likely {
220 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
221
223 Base::template callLowLevelFunction<LowLevelFunctionEntryCallKind::Primal>(
224 tape, true, curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr, &vectorAccess);
225 } else CODI_Likely {
226 Identifier const lhsIdentifier = lhsIdentifiers[curStatementPos];
227
228 oldPrimalValues[curStatementPos] = primalVector[lhsIdentifier];
229 primalVector[lhsIdentifier] = StatementEvaluator::template callPrimal<PrimalValueReuseTape>(
230 stmtEvalHandle[curStatementPos], primalVector, numberOfPassiveArguments[curStatementPos],
231 curConstantPos, constantValues, curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
232
234 primalVector[lhsIdentifier]);
235 }
236
237 curStatementPos += 1;
238 }
239 }
240
243 /* data from call */
244 PrimalValueReuseTape& tape, Real* primalVector, ADJOINT_VECTOR_TYPE* adjointVector,
245 /* data from low level function byte data vector */
246 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
247 /* data from low level function info data vector */
248 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
249 Config::LowLevelFunctionDataSize* const dataSizePtr,
250 /* data from constantValueData */
251 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
252 /* data from passiveValueData */
253 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
254 /* data from rhsIdentifiersData */
255 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
256 /* data from statementData */
257 size_t& curStatementPos, size_t const& endStatementPos, Identifier const* const lhsIdentifiers,
258 Config::ArgumentSize const* const numberOfPassiveArguments, Real const* const oldPrimalValues,
259 EvalHandle const* const stmtEvalHandle) {
260 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos);
261
262#if !CODI_VariableAdjointInterfaceInPrimalTapes
263 typename Base::template VectorAccess<Gradient*> vectorAccess(adjointVector, primalVector);
264#endif
265
266 while (curStatementPos > endStatementPos) CODI_Likely {
267 curStatementPos -= 1;
268
269 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
270
272 Base::template callLowLevelFunction<LowLevelFunctionEntryCallKind::Reverse>(
273 tape, false, curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr,
275 adjointVector
276#else
277 &vectorAccess
278#endif
279 );
280 } else CODI_Likely {
281 Identifier const lhsIdentifier = lhsIdentifiers[curStatementPos];
282
283#if CODI_VariableAdjointInterfaceInPrimalTapes
285 tape, lhsIdentifier, adjointVector->getVectorSize(), adjointVector->getAdjointVec(lhsIdentifier));
286 Gradient const lhsAdjoint{};
287 adjointVector->setLhsAdjoint(lhsIdentifier);
288#else
289 Gradient const lhsAdjoint = adjointVector[lhsIdentifier];
291 tape, lhsIdentifier, GradientTraits::dim<Gradient>(), GradientTraits::toArray(lhsAdjoint).data());
292 adjointVector[lhsIdentifier] = Gradient();
293#endif
295 primalVector[lhsIdentifier]);
296
297 primalVector[lhsIdentifier] = oldPrimalValues[curStatementPos];
298
299 StatementEvaluator::template callReverse<PrimalValueReuseTape>(
300 stmtEvalHandle[curStatementPos], primalVector, adjointVector, lhsAdjoint,
301 numberOfPassiveArguments[curStatementPos], curConstantPos, constantValues, curPassivePos, passiveValues,
302 curRhsIdentifiersPos, rhsIdentifiers);
303 }
304 }
305 }
306
308 template<typename TapeTypes>
310 /* data from call */
311 Real* primalVector,
312 /* file interface pointer*/
314 /* data from low level function byte data vector */
315 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
316 /* data from low level function info data vector */
317 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
318 Config::LowLevelFunctionDataSize* const dataSizePtr,
319 /* data from constantValueData */
320 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
321 /* data from passiveValueData */
322 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
323 /* data from rhsIdentifiersData */
324 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
325 /* data from statementData */
326 size_t& curStatementPos, size_t const& endStatementPos, Identifier const* const lhsIdentifiers,
327 Config::ArgumentSize const* const numberOfPassiveArguments, Real* const oldPrimalValues,
328 EvalHandle const* const stmtEvalHandle) {
329 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos,
330 oldPrimalValues);
331
332 while (curStatementPos < endStatementPos) {
333 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
334
336 writer->writeLowLevelFunction(curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr);
337 } else CODI_Likely {
338 WriteInfo writeInfo = StatementEvaluator::template getWriteInformation<PrimalValueReuseTape>(
339 stmtEvalHandle[curStatementPos], primalVector, nPassiveValues, curConstantPos, constantValues,
340 curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
341 Identifier const lhsIdentifier = lhsIdentifiers[curStatementPos];
342
343 writer->writeStatement(writeInfo, lhsIdentifier, oldPrimalValues[curStatementPos], nPassiveValues,
344 curRhsIdentifiersPos, rhsIdentifiers, curPassivePos, passiveValues, curConstantPos,
345 constantValues, stmtEvalHandle[curStatementPos]);
346
347 curRhsIdentifiersPos += writeInfo.numberOfActiveArguments;
348 curConstantPos += writeInfo.numberOfConstantArguments;
349 curPassivePos += nPassiveValues;
350 }
351
352 curStatementPos += 1;
353 }
354 }
355
358 // Reset primals.
359 auto clearFunc = [this](Identifier* lhsIndex, Config::ArgumentSize* passiveArgs, Real* oldPrimal,
360 EvalHandle* evalHandle) {
361 CODI_UNUSED(passiveArgs, evalHandle);
362
363 this->primals[*lhsIndex] = *oldPrimal;
364 };
365
366 using StmtPosition = typename StatementData::Position;
367 StmtPosition startStmt = this->llfByteData.template extractPosition<StmtPosition>(this->getPosition());
368 StmtPosition endStmt = this->llfByteData.template extractPosition<StmtPosition>(pos);
369
370 this->statementData.forEachReverse(startStmt, endStmt, clearFunc);
371 }
372
375 CODI_INLINE void pushStmtData(Identifier const& index, Config::ArgumentSize const& numberOfPassiveArguments,
376 Real const& oldPrimalValue, EvalHandle evalHandle) {
377 Base::statementData.pushData(index, numberOfPassiveArguments, oldPrimalValue, evalHandle);
378 }
379
380 public:
382 void revertPrimals(Position const& pos) {
384 }
385 };
386}
#define CODI_Unlikely
Declare unlikely evaluation of an execution path.
Definition config.h:399
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_VariableAdjointInterfaceInPrimalTapes
See codi::Config::VariableAdjointInterfaceInPrimalTapes.
Definition config.h:269
#define ADJOINT_VECTOR_TYPE
See codi::Config::VariableAdjointInterfaceInPrimalTapes.
Definition config.h:277
#define CODI_Likely
Declare likely evaluation of an execution path.
Definition config.h:397
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
typename GradientImplementation< AdjointVector >::Gradient Gradient
Deduce the entry type from an adjoint vector type, usually identical to the gradient type of a tape.
Definition adjointVectorTraits.hpp:92
uint16_t LowLevelFunctionDataSize
Size store type for a low level function.
Definition config.h:98
uint16_t LowLevelFunctionToken
Token type for low level functions in the tapes.
Definition config.h:108
size_t constexpr StatementLowLevelFunctionTag
Statement tag for low level functions.
Definition config.h:126
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
std::array< AtomicTraits::RemoveAtomic< typename TraitsImplementation< Gradient >::Real >, TraitsImplementation< Gradient >::dim > toArray(Gradient const &gradient)
Converts the (possibly multi-component) gradient to an array of Reals.
Definition gradientTraits.hpp:116
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition codi.hpp:91
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
AdjointsManagement
Policies for management of the tape's interal adjoints.
Definition tapeParameters.hpp:98
@ Automatic
Manage internal adjoints automatically, including locking, bounds checking, and resizing.
Data is stored chunk-wise in this DataInterface implementation. If a chunk runs out of space,...
Definition chunkedData.hpp:64
Position getPosition() const
Current position of the tape.
Definition commonTapeImplementation.hpp:665
LowLevelFunctionByteData llfByteData
Byte data for low level functions.
Definition commonTapeImplementation.hpp:156
static void notifyStatementEvaluatePrimalListeners(Tape &tape, Identifier const &lhsIdentifier, Real const &lhsValue)
Invoke callbacks for StatementEvaluatePrimal events.
Definition eventSystem.hpp:745
static void notifyStatementEvaluateListeners(Tape &tape, Identifier const &lhsIdentifier, size_t sizeLhsAdjoint, Real const *lhsAdjoint)
Invoke callbacks for StatementEvaluate events.
Definition eventSystem.hpp:712
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
Implementation of VectorAccessInterface for adjoint and primal vectors.
Definition primalAdjointVectorAccess.hpp:59
Base class for all standard Primal value tape implementations.
Definition primalValueBaseTape.hpp:137
std::vector< Real > primals
Current state of primal values in the program.
Definition primalValueBaseTape.hpp:190
std::vector< Gradient > adjoints
Evaluation vector for AD.
Definition primalValueBaseTape.hpp:189
typename Base::Position Position
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:166
void clearAdjoints(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoint values, that is, set them to zero.
Definition primalValueBaseTape.hpp:524
StatementData statementData
Data stream for statement specific data.
Definition primalValueBaseTape.hpp:184
Final implementation for a primal value tape with a reuse index management.
Definition primalValueReuseTape.hpp:64
static void internalEvaluateReverse_EvalStatements(PrimalValueReuseTape &tape, Real *primalVector, Gradient *adjointVector, size_t &curLLFByteDataPos, size_t const &endLLFByteDataPos, char *dataPtr, size_t &curLLFInfoDataPos, size_t const &endLLFInfoDataPos, Config::LowLevelFunctionToken *const tokenPtr, Config::LowLevelFunctionDataSize *const dataSizePtr, size_t &curConstantPos, size_t const &endConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, size_t const &endPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, size_t const &endRhsIdentifiersPos, Identifier const *const rhsIdentifiers, size_t &curStatementPos, size_t const &endStatementPos, Identifier const *const lhsIdentifiers, Config::ArgumentSize const *const numberOfPassiveArguments, Real const *const oldPrimalValues, EvalHandle const *const stmtEvalHandle)
Perform a reverse evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
Definition primalValueReuseTape.hpp:242
void internalResetPrimalValues(Position const &pos)
Reset the primal values to the given position.
Definition primalValueReuseTape.hpp:357
friend Base
Allow the base class to call protected and private methods.
Definition primalValueReuseTape.hpp:73
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition primalValueReuseTape.hpp:75
void pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfPassiveArguments, Real const &oldPrimalValue, EvalHandle evalHandle)
Add statement specific data to the data streams.
Definition primalValueReuseTape.hpp:375
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition primalValueReuseTape.hpp:76
typename TapeTypes::StatementData StatementData
See PrimalValueTapeTypes.
Definition primalValueReuseTape.hpp:83
static void internalEvaluatePrimal_EvalStatements(PrimalValueReuseTape &tape, Real *primalVector, size_t &curLLFByteDataPos, size_t const &endLLFByteDataPos, char *dataPtr, size_t &curLLFInfoDataPos, size_t const &endLLFInfoDataPos, Config::LowLevelFunctionToken *const tokenPtr, Config::LowLevelFunctionDataSize *const dataSizePtr, size_t &curConstantPos, size_t const &endConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, size_t const &endPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, size_t const &endRhsIdentifiersPos, Identifier const *const rhsIdentifiers, size_t &curStatementPos, size_t const &endStatementPos, Identifier const *const lhsIdentifiers, Config::ArgumentSize const *const numberOfPassiveArguments, Real *const oldPrimalValues, EvalHandle const *const stmtEvalHandle)
Perform a primal evaluation of the tape. Arguments are from the recursive eval methods of the DataInt...
Definition primalValueReuseTape.hpp:197
void revertPrimals(Position const &pos)
Revert the primals to the state indicated by pos.
Definition primalValueReuseTape.hpp:382
void clearAdjoints(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoints that would be set in a tape evaluation from start to end. It has to hold start >= ...
Definition primalValueReuseTape.hpp:93
static void internalWriteTape(Real *primalVector, codi::TapeWriterInterface< TapeTypes > *writer, size_t &curLLFByteDataPos, size_t const &endLLFByteDataPos, char *dataPtr, size_t &curLLFInfoDataPos, size_t const &endLLFInfoDataPos, Config::LowLevelFunctionToken *const tokenPtr, Config::LowLevelFunctionDataSize *const dataSizePtr, size_t &curConstantPos, size_t const &endConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, size_t const &endPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, size_t const &endRhsIdentifiersPos, Identifier const *const rhsIdentifiers, size_t &curStatementPos, size_t const &endStatementPos, Identifier const *const lhsIdentifiers, Config::ArgumentSize const *const numberOfPassiveArguments, Real *const oldPrimalValues, EvalHandle const *const stmtEvalHandle)
Passes the statement information and the stmtEvalHandle to the writer.
Definition primalValueReuseTape.hpp:309
T_TapeTypes TapeTypes
See PrimalValueReuseTape.
Definition primalValueReuseTape.hpp:67
static void internalEvaluateForward_EvalStatements(PrimalValueReuseTape &tape, Real *primalVector, Gradient *adjointVector, size_t &curLLFByteDataPos, size_t const &endLLFByteDataPos, char *dataPtr, size_t &curLLFInfoDataPos, size_t const &endLLFInfoDataPos, Config::LowLevelFunctionToken *const tokenPtr, Config::LowLevelFunctionDataSize *const dataSizePtr, size_t &curConstantPos, size_t const &endConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, size_t const &endPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, size_t const &endRhsIdentifiersPos, Identifier const *const rhsIdentifiers, size_t &curStatementPos, size_t const &endStatementPos, Identifier const *const lhsIdentifiers, Config::ArgumentSize const *const numberOfPassiveArguments, Real *const oldPrimalValues, EvalHandle const *const stmtEvalHandle)
Perform a forward evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
Definition primalValueReuseTape.hpp:133
void clearCustomAdjoints(Position const &start, Position const &end, AdjointVector data)
Clear all adjoint values, that is, set them to zero.
Definition primalValueReuseTape.hpp:115
typename TapeTypes::Identifier Identifier
See TapeTypesInterface.
Definition primalValueReuseTape.hpp:77
typename TapeTypes::StatementEvaluator StatementEvaluator
See PrimalValueTapeTypes.
Definition primalValueReuseTape.hpp:79
typename Base::Position Position
See TapeTypesInterface.
Definition primalValueReuseTape.hpp:81
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition primalValueReuseTape.hpp:78
typename TapeTypes::EvalHandle EvalHandle
See PrimalValueTapeTypes.
Definition primalValueReuseTape.hpp:80
PrimalValueReuseTape()
Constructor.
Definition primalValueReuseTape.hpp:86
Type definitions for the primal value tapes.
Definition primalValueBaseTape.hpp:78
Creation of handles for the evaluation of expressions in a context where the expression type is not a...
Definition statementEvaluatorInterface.hpp:104
The interface used by all the tape writers. The tape writers are used to generate text,...
Definition tapeReaderWriterInterface.hpp:128
virtual void writeLowLevelFunction(size_t &curLLFByteDataPos, char *dataPtr, size_t &curLLFInfoDataPos, Config::LowLevelFunctionToken *const tokenPtr, Config::LowLevelFunctionDataSize *const dataSizePtr)
Used for statements that contain a low level function.
Definition tapeReaderWriterInterface.hpp:169
virtual void writeStatement(Identifier const &curLhsIdentifier, size_t &curJacobianPos, Real const *const rhsJacobians, Identifier const *const rhsIdentifiers, Config::ArgumentSize const &nJacobians)
Called for each statement. The method writes the current statement to the file. This overload is used...
Definition tapeReaderWriterInterface.hpp:149
This class is used during the writing process of a primal value tape. The WriteInfo is returned by co...
Definition tapeReaderWriterInterface.hpp:69
size_t numberOfActiveArguments
Number of active arguments.
Definition tapeReaderWriterInterface.hpp:70
size_t numberOfConstantArguments
Number of constant arguments.
Definition tapeReaderWriterInterface.hpp:71