CoDiPack  2.3.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
primalValueLinearTape.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 PrimalValueLinearTape : public PrimalValueBaseTape<T_TapeTypes, PrimalValueLinearTape<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 IndexManager = typename TapeTypes::IndexManager;
78 using Identifier = typename TapeTypes::Identifier;
80 using StatementEvaluator = typename TapeTypes::StatementEvaluator;
81 using EvalHandle = typename TapeTypes::EvalHandle;
82 using Position = typename Base::Position;
83
86
88
92 void clearAdjoints(Position const& start, Position const& end,
94 CODI_UNUSED(adjointsManagement);
95
96 using IndexPosition = CODI_DD(typename IndexManager::Position, int);
97 IndexPosition startIndex = this->llfByteData.template extractPosition<IndexPosition>(start);
98 IndexPosition endIndex = this->llfByteData.template extractPosition<IndexPosition>(end);
99
100 startIndex = std::min(startIndex, (IndexPosition)this->adjoints.size() - 1);
101 endIndex = std::min(endIndex, (IndexPosition)this->adjoints.size() - 1);
102
103 for (IndexPosition curPos = endIndex + 1; curPos <= startIndex; curPos += 1) {
104 this->adjoints[curPos] = Gradient();
105 }
106 }
107
109 template<typename AdjointVector>
110 void clearCustomAdjoints(Position const& start, Position const& end, AdjointVector data) {
111 using IndexPosition = CODI_DD(typename IndexManager::Position, int);
112 IndexPosition startIndex = this->llfByteData.template extractPosition<IndexPosition>(start);
113 IndexPosition endIndex = this->llfByteData.template extractPosition<IndexPosition>(end);
114
115 for (IndexPosition curPos = endIndex + 1; curPos <= startIndex; curPos += 1) {
117 }
118 }
119
120 protected:
121
124 /* data from call */
125 PrimalValueLinearTape& tape, Real* primalVector, ADJOINT_VECTOR_TYPE* adjointVector,
126 /* data from low level function byte data vector */
127 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
128 /* data from low level function info data vector */
129 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
130 Config::LowLevelFunctionDataSize* const dataSizePtr,
131 /* data from constantValueData */
132 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
133 /* data from passiveValueData */
134 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
135 /* data from rhsIdentifiersData */
136 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
137 /* data from statementData */
138 size_t& curStatementPos, size_t const& endStatementPos,
139 Config::ArgumentSize const* const numberOfPassiveArguments, EvalHandle const* const stmtEvalHandle,
140 /* data from index handler */
141 size_t const& startAdjointPos, size_t const& endAdjointPos) {
142 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos,
143 endStatementPos);
144
145 size_t curAdjointPos = startAdjointPos;
146
147#if !CODI_VariableAdjointInterfaceInPrimalTapes
148 typename Base::template VectorAccess<Gradient*> vectorAccess(adjointVector, primalVector);
149#endif
150
151 while (curAdjointPos < endAdjointPos) CODI_Likely {
152 curAdjointPos += 1;
153
154 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
155
157 Base::template callLowLevelFunction<LowLevelFunctionEntryCallKind::Forward>(
158 tape, true, curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr,
160 adjointVector
161#else
162 &vectorAccess
163#endif
164 );
165 } else if (Config::StatementInputTag == nPassiveValues) CODI_Unlikely {
166 // Do nothing.
167 } else CODI_Likely {
168 Gradient lhsTangent = Gradient();
169
170 primalVector[curAdjointPos] = StatementEvaluator::template callForward<PrimalValueLinearTape>(
171 stmtEvalHandle[curStatementPos], primalVector, adjointVector, lhsTangent, nPassiveValues,
172 curConstantPos, constantValues, curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
173
174#if CODI_VariableAdjointInterfaceInPrimalTapes
175 adjointVector->setLhsTangent(curAdjointPos);
177 tape, curAdjointPos, adjointVector->getVectorSize(), adjointVector->getAdjointVec(curAdjointPos));
178#else
179 adjointVector[curAdjointPos] = lhsTangent;
180
182 tape, curAdjointPos, GradientTraits::dim<Gradient>(), GradientTraits::toArray(lhsTangent).data());
183#endif
185 primalVector[curAdjointPos]);
186 }
187
188 curStatementPos += 1;
189 }
190 }
191
194 /* data from call */
195 PrimalValueLinearTape& tape, Real* primalVector,
196 /* data from low level function byte data vector */
197 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
198 /* data from low level function info data vector */
199 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
200 Config::LowLevelFunctionDataSize* const dataSizePtr,
201 /* data from constantValueData */
202 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
203 /* data from passiveValueData */
204 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
205 /* data from rhsIdentifiersData */
206 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
207 /* data from statementData */
208 size_t& curStatementPos, size_t const& endStatementPos,
209 Config::ArgumentSize const* const numberOfPassiveArguments, EvalHandle const* const stmtEvalHandle,
210 /* data from index handler */
211 size_t const& startAdjointPos, size_t const& endAdjointPos) {
212 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos,
213 endStatementPos);
214
215 size_t curAdjointPos = startAdjointPos;
216
217 typename Base::template VectorAccess<Gradient*> vectorAccess(nullptr, primalVector);
218
219 while (curAdjointPos < endAdjointPos) CODI_Likely {
220 curAdjointPos += 1;
221
222 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
223
225 Base::template callLowLevelFunction<LowLevelFunctionEntryCallKind::Primal>(
226 tape, true, curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr, &vectorAccess);
227 } else if (Config::StatementInputTag == nPassiveValues) CODI_Unlikely {
228 // Do nothing.
229 } else CODI_Likely {
230 primalVector[curAdjointPos] = StatementEvaluator::template callPrimal<PrimalValueLinearTape>(
231 stmtEvalHandle[curStatementPos], primalVector, nPassiveValues, curConstantPos, constantValues,
232 curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
233
235 primalVector[curAdjointPos]);
236 }
237
238 curStatementPos += 1;
239 }
240 }
241
244 /* data from call */
245 PrimalValueLinearTape& tape, Real* primalVector, ADJOINT_VECTOR_TYPE* adjointVector,
246 /* data from low level function byte data vector */
247 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
248 /* data from low level function info data vector */
249 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
250 Config::LowLevelFunctionDataSize* const dataSizePtr,
251 /* data from constantValueData */
252 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
253 /* data from passiveValueData */
254 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
255 /* data from rhsIdentifiersData */
256 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
257 /* data from statementData */
258 size_t& curStatementPos, size_t const& endStatementPos,
259 Config::ArgumentSize const* const numberOfPassiveArguments, EvalHandle const* const stmtEvalHandle,
260 /* data from index handler */
261 size_t const& startAdjointPos, size_t const& endAdjointPos) {
262 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos,
263 endStatementPos);
264
265 size_t curAdjointPos = startAdjointPos;
266
267#if !CODI_VariableAdjointInterfaceInPrimalTapes
268 typename Base::template VectorAccess<Gradient*> vectorAccess(adjointVector, primalVector);
269#endif
270
271 while (curAdjointPos > endAdjointPos) CODI_Likely {
272 curStatementPos -= 1;
273
274 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
275
277 Base::template callLowLevelFunction<LowLevelFunctionEntryCallKind::Reverse>(
278 tape, false, curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr,
280 adjointVector
281#else
282 &vectorAccess
283#endif
284 );
285 } else if (Config::StatementInputTag == nPassiveValues) CODI_Unlikely {
286 // Do nothing.
287 } else CODI_Likely {
288#if CODI_VariableAdjointInterfaceInPrimalTapes
289
291 tape, curAdjointPos, adjointVector->getVectorSize(), adjointVector->getAdjointVec(curAdjointPos));
292
293 Gradient const lhsAdjoint{};
294 adjointVector->setLhsAdjoint(curAdjointPos);
295#else
296 Gradient const lhsAdjoint = adjointVector[curAdjointPos];
297
299 tape, curAdjointPos, GradientTraits::dim<Gradient>(), GradientTraits::toArray(lhsAdjoint).data());
300
302 adjointVector[curAdjointPos] = Gradient();
303 }
304#endif
306 primalVector[curAdjointPos]);
307
308 StatementEvaluator::template callReverse<PrimalValueLinearTape>(
309 stmtEvalHandle[curStatementPos], primalVector, adjointVector, lhsAdjoint, nPassiveValues,
310 curConstantPos, constantValues, curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
311 }
312
313 curAdjointPos -= 1;
314 }
315 }
316
318 template<typename TapeTypes>
320 /* data from call */
321 Real* primalVector,
322 /* file interface pointer*/
324 /* data from low level function byte data vector */
325 size_t& curLLFByteDataPos, size_t const& endLLFByteDataPos, char* dataPtr,
326 /* data from low level function info data vector */
327 size_t& curLLFInfoDataPos, size_t const& endLLFInfoDataPos, Config::LowLevelFunctionToken* const tokenPtr,
328 Config::LowLevelFunctionDataSize* const dataSizePtr,
329 /* data from constantValueData */
330 size_t& curConstantPos, size_t const& endConstantPos, PassiveReal const* const constantValues,
331 /* data from passiveValueData */
332 size_t& curPassivePos, size_t const& endPassivePos, Real const* const passiveValues,
333 /* data from rhsIdentifiersData */
334 size_t& curRhsIdentifiersPos, size_t const& endRhsIdentifiersPos, Identifier const* const rhsIdentifiers,
335 /* data from statementData */
336 size_t& curStatementPos, size_t const& endStatementPos,
337 Config::ArgumentSize const* const numberOfPassiveArguments, EvalHandle const* const stmtEvalHandle,
338 /* data from index handler */
339 size_t const& startAdjointPos, size_t const& endAdjointPos) {
340 CODI_UNUSED(endLLFByteDataPos, endLLFInfoDataPos, endConstantPos, endPassivePos, endRhsIdentifiersPos,
341 endStatementPos);
342
343 size_t curAdjointPos = startAdjointPos;
344
345 while (curAdjointPos < endAdjointPos) {
346 curAdjointPos += 1;
347 Config::ArgumentSize nPassiveValues = numberOfPassiveArguments[curStatementPos];
348
350 writer->writeLowLevelFunction(curLLFByteDataPos, dataPtr, curLLFInfoDataPos, tokenPtr, dataSizePtr);
351 } else CODI_Likely {
352 WriteInfo writeInfo = StatementEvaluator::template getWriteInformation<PrimalValueLinearTape>(
353 stmtEvalHandle[curStatementPos], primalVector, nPassiveValues, curConstantPos, constantValues,
354 curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
355
356 if (Config::StatementInputTag == nPassiveValues) CODI_Unlikely {
357 writer->writeStatement(writeInfo, curAdjointPos, primalVector[curAdjointPos], nPassiveValues,
358 curRhsIdentifiersPos, rhsIdentifiers, curPassivePos, passiveValues, curConstantPos,
359 constantValues, stmtEvalHandle[curStatementPos]);
360
361 } else CODI_Likely {
362 writer->writeStatement(writeInfo, curAdjointPos, primalVector[curAdjointPos], nPassiveValues,
363 curRhsIdentifiersPos, rhsIdentifiers, curPassivePos, passiveValues, curConstantPos,
364 constantValues, stmtEvalHandle[curStatementPos]);
365
366 curRhsIdentifiersPos += writeInfo.numberOfActiveArguments;
367 curConstantPos += writeInfo.numberOfConstantArguments;
368 curPassivePos += nPassiveValues;
369 }
370 }
371
372 curStatementPos += 1;
373 }
374 }
375
379 CODI_UNUSED(pos);
380
381 // Nothing to do.
382 }
383
386 CODI_INLINE void pushStmtData(Identifier const& index, Config::ArgumentSize const& numberOfPassiveArguments,
387 Real const& oldPrimalValue, EvalHandle evalHandle) {
388 CODI_UNUSED(index, oldPrimalValue);
389
390 Base::statementData.pushData(numberOfPassiveArguments, evalHandle);
391 }
392
393 public:
396 void revertPrimals(Position const& pos) {
397 CODI_UNUSED(pos);
398
399 // Primal values do not need to be reset.
400 }
401 };
402}
#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
bool constexpr ReversalZeroesAdjoints
With a linear index management, control if adjoints are set to zero during reversal.
Definition config.h:289
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
size_t constexpr StatementInputTag
Tag for statements that are inputs. Used in linear index management context.
Definition config.h:123
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
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< 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 linear index management.
Definition primalValueLinearTape.hpp:64
typename TapeTypes::StatementEvaluator StatementEvaluator
See PrimalValueTapeTypes.
Definition primalValueLinearTape.hpp:80
T_TapeTypes TapeTypes
See PrimalValueLinearTape.
Definition primalValueLinearTape.hpp:67
void clearCustomAdjoints(Position const &start, Position const &end, AdjointVector data)
Clear all adjoint values, that is, set them to zero.
Definition primalValueLinearTape.hpp:110
typename Base::Position Position
See TapeTypesInterface.
Definition primalValueLinearTape.hpp:82
typename TapeTypes::Identifier Identifier
See TapeTypesInterface.
Definition primalValueLinearTape.hpp:78
PrimalValueLinearTape()
Constructor.
Definition primalValueLinearTape.hpp:85
static void internalEvaluateReverse_EvalStatements(PrimalValueLinearTape &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, Config::ArgumentSize const *const numberOfPassiveArguments, EvalHandle const *const stmtEvalHandle, size_t const &startAdjointPos, size_t const &endAdjointPos)
Perform a reverse evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
Definition primalValueLinearTape.hpp:243
friend Base
Allow the base class to call protected and private methods.
Definition primalValueLinearTape.hpp:73
void internalResetPrimalValues(Position const &pos)
Reset the primal values to the given position.
Definition primalValueLinearTape.hpp:378
typename TapeTypes::IndexManager IndexManager
See PrimalValueTapeTypes.
Definition primalValueLinearTape.hpp:77
typename TapeTypes::EvalHandle EvalHandle
See PrimalValueTapeTypes.
Definition primalValueLinearTape.hpp:81
void revertPrimals(Position const &pos)
Revert the primals to the state indicated by pos.
Definition primalValueLinearTape.hpp:396
void pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfPassiveArguments, Real const &oldPrimalValue, EvalHandle evalHandle)
Add statement specific data to the data streams.
Definition primalValueLinearTape.hpp:386
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition primalValueLinearTape.hpp:75
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition primalValueLinearTape.hpp:76
static void internalEvaluatePrimal_EvalStatements(PrimalValueLinearTape &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, Config::ArgumentSize const *const numberOfPassiveArguments, EvalHandle const *const stmtEvalHandle, size_t const &startAdjointPos, size_t const &endAdjointPos)
Perform a primal evaluation of the tape. Arguments are from the recursive eval methods of the DataInt...
Definition primalValueLinearTape.hpp:193
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, Config::ArgumentSize const *const numberOfPassiveArguments, EvalHandle const *const stmtEvalHandle, size_t const &startAdjointPos, size_t const &endAdjointPos)
Passes the statement information and the stmtEvalHandle to the writer.
Definition primalValueLinearTape.hpp:319
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition primalValueLinearTape.hpp:79
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 primalValueLinearTape.hpp:92
static void internalEvaluateForward_EvalStatements(PrimalValueLinearTape &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, Config::ArgumentSize const *const numberOfPassiveArguments, EvalHandle const *const stmtEvalHandle, size_t const &startAdjointPos, size_t const &endAdjointPos)
Perform a forward evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
Definition primalValueLinearTape.hpp:123
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