.. java:import:: fr.inria.tapenade.representation Block .. java:import:: fr.inria.tapenade.representation BlockStorage .. java:import:: fr.inria.tapenade.representation CallArrow .. java:import:: fr.inria.tapenade.representation CallGraph .. java:import:: fr.inria.tapenade.representation DiffRoot .. java:import:: fr.inria.tapenade.representation Directive .. java:import:: fr.inria.tapenade.representation FGConstants .. java:import:: fr.inria.tapenade.representation HeaderBlock .. java:import:: fr.inria.tapenade.representation ILUtils .. java:import:: fr.inria.tapenade.representation Instruction .. java:import:: fr.inria.tapenade.representation SymbolDecl .. java:import:: fr.inria.tapenade.representation SymbolTable .. java:import:: fr.inria.tapenade.representation SymbolTableConstants .. java:import:: fr.inria.tapenade.representation TapEnv .. java:import:: fr.inria.tapenade.representation TapList .. java:import:: fr.inria.tapenade.representation TypeSpec .. java:import:: fr.inria.tapenade.representation Unit .. java:import:: fr.inria.tapenade.representation VariableDecl .. java:import:: fr.inria.tapenade.representation ZoneInfo .. java:import:: fr.inria.tapenade.representation MPIcallInfo .. java:import:: fr.inria.tapenade.utils BoolMatrix .. java:import:: fr.inria.tapenade.utils BoolVector .. java:import:: fr.inria.tapenade.utils ILLang .. java:import:: fr.inria.tapenade.utils TapIntList .. java:import:: fr.inria.tapenade.utils ToBool .. java:import:: fr.inria.tapenade.utils Tree ReqExplicit =========== .. java:package:: fr.inria.tapenade.analysis :noindex: .. java:type:: public final class ReqExplicit extends DataFlowAnalyzer Storage activity analyzer. This analysis finds, for each location in the code, the pointer variables whose derivatives must be computed, assigned, allocated, or deallocated, even if they are not (yet) active. This analysis must be done after activity is completed, because it uses activity (cf 1st case of reqX). All usages of this analysis can be found by grep "PointerActiveUsage". Example, with pointers: \ ``allocate(V) ; V=0.0 ; P=&V ; ... V=X ; Y=*P ; deallocate(V)``\ P is not active at the time of \ ``P=&V``\ . However this must be differentiated into \ ``Pd = &Vd``\ because later \ ``Y=*P``\ will be active and differentiated into Yd=*Pd which requires Pd to be explicitly pointing to Vd. Moreover, Vd must be allocated and deallocated together with V. The "Required" Storage Activity info is a BoolVector of ALLKIND (but applies only to pointers?), with a boolean true when the zone's derivative may be needed (allocated) downstream. When this boolean is true downstream an allocate for this pointer, then we must add an allocate for the differentiated pointer. Conversely, there is an "avlX" info analysis ("maybe-present") that propagates forward the zones of the pointers for which the derivative pointer may be present (allocated) at the current location. When this boolean is true upstream a "free" of this pointer, then we must add a free of for the differentiated pointer. .. parsed-literal:: Feature: derives from DataFlowAnalyzer : OK Feature: able to analyze recursive code: OK Feature: distinguishes structure elemts: OK Feature: takes care of pointer dests: OK Feature: refine on loop-local variables: only during TOPDOWN_2 phase Feature: std method for call arguments : OK Feature: able to analyze sub-flow-graph: OK Methods ------- analyze ^^^^^^^ .. java:method:: @Override protected boolean analyze() :outertype: ReqExplicit Run Storage Activity analysis on the curUnit. Runs backwards towards pointers' definitions and malloc, then forwards towards pointers' free(). Return value is meaningless when we are in a runTopDownAnalysis(). compareChannelZoneDataDownstream ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean compareChannelZoneDataDownstream(int mpZone, Block refBlock) :outertype: ReqExplicit Special comparison for ReqX info attached to a message-passing zone. Dummy implementation, may need to be revised... compareChannelZoneDataUpstream ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean compareChannelZoneDataUpstream(int mpZone, Block refBlock) :outertype: ReqExplicit Special comparison for ReqX info attached to a message-passing zone. Dummy implementation, may need to be revised... compareDownstreamValues ^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean compareDownstreamValues() :outertype: ReqExplicit Compares ReqX info arriving from downstream the exit of this curBlock with same info stored here at the previous sweep. If different, updates the stored value and returns modified status "true". For loops, comparison is done also on the infoTmpCycle value. For AVAILABLE fgPhase (analyzeForward()), no copy is required here because this is the last use of "infoTmp" and "infoTmpCycle". compareUpstreamValues ^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean compareUpstreamValues() :outertype: ReqExplicit Compares ReqX info arriving from downstream the entry of this curBlock with same info stored here at the previous sweep. If different, updates the stored value and returns modified status "true". For loops, comparison is done also on the infoTmpCycle value. For REQUIRED fgPhase (analyzeBackward()), no copy is required here because this is the last use of "infoTmp" and "infoTmpCycle". copyAnnotation ^^^^^^^^^^^^^^ .. java:method:: public static void copyAnnotation(ActivityPattern curActivity, Tree fromTree, Tree toTree) :outertype: ReqExplicit If there is an annotation about ReqX on "fromTree" for activity "curActivity", copies it onto "toTree". cumulCycleValueWithAdditional ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void cumulCycleValueWithAdditional(SymbolTable commonSymbolTable) :outertype: ReqExplicit cumulValueWithAdditional ^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void cumulValueWithAdditional(SymbolTable commonSymbolTable) :outertype: ReqExplicit diffZonesManaged ^^^^^^^^^^^^^^^^ .. java:method:: public BoolVector diffZonesManaged(ActivityPattern pattern) :outertype: ReqExplicit :return: the BoolVector of the pointer public zones indices whose differentials are managed during Unit, i.e. they are AvlX at exit of Unit and they are possibly overwritten during the Unit. This should be true in particular if the unit makes the pointer point to some new address and this address'es memory is still allocated, which implies it is the context's responsibility to free it afterwards. diffZonesRequired ^^^^^^^^^^^^^^^^^ .. java:method:: public BoolVector diffZonesRequired(ActivityPattern pattern) :outertype: ReqExplicit :return: the BoolVector of the pointer public zones indices whose differentials are required at Unit entry, i.e. they are ReqX at entry of Unit and they are possibly read or written during the Unit. This should be true in particular if the unit derefs the destination (upon entry into "unit") of the diff of a pointer, which must therefore point upon entry to some allocated diff memory location. formalArgsPointerActivity ^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: public static boolean[] formalArgsPointerActivity(ActivityPattern pattern, int nbArgs) :outertype: ReqExplicit :return: an array of booleans, one for each formal argument, true when the differentiated formal argument is needed because its memory location is reqX either upon entry or upon exit. getValueFlowingBack ^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean getValueFlowingBack() :outertype: ReqExplicit getValueFlowingThrough ^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean getValueFlowingThrough() :outertype: ReqExplicit initializeCGForUnit ^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected Object initializeCGForUnit() :outertype: ReqExplicit Initializes the context of Unit "unit" for the current cgPhase of this analysis. initializeCumulValue ^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void initializeCumulValue() :outertype: ReqExplicit initializeInitBlock ^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void initializeInitBlock() :outertype: ReqExplicit initializeUnit ^^^^^^^^^^^^^^ .. java:method:: @Override protected void initializeUnit() :outertype: ReqExplicit Initializations before each ReqX analysis of "curUnit". Creates the BlockStorage's that will store the info and infoCycle propagated by the current analysis, at the two ends of each Block. isAnnotatedReqX ^^^^^^^^^^^^^^^ .. java:method:: public static boolean isAnnotatedReqX(ActivityPattern pattern, Tree tree) :outertype: ReqExplicit True when this tree has been annotated ReqX for the given activity context. isPointerActiveArg ^^^^^^^^^^^^^^^^^^ .. java:method:: public static boolean isPointerActiveArg(ActivityPattern curActivity, int rankInShape) :outertype: ReqExplicit :return: true when the given FORMAL elementary argument to the Unit must have a differentiated counterpart (although it may be non-active) because this formal argument (either parameter or global or side-effect...) is a pointer and is either both overwritten during the call and reqX upon exit from the call or is both reqX upon entry in the call and accessed (read or written) during the call. Also returns true for non-pointer formal args that are marked reqX upon call entry, which is the case for variables whose address is assigned into a reqX pointer inside the call (cf F90:cm22). isPointerActiveCall ^^^^^^^^^^^^^^^^^^^ .. java:method:: public boolean isPointerActiveCall(Tree callTree, Unit callingUnit, Unit calledUnit, SymbolTable callSymbolTable, Instruction callInstruction, BoolVector avlX, BoolVector reqX, TapList reqXResult) :outertype: ReqExplicit :return: true when "callTree", a particular call to a Unit (although it may be non-active) must be differentiated because one of its ACTUAL arguments (either parameter or global or side-effect...) is a pointer and is both reqX JUST DOWNSTREAM the call and overwritten during the call. NOTE: we believe we must not make the call ReqX when a pointer arg is reqX UPSTREAM the call and read during the call, (although this makes the arg itself reqX when the call is reqX, cf F90:cm04) because this is true only when the arg is read to fill another pointer arg which is itself active of reqX, and therefore the call will be found ReqX anyway. Moreover, this would find too many reqX calls. Also, the call must be differentiated if one of its actual arguments is a pointer and is avlX JUST UPSTREAM the call and overwritten during the call. isPointerActiveUnit ^^^^^^^^^^^^^^^^^^^ .. java:method:: public boolean isPointerActiveUnit(ActivityPattern curActivity) :outertype: ReqExplicit :return: true when the given Unit (although it may be non-active) must be differentiated because one of its FORMAL arguments (either parameter or global or side-effect...) is a pointer and is overwritten during the Unit and (it is either reqX upon exit from some call or avlX upon entry into some call). This happens when at least one call to it is ReqX or AvlX. (cf isPointerActiveCall() ; Read the NOTE on method isPointerActiveCall() ). Also, when both reqX and avlX are empty, which may mean that the Unit is not called by the call tree that contains the differentiated part (at least in the given code), the Unit is considered PointerActive when at least one of the pointers it overwrites is active some time in the differentiated part. We do that so that routines that are outside the call tree but do prepare pointers, get differentiated and can be used to prepare the diff pointers. propagateValuesBackwardThroughBlock ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean propagateValuesBackwardThroughBlock() :outertype: ReqExplicit Propagates info through "curBlock", upstream (i.e. backwards). This occurs only for the BOTTOMUP_1 and TOPDOWN_2 cgPhases. propagateValuesForwardThroughBlock ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected boolean propagateValuesForwardThroughBlock() :outertype: ReqExplicit Propagates info through "curBlock", downstream (i.e. forwards). This occurs only for the BOTTOMUP_3 and TOPDOWN_4 cgPhases. run ^^^ .. java:method:: @Override protected void run(TapList rootUnits) :outertype: ReqExplicit Run Storage Activity analysis on the CallGraph under "rootUnits" or on the complete CallGraph if "rootUnits" is null. Runs bottom-up, then top-down, then bottom-up, then top-down. runAnalysis ^^^^^^^^^^^ .. java:method:: public static void runAnalysis(CallGraph callGraph, TapList rootUnits) :outertype: ReqExplicit Main trigger method. Runs Storage Activity analysis under the rootUnits. setAnnotatedReqX ^^^^^^^^^^^^^^^^ .. java:method:: public static void setAnnotatedReqX(ActivityPattern pattern, Tree tree) :outertype: ReqExplicit Annotate this tree as ReqX for the given activity context. setCurBlockEtc ^^^^^^^^^^^^^^ .. java:method:: @Override protected void setCurBlockEtc(Block block) :outertype: ReqExplicit Set curBlock, curSymbolTable, nDZ, vectorMap's. :param block: The new current Block. setEmptyCumulAndCycleValues ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void setEmptyCumulAndCycleValues() :outertype: ReqExplicit terminateCGForUnit ^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void terminateCGForUnit() :outertype: ReqExplicit Concluding operations on the given curUnit, called at the end of each bottom-up or top-down cgPhase. terminateFGForBlock ^^^^^^^^^^^^^^^^^^^ .. java:method:: @Override protected void terminateFGForBlock() :outertype: ReqExplicit terminateUnit ^^^^^^^^^^^^^ .. java:method:: @Override protected boolean terminateUnit() :outertype: ReqExplicit Terminates ReqX analysis on "curUnit". Return value is meaningful only in the bottom-up cgPhases: true means that the analysis result has changed since last time.