DifferentiationEnv

public final class DifferentiationEnv

Differentiation environment.

Constant objects kept by the DifferentiationEnv:
   callGraphDifferentiator, FlowGraphDifferentiator, BlockDifferentiator,
   procedureCallDifferentiator, dynMemoryDifferentiator,
   expressionDifferentiator (soon), VarRefDifferentiator,
   multiDirMode, suffixes
   srcCallGraph, diffCallGraph

Modifiable "current" objects during navigation inside IR and construction of IR:
                curUnit
                   curActivity
                   curDiffUnit
                   curFwdDiffUnit
                     curDiffUnitSort curDiffVarSort
                   curBlock
                     curVectorMap, curDiffVectorMap, curPtrVectorMap, curSymbolTable
                     curInstruction
                     curFwdSymbolTable, curBwdSymbolTable

Fields

activeRootCalledFromContext

protected boolean activeRootCalledFromContext

True when the curInstruction being differentiated is in context code and is a call to an active.

adDiffMode

protected int adDiffMode

The current differentiation mode for the current Unit.

blockDifferentiator

protected BlockDifferentiator blockDifferentiator

The object that knows how to differentiate Basic Blocks.

callGraphDifferentiator

protected CallGraphDifferentiator callGraphDifferentiator

The object that knows how to differentiate a callGraph.

callersOfRootUnits

protected TapList<Unit> callersOfRootUnits

commonActivityMemoryMap

protected MemoryMaps commonActivityMemoryMap

copiedIncludes

protected TapList<TapPair<Instruction, Instruction>> copiedIncludes

Association original include instruction to include instruction in diff.

copiedUnits

protected UnitStorage<Unit> copiedUnits

Association original Unit to copied original Unit in diff.

copiedUnitsBack

protected UnitStorage<Unit> copiedUnitsBack

Association copied original Unit in diff to original Unit.

curBlock

protected Block curBlock

The current source Block.

curBwdSymbolTable

protected SymbolTable curBwdSymbolTable

The current bwd differentiated SymbolTable (i.e. of the current bwd diff Block).

curDiffUnit

protected Unit curDiffUnit

The current “standard” differentiated Unit of the current Unit. Contains: – in TANGENT_MODE: the tangent diff Unit. – in ADJOINT_MODE: the joint diff Unit (fwd and bwd sweeps together) – in ADJOINT_SPLIT_MODE: the bwd sweep alone.

curDiffUnitPushesPointers

protected boolean curDiffUnitPushesPointers

True when differentiation notices that there must be a F90 INTERFACE declaration for PUSH/LOOK/POP POINTER().

curDiffUnitSort

protected int curDiffUnitSort

The current sort of derivatives for procedures.

curDiffVarSort

protected int curDiffVarSort

The current sort of derivatives for variables.

curDiffVectorMap

protected int[] curDiffVectorMap

The current diffVectorMap (i.e. of the current Unit+SymbolTable).

curFwdDiffUnit

protected Unit curFwdDiffUnit

The current “standard” differentiated Unit of the current Unit. Contains: – in TANGENT_MODE: the tangent diff Unit. – in ADJOINT_MODE: the joint diff Unit (fwd and bwd sweeps together) – in ADJOINT_SPLIT_MODE: the bwd sweep alone.

curFwdSymbolTable

protected SymbolTable curFwdSymbolTable

The current fwd differentiated SymbolTable (i.e. of the current fwd diff Block).

curPtrVectorMap

protected int[] curPtrVectorMap

The current ptrVectorMap (i.e. of the current Unit+SymbolTable).

curUnitIsActiveUnit

protected boolean curUnitIsActiveUnit

Global boolean true when “curUnit” is an active subroutine.

curUnitIsContext

protected boolean curUnitIsContext

Global boolean true when “curUnit” is currently differentiated as context.

curVectorMap

protected int[] curVectorMap

The current vectorMap (i.e. of the current Unit+SymbolTable).

debugADHereUnit

protected Unit debugADHereUnit

The Unit of the external boolean function “DEBUG_***_HERE()”.

diffKind

protected int diffKind

The kind of zones that are currently differentiated. Usually, it is SymbolTableConstants.REALKIND, but in a special mode, it can be ALLKIND!…

dynMemoryDifferentiator

protected DynMemoryDifferentiator dynMemoryDifferentiator

The object that knows how to differentiate Dynamic Memory manipulations.

emptyCopiedUnitSuffix

protected boolean emptyCopiedUnitSuffix

True when copied Units keep their original name.

expressionDifferentiator

protected ExpressionDifferentiator expressionDifferentiator

The object that knows how to differentiate expressions.

flowGraphDifferentiator

protected FlowGraphDifferentiator flowGraphDifferentiator

The object that knows how to differentiate FlowGraphs.

hiddenDiffInitVariables

protected TapList<TapPair<Object, TapList<String>>> hiddenDiffInitVariables

List of hidden variables to be diff-initialized for the current unit.

hiddenInstrumentedVariables

protected TapList<TapPair<Object, TapList<String>>> hiddenInstrumentedVariables

List of hidden variables to be instrumented (for debug) for the current unit.

hiddenPushPopVariables

protected TapList<TapPair<Object, TapList<String>>> hiddenPushPopVariables

List of hidden variables to be PUSH/POP’ed for the current unit.

iReplic

protected int iReplic

The current replica number for diff variables.

integer4TypeSpec

protected WrapperTypeSpec integer4TypeSpec

INTEGER*4 type

integerTypeSpec

protected WrapperTypeSpec integerTypeSpec

The “INTEGER” WrapperTypeSpec, necessary to create new INTEGER variables.

multiDirMode

protected boolean multiDirMode

True to get vector loops around derivative instructions.

procedureCallDifferentiator

protected ProcedureCallDifferentiator procedureCallDifferentiator

The object that knows how to differentiate procedure calls.

realTypeSpec

protected WrapperTypeSpec realTypeSpec

The “REAL” WrapperTypeSpec, necessary to create new REAL variables.

rootUnits

protected TapList<Unit> rootUnits

suffixes

protected String[][] suffixes

The array of all suffixes used during differentiation.

toActiveTmpZones

protected TapIntList toActiveTmpZones

toIndexSymbolHolders

protected TapList<NewSymbolHolder> toIndexSymbolHolders

List of already created newSymbolHolders for variables named “indexN”, used in sub-expressions in actual arguments of calls. This list is ordered with increasing N’s.

toTotalZones

protected TapIntList toTotalZones

traceCurBlock

protected int traceCurBlock

1 means trace on current Block. 2 means trace in even more detail (when traceCurDifferentiation is true).

traceCurDifferentiation

protected boolean traceCurDifferentiation

Detailled trace of differentiation on the standard output: True when we want to trace differentiation on-the-fly on the current Unit (curUnit).

traceDifferentiationUnits

protected TapList<Unit> traceDifferentiationUnits

Units for which we want to trace differentiation on-the-fly.

unitActivities

protected BlockStorage<TapList<BoolVector>> unitActivities

Activity info for the current Unit (curUnit).

unitAvlXs

protected BlockStorage<TapList<BoolVector>> unitAvlXs

AvlX info for the current Unit (curUnit).

unitRecomputations

protected BlockStorage<TapList<TapPair<TapList<Instruction>, TapList<Instruction>>>> unitRecomputations

Recomputation (see TBR) info for the current Unit (curUnit).

unitReqXs

protected BlockStorage<TapList<BoolVector>> unitReqXs

ReqX info for the current Unit (curUnit).

unitTBRs

protected BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> unitTBRs

TBR info for the current Unit (curUnit).

unitUsefulnesses

protected BlockStorage<TapList<BoolVector>> unitUsefulnesses

Usefulness info for the current Unit (curUnit).

usesADMM

protected boolean usesADMM

True when differentiation notices that ADMM is used.

varRefDifferentiator

protected VarRefDifferentiator varRefDifferentiator

The object that knows how to differentiate memory references.

Constructors

DifferentiationEnv

protected DifferentiationEnv(CallGraph srcCallGraph, String[][] suffixes)

Methods

addInHiddenDiffInitVariables

protected void addInHiddenDiffInitVariables(ZoneInfo zoneInfo)

addInHiddenInstrumentedVariables

protected void addInHiddenInstrumentedVariables(ZoneInfo zoneInfo)

addInHiddenPushPopVariables

protected void addInHiddenPushPopVariables(ZoneInfo zoneInfo)

allocateTmpZone

protected int allocateTmpZone()

Allocate a new zone number for a new temporary variable. increments the head of “toTotalZones”, that contains the last zone used.

curActivity

protected ActivityPattern curActivity()
Returns

The activity pattern for which we are differentiating the current Unit.

curInstruction

protected Instruction curInstruction()
Returns

The current (source) Instruction.

curSymbolTable

protected SymbolTable curSymbolTable()
Returns

The current source SymbolTable (i.e. of the current source Block).

curUnit

protected Unit curUnit()
Returns

The current source Unit being analyzed or differentiated.

diffCallGraph

protected CallGraph diffCallGraph()

The differentiated CallGraph.

getCurrentFilename

public String getCurrentFilename(boolean fullPath)

Get the filename in which we are differentiating at a given time

Parameters
  • fullPath: – true if the path to file is kept or simply the filename

Returns

either the filename where the current unit is located (fullPath = False) or path + filename

getDiffOfModule

protected Unit getDiffOfModule(Unit unit)

getDiffOfUnit

protected Unit getDiffOfUnit(Unit unit, ActivityPattern pattern, int diffMode)

getOrigUnitOfPrimalCopy

protected Unit getOrigUnitOfPrimalCopy(Unit unit)

getPatternsForCallingUnitPattern

protected TapList<ActivityPattern> getPatternsForCallingUnitPattern(ActivityPattern callerPattern, Unit calledUnit)
Parameters
  • callerPattern – The activity pattern of this particular call site.

  • calledUnit – The called unit

Returns

the ActivityPatterns for a “calledUnit” that are used at a particular call site, i.e. only the patterns of “calledUnit” that may be called here in the caller’s pattern. When the call site is a module, the callerPattern is null and all called patterns are returned.

getPrimalCopyOfOrigUnit

protected Unit getPrimalCopyOfOrigUnit(Unit unit)

hideActiveTmpZones

protected void hideActiveTmpZones()

popCurDiffSorts

protected void popCurDiffSorts()

popCurDiffUnit

protected void popCurDiffUnit()

popCurDiffVectorMap

protected void popCurDiffVectorMap()

popCurSymbolTable

protected void popCurSymbolTable()

popCurUnitEtc

protected void popCurUnitEtc()

popCurVectorMap

protected void popCurVectorMap()

pushCurDiffSorts

protected void pushCurDiffSorts(int diffUnitSort, int diffVarSort)

pushCurDiffUnit

protected void pushCurDiffUnit(Unit diffUnit)

pushCurDiffVectorMap

protected void pushCurDiffVectorMap(int[] diffVectorMap)

Current pointer Type vectorMap

Parameters
  • diffVectorMap – current diff vectorMap

pushCurSymbolTable

protected void pushCurSymbolTable(SymbolTable symbolTable)

pushCurUnitEtc

protected void pushCurUnitEtc(Unit unit)

pushCurVectorMap

protected void pushCurVectorMap(int[] vectorMap)

resetActiveTmpZones

protected void resetActiveTmpZones()

setCurActivity

protected void setCurActivity(ActivityPattern activity)

Sets and redistributes the global current activity pattern for the current Unit.

setCurBlock

protected void setCurBlock(Block block)

setCurBwdSymbolTable

protected void setCurBwdSymbolTable(SymbolTable symbolTable)

setCurDiffSorts

protected void setCurDiffSorts(int diffUnitSort, int diffVarSort)

setCurDiffUnit

protected void setCurDiffUnit(Unit diffUnit)

setCurDiffVectorMap

protected void setCurDiffVectorMap(int[] diffVectorMap)

setCurFwdDiffUnit

protected void setCurFwdDiffUnit(Unit fwdDiffUnit)

setCurFwdSymbolTable

protected void setCurFwdSymbolTable(SymbolTable symbolTable)

setCurInstruction

protected void setCurInstruction(Instruction instr)

setCurPtrVectorMap

protected void setCurPtrVectorMap(int[] ptrVectorMap)

setCurSymbolTable

protected void setCurSymbolTable(SymbolTable symbolTable)

setCurUnitEtc

protected void setCurUnitEtc(Unit unit)

Sets and redistributes the global current source Unit (“curUnit”), and sets traceCurDifferentiation boolean accordingly, and resets global curInstruction to null.

setCurVectorMap

protected void setCurVectorMap(int[] vectorMap)

setDiffCallGraph

protected void setDiffCallGraph(CallGraph diffCallGraph)

setDiffCallGraphAndRootUnits

protected void setDiffCallGraphAndRootUnits(CallGraph diffCG, TapList<Unit> rootUnits)

someUnitsAreTraced

public boolean someUnitsAreTraced()

srcCallGraph

protected CallGraph srcCallGraph()

The source/original non-differentiated CallGraph.