CallGraphDifferentiator

public class CallGraphDifferentiator

The top level of Differentiation at the Call-Graph level.

Fields

unitDiffTimer

protected final Chrono unitDiffTimer

Timer for differentiation of each individual Unit.

unitsHaveDiff

protected UnitStorage<Boolean> unitsHaveDiff

Stores decision to generate a differentiated version of a Unit.

unitsHavePrimal

protected UnitStorage<Boolean> unitsHavePrimal

Stores decision to (re)generate a primal version of a Unit.

Constructors

CallGraphDifferentiator

protected CallGraphDifferentiator(DifferentiationEnv adEnv)

Methods

collectDiffSubUnits

protected void collectDiffSubUnits(Unit srcSubUnit, int differentiationMode, TapList<Unit> toDiffSubUnitsFwd, TapList<Unit> toDiffSubUnitsBwd)

declareDiffSymbolTableIfNew

protected static void declareDiffSymbolTableIfNew(Unit diffUnit, SymbolTable diffSymbolTable)

diffCallNeeded

public boolean diffCallNeeded(Tree callTree, ActivityPattern callingActivity, Unit calledUnit, ActivityPattern calledActivity, BoolVector beforeAvlX, BoolVector afterReqX, TapList resultPointerActivity, Block block, Instruction instr)

getUnitDiffInfo

protected UnitDiffInfo getUnitDiffInfo(Unit unit)

getUnitFormalArgsActivityS

public boolean[] getUnitFormalArgsActivityS(ActivityPattern activityPattern)
Returns

the precomputed formalArgsActivity info of the Unit of the given “activityPattern”, for this particular “activityPattern” given.

patternCreatesDiffCode

public boolean patternCreatesDiffCode(ActivityPattern activityPattern, Unit srcUnit)

run

public static CallGraph run(CallGraph origCallGraph, TapList<Unit> rootUnits, String[][] suffixes)

Main entry point: Given a source CallGraph and a list of rootUnits to differentiate, creates the differentiated CallGraph, equipped in field “backAssociations” with the correspondence from source Units to differentiated Units.

solveNewSymbolHoldersOfUnit

protected static void solveNewSymbolHoldersOfUnit(Unit unit, boolean emptyCopiedUnitSuffix)

updateAllUsagesDiffFuncResultName

protected void updateAllUsagesDiffFuncResultName(Unit unit, String oldUnitName, Unit diffUnit, Tree diffFuncResultName)

Inside diffUnit, replace all occurrences of “oldUnitName” with (a copy of) the given “diffFuncResultName”, which is the name of the diff function and therefore (Fortran style) the name of the variable holding the return value.