CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::IdentifierCacheOptimizerHotCold< T_Tape, T_Lifetime > Struct Template Reference

Reassigns the identifiers in a tape such that the tape evaluation is optimized. More...

#include <identifierCacheOptimizer.hpp>

Public Types

using Lifetime = T_Lifetime
 See IdentifierCacheOptimizerHotCold.
 
using Tape = T_Tape
 See IdentifierCacheOptimizerHotCold.
 

Public Member Functions

template<typename FuncIn, typename FuncOut>
void eval (FuncIn &&iterIn, FuncOut &&iterOut)
 Perform the tape cache optimization. Se the class description for details.
 
inlinesize_t getLargestCreatedIndex ()
 Get the new largest created index.
 
 inlineIdentifierCacheOptimizerHotCold (Tape &tape)
 Constructor.
 
inlinevoid setHotLiveTimeThreshold (Lifetime hotLiveTimeThreshold)
 Set the threshold for hot variables. Smaller values will be hot and larger ones cold.
 
template<typename Stream>
void writeStatsHeader (Stream &out)
 Write the header for the statistics to a stream.
 
template<typename Stream>
void writeStatsRow (Stream &out)
 Write the data for this optimizer into a row.
 
template<typename Stream>
void writeStatsVerbose (Stream &out)
 Write statistics to a stream as a list.
 

Detailed Description

template<typename T_Tape, typename T_Lifetime = int>
struct codi::IdentifierCacheOptimizerHotCold< T_Tape, T_Lifetime >

Reassigns the identifiers in a tape such that the tape evaluation is optimized.

The optimization performs three steps:

  1. Analyze the lifetime of the left hand side identifiers for each statement.
  2. Based on the lifetime of the statement each statement is given a new identifier.
    • If the identifier is used only for a short time it gets a hot identifier. Theses identifiers are from a special region in the adjoint vector that is accessed quite often.
    • Otherwise, the identifier gets a cold identifier. These are taken from the remainder of the available identifiers.
  3. The unused identifiers are removed by shifting the cold identifiers. The adjoint vector usually becomes smaller.

Since the optimization requires some time, it should only be applied if the tape is evaluated quite often.

Template Parameters
T_TapeTape tape on which the optimization is applied.
T_LifetimeThe lifetime type. For large tapes this needs to be increased. Signed type required since negative values are used for statements with multiple outputs.

The documentation for this struct was generated from the following file: