ActivityPattern

public final class ActivityPattern

Class that holds one activity pattern of a Unit and its blocks, together with the results of several data-flow analysis on this Unit for this activity pattern.

Constructors

ActivityPattern

public ActivityPattern(Unit unit, boolean generalizable, boolean forceActive, int diffKind)

ActivityPattern

public ActivityPattern(Unit unit, BoolVector variedOnCall, BoolVector usefulOnExit, boolean generalizable, int diffKind)

Methods

activities

public BlockStorage<TapList<BoolVector>> activities()

Activities for all blocks in this unit with this activity Pattern.

adTBRTopDownContext

public BoolVector adTBRTopDownContext()

Initialization for TBR analysis. For the current Unit, the boolvector of the zones that are already TBR at the point of entry into the current Unit.

adTBRTopDownContextOnDiffPtr

public BoolVector adTBRTopDownContextOnDiffPtr()

avlXEffectsAdded

public BoolVector avlXEffectsAdded()

Temporary result, only for communication from BOTTOMUP_3 cgPhase to TOPDOWN_4 cgPhase: BoolVector of the zones added unconditionally to AvlX, downwards any call.

avlXEffectsVisible

public BoolVector avlXEffectsVisible()

Temporary result, only for communication from BOTTOMUP_3 cgPhase to TOPDOWN_4 cgPhase: BoolVector of the zones NOT completely masked by each Unit to the AvlX analysis.

avlXs

public BlockStorage<TapList<BoolVector>> avlXs()

The other published result of ReqX analysis: vectors of AvlX zones between each pair of successive instructions.

butRemainsInFwdSweep

public BlockStorage<int[]> butRemainsInFwdSweep()

Another result of TBR analysis. For each Instruction, true if, although this instruction may be recomputed, it must also be kept in the forward sweep.

callActivity

public BoolVector callActivity()

Result of activity analysis: Active zones upon entry into each subroutine. Storage, for each “procedure” Unit, of a BoolVector describing active zones upon call of the Unit. This is the “or” of all activities just before each call to the Unit. This is not redundant with the “internal” analysis result ((BoolVector[])topDownContexts.retrieve(unit))[VoC] because this is the real “activity” and that was only the “varied” info. Upon finishing activity analysis of the Unit, this value may be manipulated to force the differentiate call sites to perform diff var initialization upstream the diff call. In debugActivity mode only, contains the variedness upon call.

callUsefulness

public BoolVector callUsefulness()

Result of activity analysis, useful only in debugActivity mode, contains the usefulness upon call.

callingPatterns

public TapList<ActivityPattern> callingPatterns()
Returns

the list of calling contexts that will use this activity pattern.

copyReqExplicitInfos

public void copyReqExplicitInfos(ActivityPattern model)

Used in ReqExplicit analysis to initialize a standard ActivityPattern with its corresponding context ActivityPattern.

diffLivenessTopDownContext

public DiffLivenessAnalyzer.Context diffLivenessTopDownContext()

The context object used in the top-down phase of DiffLiveness analysis to accumulate the contexts of the call sites of a function into a location that analysis of this function will retrieve.

diffLivenesses

public BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffLivenesses()

Result of diffLiveness analysis: for each Unit that may be differentiated in reverse nocheckpoint mode (“split”) or in tangent mode, for each Block, a TapList of diffLiveness BoolVector’s between each pair of successive instructions.

diffLivenessesCkp

public BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffLivenessesCkp()

Result of diffLiveness analysis: for each Unit that may be differentiated in reverse checkpoint mode (“joint”), for each Block, a TapList of diffLiveness BoolVector’s between each pair of successive instructions.

diffOverwrites

public BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffOverwrites()

Result of diffLiveness analysis: for each Unit that may be differentiated in reverse nocheckpoint mode (“split”) or in tangent mode, for each Block, a TapList of diffOverwrite BoolVector’s between each pair of successive instructions.

diffOverwritesCkp

public BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffOverwritesCkp()

Result of diffLiveness analysis: for each Unit that may be differentiated in reverse checkpoint mode (“joint”), for each Block, a TapList of diffOverwrite BoolVector’s between each pair of successive instructions.

diffPattern

public DiffPattern diffPattern()
Returns

The diffPattern that lead to the creation of this activity pattern.

dump

public void dump()

entryAvlX

public BoolVector entryAvlX()

A secondary published result of ReqX analysis: BoolVector of AvlX zones (public) upon entry from the Unit.

entryDiffLivenessesCkp

public BoolVector entryDiffLivenessesCkp()

Result of 1st (BOTTOMUP) sweep of diffLiveness analysis: for each Unit, the BoolVector of its live (i.e. required) arguments upon call in the reverse-checkpointed mode. In other words, these are the variables of the Unit that are diff-live upon entry, if we suppose the diff-live set upon exit is emptyset.

entryDiffLivenessesCkpOnDiffPtr

public BoolVector entryDiffLivenessesCkpOnDiffPtr()

entryDiffOverwritesCkp

public BoolVector entryDiffOverwritesCkp()

Result of 1st (BOTTOMUP) sweep of diffLiveness analysis: for the current Unit, the BoolVector of its diff-overwritten arguments upon call in the reverse-checkpointed mode. In other words, these are the variables of the Unit that are diff-overwritten upon entry, if we suppose the diff-overwritten set upon exit is emptyset.

entryDiffOverwritesCkpOnDiffPtr

public BoolVector entryDiffOverwritesCkpOnDiffPtr()

entryReqX

public BoolVector entryReqX()

A secondary published result of ReqX analysis: BoolVector of ReqX zones (public) upon entry into the Unit.

exitActivity

public BoolVector exitActivity()

Result of activity analysis: Active zones upon exit from each subroutine. Storage, for each “procedure” Unit, of a BoolVector describing active zones upon exit from the Unit. In other words, this should be equal to the Unit’s “callActivities” times the Unit’s dependence matrix. Upon finishing activity analysis of the Unit, this value may be manipulated to force the differentiate call sites to perform diff var initialization downstream the diff call. In debugActivity mode only, contains the variedness upon return.

exitAvlX

public BoolVector exitAvlX()

A secondary published result of ReqX analysis: BoolVector of AvlX zones (public) upon exit from the Unit.

exitReqX

public BoolVector exitReqX()

A secondary published result of ReqX analysis: BoolVector of ReqX zones (public) upon exit into the Unit.

exitUsefulness

public BoolVector exitUsefulness()

Result of activity analysis, useful only in debugActivity mode, contains the usefulness upon return.

fragmentDiffLivenessesCkp

public TapPair<BoolVector, BoolVector> fragmentDiffLivenessesCkp(Block ckpBlock)

Returns the diff liveness info about one given checkpointed code fragment, here represented by its “main” Block “ckpBlock”

getAnnotationForActivityPattern

public static Object getAnnotationForActivityPattern(Tree tree, ActivityPattern pattern, String name)
Parameters
  • tree – The tree on which we search the annotation.

  • name – The name of the annotation we search.

  • pattern – The ActivityPattern for which we search the annotation.

Returns

The value found for this annotation, otherwise null.

getCallingActivityPattern

public ActivityPattern getCallingActivityPattern(Unit caller, TapList<ActivityPattern> dejaVu)

getInstructionBoolInfo

public static boolean getInstructionBoolInfo(BlockStorage<int[]> info, Instruction instruction, int infoRk)

initializeButRemainsInFwdSweep

public void initializeButRemainsInFwdSweep()

initializeMayBeRecomputed

public void initializeMayBeRecomputed()

isActive

public boolean isActive()
Returns

true if this activityPattern is active, ie not all variables are inactive.

isCalledBy

public boolean isCalledBy(Unit caller, ActivityPattern callerActivityPattern, TapList<ActivityPattern> dejaVu)

isContext

public boolean isContext()

True when this activity pattern is for “context” differentiation, i.e. outside the differentiated sub-call-tree.

isDisconnected

public boolean isDisconnected()

isDontDiff

public boolean isDontDiff()

Conversely to “isForcedActive”, this boolean is used to force non-differentiation of this Unit with respect to this ActivityPattern. cf F77:lha87 and ADActivityAnalyzer.

isForcedActive

public boolean isForcedActive()

This boolean is used to force active the “dummy” ActivityPattern that we create for a VarFunction that is called only in hidden places (external units) so that we must suppose it is active but we don’t know in which way! cf F90:v459.

isGeneralizable

public boolean isGeneralizable()

false if this pattern was created to exactly match a user request, and should therefore not be generalized. This should only happen for diff roots.

localExitTBR

public BoolVector localExitTBR()

Intermediate result of the 1st, bottom-up phase: TBR set upon exit, due only to operations inside the Unit.

localExitTBROnDiffPtr

public BoolVector localExitTBROnDiffPtr()

mayBeRecomputed

public BlockStorage<int[]> mayBeRecomputed()

Another result of TBR analysis. For each Instruction, true if this Instruction is considered for recomputing its result rather than storing it (Store on kill).

recomps

public BlockStorage<TapList<TapPair<TapList<Instruction>, TapList<Instruction>>>> recomps()

Another result of TBR analysis. For each Unit of the CallGraph, for each Block, the TapList of the recomputations that we want to place on the way backwards between successive instructions. Each of these recomputations is itself a TapList of Instruction’s.

registerCallingActivityPattern

public void registerCallingActivityPattern(ActivityPattern callingPattern)

removeAnnotationForActivityPattern

public static void removeAnnotationForActivityPattern(Tree tree, ActivityPattern pattern, String name)

Removes the annotation “name” for ActivityPattern “pattern” on this “tree”.

Parameters
  • tree – The tree on which we remove the annotation.

  • name – The name of the annotation we remove.

  • pattern – The ActivityPattern for which we remove the annotation.

reqXEffects

public BoolMatrix reqXEffects()

Temporary result, only for communication from BOTTOMUP_1 cgPhase to TOPDOWN_2 cgPhase: BoolMatrix of the effect of each Unit on its ReqX info, upwards any call.

reqXEffectsAdded

public BoolVector reqXEffectsAdded()

Temporary result, only for communication from BOTTOMUP_1 cgPhase to TOPDOWN_2 cgPhase: BoolVector of the zones added unconditionally to ReqX, upwards any call.

reqXs

public BlockStorage<TapList<BoolVector>> reqXs()

The published result of ReqX analysis: vectors of ReqX zones between each pair of successive instructions.

setActivities

public void setActivities(BlockStorage<TapList<BoolVector>> activities)

setAdTBRTopDownContext

public void setAdTBRTopDownContext(BoolVector adTBRTopDownContext)

setAdTBRTopDownContextOnDiffPtr

public void setAdTBRTopDownContextOnDiffPtr(BoolVector adTBRTopDownContextOnDiffPtr)

setAnnotationForActivityPattern

public static void setAnnotationForActivityPattern(Tree tree, ActivityPattern pattern, String name, Object val)

Sets to “val” the value of annotation “name” for ActivityPattern “pattern” on this “tree”.

Parameters
  • tree – The tree on which we set the annotation.

  • name – The name of the annotation we set.

  • pattern – The ActivityPattern for which we set the annotation.

  • val – The value we set for this annotation.

setAvlXEffectsAdded

public void setAvlXEffectsAdded(BoolVector avlXEffectsAdded)

setAvlXEffectsVisible

public void setAvlXEffectsVisible(BoolVector avlXEffectsVisible)

setAvlXs

public void setAvlXs(BlockStorage<TapList<BoolVector>> avlXs)

setCallActivity

public void setCallActivity(BoolVector callActivity)

setCallUsefulness

public void setCallUsefulness(BoolVector callUsefulness)

setContext

public void setContext(boolean context)

setDiffLivenessTopDownContext

public void setDiffLivenessTopDownContext(DiffLivenessAnalyzer.Context diffLivenessTopDownContext)

setDiffLivenesses

public void setDiffLivenesses(BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffLivenesses)

setDiffLivenessesCkp

public void setDiffLivenessesCkp(BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffLivenessesCkp)

setDiffOverwrites

public void setDiffOverwrites(BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffOverwrites)

setDiffOverwritesCkp

public void setDiffOverwritesCkp(BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> diffOverwritesCkp)

setDiffPattern

public void setDiffPattern(DiffPattern diffPattern)

setDontDiff

public void setDontDiff(boolean dontDiff)

setEntryAvlX

public void setEntryAvlX(BoolVector entryAvlX)

setEntryDiffLivenessesCkp

public void setEntryDiffLivenessesCkp(BoolVector entryDiffLivenessesCkp)

setEntryDiffLivenessesCkpOnDiffPtr

public void setEntryDiffLivenessesCkpOnDiffPtr(BoolVector entryDiffLivenessesCkpOnDiffPtr)

setEntryDiffOverwritesCkp

public void setEntryDiffOverwritesCkp(BoolVector entryDiffOverwritesCkp)

setEntryDiffOverwritesCkpOnDiffPtr

public void setEntryDiffOverwritesCkpOnDiffPtr(BoolVector entryDiffOverwritesCkpOnDiffPtr)

setEntryReqX

public void setEntryReqX(BoolVector entryReqX)

setExitActivity

public void setExitActivity(BoolVector exitActivity)

setExitAvlX

public void setExitAvlX(BoolVector exitAvlX)

setExitReqX

public void setExitReqX(BoolVector exitReqX)

setExitUsefulness

public void setExitUsefulness(BoolVector exitUsefulness)

setForcedActive

public void setForcedActive(boolean forcedActive)

setFragmentDiffLivenessesCkp

public void setFragmentDiffLivenessesCkp(Block ckpBlock, TapPair<BoolVector, BoolVector> info)

setInstructionBoolInfo

public static void setInstructionBoolInfo(BlockStorage<int[]> info, Instruction instruction, int infoRk, boolean value)

setLocalExitTBR

public void setLocalExitTBR(BoolVector localExitTBR)

setLocalExitTBROnDiffPtr

public void setLocalExitTBROnDiffPtr(BoolVector localExitTBROnDiffPtr)

setRecomps

public void setRecomps(BlockStorage<TapList<TapPair<TapList<Instruction>, TapList<Instruction>>>> recomps)

setReqXEffects

public void setReqXEffects(BoolMatrix reqXEffects)

setReqXEffectsAdded

public void setReqXEffectsAdded(BoolVector reqXEffectsAdded)

setReqXs

public void setReqXs(BlockStorage<TapList<BoolVector>> reqXs)

setStaticActivity

public void setStaticActivity(BoolVector staticActivity)

setTbrs

public void setTbrs(BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> tbrs)

setUsefulOnCallingSide

public void setUsefulOnCallingSide(BoolVector usefulnessOnCallingSide)

setUsefulnesses

public void setUsefulnesses(BlockStorage<TapList<BoolVector>> usefulnesses)

staticActivity

public BoolVector staticActivity()

Zones that are active all through the analyzed curUnit, and that are not even mentioned in the [before|after]Activ vectors because they are unused, unmodified and are therefore filtered out by activity analysis. Cf results*.results[index] in ResultsSet() in validation code SEISM.

tbrs

public BlockStorage<TapList<TapPair<BoolVector, BoolVector>>> tbrs()

Main result of TBR analysis. TBR set just before each instruction, for each Block of each Unit of the CallGraph. Actually, the TBR result is also stored as a Tree annotation, therefore this field is rarely used, e.g. for the save of local vars at the end of fwd sweeps (split mode), or for dumps.

toString

public String toString()

unit

public Unit unit()
Returns

The Unit that this activity pattern refers/applies to.

usefulOnCallingSide

public BoolVector usefulOnCallingSide()

Result of activity analysis, BoolVector of the (union of) public usefulness at the calling location(s) of this Unit. This usefulness is not filtered through the by-value formal arguments, so that it can be used to detect whether a by-value argument of the Unit needs a second adjoint (local) derivative to eventually add into the adjoint derivative actual argument.

usefulOnExit

public BoolVector usefulOnExit()

Useful on Exit of this unit.

usefulnesses

public BlockStorage<TapList<BoolVector>> usefulnesses()

Usefulnesses for all blocks in this unit with this activity Pattern.

varFunctionADActivities

public TapTriplet<Unit, BoolVector, BoolVector>[] varFunctionADActivities()

Result of activity analysis: about functions passed as arguments. For each Unit, contains an array of the same length as the arguments list which contains, for each argument which is a function name and which is “active”, the callActivity and exitUsefulness of this function.

variedOnCall

public BoolVector variedOnCall()

Varied on Call of this unit.

walkUpToPatternOf

public static void walkUpToPatternOf(ActivityPattern pattern, Unit unit, TapList<ActivityPattern> collected, TapList<ActivityPattern> dejaVu)

zonesMPIiReceived

public BoolVector zonesMPIiReceived()

BoolVector of the zones for which this Unit does a AMPI_Irecv(), and therefore (if the zone is active) the adjoint must run a AMPI_Turn().

zonesMPIiReceivedLength

public int zonesMPIiReceivedLength()

zonesOfVarsHaveDiff

public BoolVector zonesOfVarsHaveDiff()

Result of activity analysis: BoolVector of the (diffKind) zones for which there will be a differentiated variable.