ProcedureCallDifferentiator

public class ProcedureCallDifferentiator

Object that differentiates procedure calls. In cooperation with a BlockDifferentiator, for each given procedure call, tells this BlockDifferentiator which instructions must be added to the fwdBlock and (optional) bwdBlock of the current curBlock.

Constructors

ProcedureCallDifferentiator

protected ProcedureCallDifferentiator(DifferentiationEnv adEnv)

Methods

buildDiffInstructions

protected void buildDiffInstructions(Tree callTree, Tree resultTree, int differentiationMode, Unit calledUnit, ActivityPattern calledActivity, boolean mustDiffCall, boolean callIsLive, boolean mustSaveTBRBeforeInstr, boolean normalCheckpointedCall, boolean splitAdjointCall, SymbolTable fwdSymbolTable, SymbolTable bwdSymbolTable, BoolVector beforeActiv, BoolVector afterActiv, BoolVector beforeUseful, BoolVector afterUseful, BoolVector beforeReqX, BoolVector afterReqX, BoolVector beforeAvlX)

Build the derivative instructions for a source procedure call “callTree”, with its result (whan procedure is in fact a function) assigned to a source “resultTree”. The new derivative instructions are inserted into – the future block in the future forward sweep (in their future final order) through addFuture*NodeFwd() calls, – the future block in the future backward sweep (in the inverse of their future final order) through addFuture*NodeBwd() calls, – the block for derivative declarations for a SPLIT BWD code (in their future final order) through addFutureSetDiffNodeBwd() calls (happens only for declaration instructions).

Parameters
  • differentiationMode – the differentiation mode requested in {TANGENT_MODE, ADJOINT_MODE, ADJOINT_SPLIT_MODE}.

  • calledUnit – the Unit of the called procedure

  • calledActivity – the activity pattern of the called Unit which is called here.

  • mustDiffCall – true when this call is active, i.e. we need to compute derivatives about it

  • callIsLive – true when the primal call is diff-live, i.e. cannot be simply removed from the diff code

  • mustSaveTBRBeforeInstr – true when some TBR values must be PUSH/POPPED before this call

  • splitAdjointCall – true when the adjoint of this call must be SPLIT (call foo_fwd() … call foo_bwd())

  • normalCheckpointedCall – false if splitAdjointCall or in TANGENT_MODE or inside context code

  • fwdSymbolTable – the SymbolTable of the forward sweep where the derivative instructions will go

  • bwdSymbolTable – the SymbolTable of the backward sweep where the derivative instructions will go

buildDiffInstructionsOfMPICall

protected void buildDiffInstructionsOfMPICall(Tree callTree, Tree result, int differentiationMode, Unit calledUnit, ActivityPattern calledActivity, MPIcallInfo messagePassingInfo, boolean mustDiffOperation, SymbolTable fwdSymbolTable, SymbolTable bwdSymbolTable, BoolVector beforeActiv, BoolVector afterActiv, BoolVector beforeUseful, BoolVector afterUseful)

Build the derivative instructions that come from the given source “tree”, which is an MPI call. This builds the list that must go into the block of the forward sweep (in their future final execution order) and the list that must go into the block of the backward sweep (in the inverse of their future final execution order)

diffFunctionIsFunction

protected boolean diffFunctionIsFunction(Unit unit)
Returns

true if the diff of unit will be a function.

differentiateProcedureHeader

protected Tree differentiateProcedureHeader(Tree headerTree, Tree lhs, ToObject<Tree> toDiffLhs, ActivityPattern calledActivity, SymbolTable diffSymbolTable, SymbolTable interfaceSymbolTable, int diffHeaderMode, TapList<TapPair<Tree, Tree>> toDuplicateVars)

Compute a differentiated call, for the header Tree in the EntryBlock of a diffUnit (OR for a differentiated call in the special case of the ADJOINT_SPLIT call FWD OR for a differentiated call from a context procedure).

Parameters
  • headerTree – The primal header. Its head operator is ILLang.op_call.

  • lhs – The actual variable that receives the result of the call. Should be non-null ONLY when differentiateProcedureHeader() is called on a FUNCTION CALL.

  • toDiffLhs – When given non-null, holds upon exit the future lhs of the differentiated call. Should be non-null ONLY when differentiateProcedureHeader() is called on a FUNCTION CALL.

  • calledActivity – The ActivityPattern of the routine refered to by this function call. Should be non-null ONLY when differentiateProcedureHeader() is called on a function CALL otherwise should be null and curActivity will be used.

  • diffSymbolTable – The SymbolTable that will host the returned differentiated Tree.

  • diffHeaderMode – The current differentiation mode, one of {ORIGCOPY, TANGENT, ADJOINT, ADJOINT_FWD, ADJOINT_BWD}