Unit

public final class Unit

One node in the call graph. Represents one particular procedure or interface or external or module or package or file… of the current code. Holds links to callers, callees, containing CallGraph, SymbolTable’s,

For procedures, holds its Flow Graph in the form of an EntryBlock, an ExitBlock, and a graph of Block’s in between.

Fields

activeCalledNames

public TapList<String> activeCalledNames

The list of unit names called by this unit and that are active.

activityPatterns

public TapList<ActivityPattern> activityPatterns

Info for AD on this Unit. List of all possible ActivityPattern’s for the calls to this Unit. Each ActivityPattern contains information about which variables being active, useful, etc, at all necessary locations inside this Unit (Specific to AD).

allArrows

public TapList<FGArrow> allArrows

DFST-ordered list of all Flow Graph arrows.

allBlocks

public TapList<Block> allBlocks

DFST-ordered list of all Blocks, excluding EntryBlock and ExitBlock.

analysisIsOutOfDateDown

public boolean analysisIsOutOfDateDown

Mark useful in any top-down static Data Flow analysis to write whether this Unit must be analyzed again at next analysis sweep.

analysisIsOutOfDateUp

public boolean analysisIsOutOfDateUp

Mark useful in any bottom-up static Data Flow analysis to write whether this Unit must be analyzed again at next analysis sweep.

argsPublicRankTrees

public TapList[] argsPublicRankTrees

For each formal argument, indexed by its rank (0 for result), contains a tree (for each elementary part of this argument, e.g for records) of the corresponding public ranks, i.e. the rank in the external shape.

arrayDimMin

public int arrayDimMin

Default first index of arrays. Fortran = 1, C = 0.

callees

public TapList<CallArrow> callees

List of all CallArrow’s leaving from this Unit.

callers

public TapList<CallArrow> callers

List of all CallArrow’s arriving on this Unit.

childrenClasses

public TapList<Unit> childrenClasses

List of all classes that inherit from this class (unit).

copyPublicSTDeclarationBlock

public Block copyPublicSTDeclarationBlock

diffInfo

public Object diffInfo

Special (TEMPORARY) field to hold info about differentiation For instance, this holds the predefined differentiation for mathematical intrinsics.

dirNumberMaxSymbolHolder

public NewSymbolHolder dirNumberMaxSymbolHolder

The NewSymbolHolder of new variable “NBDirsMax”.

directives

public TapList<Directive> directives

List of AD directives attached to this Unit.

enclosingUnitOfInterface

public Unit enclosingUnitOfInterface

When this is an interface Unit, its enclosing Unit.

entryBlock

public EntryBlock entryBlock

The entry Block.

exitBlock

public ExitBlock exitBlock

The exit Block.

externalShape

public ZoneInfo[] externalShape

Array of ZoneInfo holding information about the elementary parameters of this Unit.

formats

public TapList<Tree> formats

The list of format Trees of this Unit.

genericArrow

protected CallArrow genericArrow

For an intrinsic, a special unique generic arrow that stands for any call to this intrinsic. Returned by getCallArrow on an intrinsic.

globalZonesNumber4

public int[] globalZonesNumber4

The number of global zones in the externalShape of this Unit. It is also the rank (plus 1) of the last zone whose data-flow info can be plainly copied between this Unit and any of its caller Units.

isCGCycle

public boolean isCGCycle

Utility temporary info built during static analyses. True iff this Unit is head (if the analysis is bottom-up) or tail (if the analysis is top-down) of a cycle in this Call Graph. This cycle detection is based on the rank’s of the Units.

isMadeForInline

public boolean isMadeForInline

True if calls to this Unit are supposed to be inlined.

isTotallyDeclared

protected boolean isTotallyDeclared

True for functions whose arguments and result types are fully specified. If not, pieces of the type must be inferred.

localMaps

public MemoryMaps localMaps

The memory maps built for non-global (non-COMMON) EQUIVALENCEd variables (Fortran-specific)

lowerLevelUnits

public TapList<Unit> lowerLevelUnits

List of the Units of all the subroutines defined locally, inside this Unit.

maybeCheckpointed

public boolean maybeCheckpointed

Flags for no Checkpoint strategy.

maybeNoCheckpointed

public boolean maybeNoCheckpointed

messages

public TapList<PositionAndMessage> messages

error and warning messages.

modifiers

public Tree modifiers

Modifiers for this function, method or subroutine.

multiDirDimensionMax

public ArrayDim multiDirDimensionMax

An ArrayDim: [arrayDimMin:NBDirsMax].

mustHandleTBR

public BoolVector mustHandleTBR

Summary of zones and arguments that the diff of this Unit must handle.

nbArrows

public int nbArrows

Total number of FGArrows, including those from/to EntryBlock and ExitBlock.

nbBlocks

public int nbBlocks

Total number of Blocks, not including EntryBlock nor ExitBlock.

newDiffCIncludes

public TapList<String> newDiffCIncludes

Used to memorize needed additional include’s in differentiated C, e.g. adBinomial.h, adFixedPoint.h …

nonFlowInstructions

public TapList<Instruction> nonFlowInstructions

The list of instructions that do not depend on the flow (e.g. sub-Units definitions), and that could not be placed into normal Flow Graph Block’s because they are unreachable by the control flow (e.g. because they are after an op_goto, op_exit, op_return…).

orig2copiedBlocks

public BlockStorage<Block> orig2copiedBlocks

When this Unit is copied from origUnit, correspondence from the Block’s of origUnit to the Block’s of this Unit. Wiped out when used.

origPublicSTDeclarationBlock

public Block origPublicSTDeclarationBlock

origUnit

public Unit origUnit

(Hack) The “original” Unit. (e.g. in AD, the unit from which this one is copied or differentiated).

otherImportedModules

public TapList<Unit> otherImportedModules

List of all implicitly imported modules.

parametersOrModuleNameTree

public Tree parametersOrModuleNameTree

If entryBlock is null, contains parameters or module name Tree.

plainDependencies

public BoolMatrix plainDependencies

Plain dependencies data-flow info: dependency of each output wrt each input.

pointerEffect

public BoolMatrix pointerEffect

Pointer data-flow info: pointer destinations upon unit exit, wrt destinations upon unit entry.

position

public int position

Indication of the position of this Unit in its file. If -1, then getPosition will recompute it from the positions of the instructions inside.

postComments

public Tree postComments

The tree of comments post-attached to this Unit.

postCommentsBlock

public Tree postCommentsBlock

The tree of block-comments post-attached to this Unit.

preComments

public Tree preComments

The tree of comments pre-attached to this Unit.

preCommentsBlock

public Tree preCommentsBlock

The tree of block-comments pre-attached to this Unit.

privacy

public String privacy

For C++ and oriented-object in general, indicate the privacy of this unit: public, private or protected.

publicZonesNumber4

public int[] publicZonesNumber4

The number of public zones of this Unit i.e. the globals plus the arguments

relevantZones

public BoolVector relevantZones

BoolVector, one bit per zone (i.e. per index in the externalShape), with value 1 if this zone can be accessed by this Unit or by some Unit recursively called. This info is needed to compensate for the introduction of irrelevant (HIDDEN) zones due to the removal of the old “side-effect” mechanism. This info may be used to compress the data-flow info on this Unit, since it is guaranteed (?) that the info on non-relevant zones is necessarily neutral.

sortOfDiffUnit

public int sortOfDiffUnit

The sort of differentiated unit this is

sortRk

protected int sortRk

A temporary rank used only during sorting.

tagMessagePassingSymbolHolder

public NewSymbolHolder tagMessagePassingSymbolHolder

testZoneInfos

public int[] testZoneInfos

For each control zone rank (from 0 up), the rank of the corresponding ZoneInfo.

translator

public PublicInfo[] translator

Information used to translate zone-based data between this Unit’s internal representation and external, published representation.

unitADDependencies

public BoolMatrix unitADDependencies

Differentiable dependencies for this Unit. Used so far, mostly to store the AD deps matrix of intrinsics found from the user-given library files.

unitInOutN

public BoolVector unitInOutN

In-Out data-flow info: vector of zones possibly/partly not accessed.

unitInOutR

public BoolVector unitInOutR

In-Out data-flow info: vector of zones possibly/partly read and not written.

unitInOutRW

public BoolVector unitInOutRW

In-Out data-flow info: vector of zones possibly/partly read then written.

unitInOutW

public BoolVector unitInOutW

In-Out data-flow info: vector of zones possibly/partly not read and only written.

unitTBR

public BoolVector unitTBR

TBR info: vector of zones possibly becoming TBR when going through this Unit, in other words zones used non-linearly and therefore needed in derivatives.

upperLevelUnit

public Unit upperLevelUnit

If this Unit was defined as a local unit of an enclosing Unit, contains the enclosing Unit. Otherwise contains null.

usedAsElementalResult

public boolean usedAsElementalResult

True for procedures that F90 can use as elemental, i.e. on an array of arguments of the expected type.

userHelp

public TapList<TapPair<String, String>> userHelp

List of things (e.g. variables) requested from the user, for the current Unit.

usesISO_C_BINDING

public boolean usesISO_C_BINDING

Fortran module must use ISO_C_BINDING module.

zonesUsedInDeclarations

public BoolVector zonesUsedInDeclarations

The vector of all the zones of all the variables that are used in the declarations part, e.g. as dimension declarator.

Constructors

Unit

public Unit(CallGraph callGraph, int rank, Unit upperLevelUnit, int language)

Creates a new Unit and links it to its CallGraph.

Methods

absorb

protected void absorb(Unit absorbedUnit)

Combines the callers and callees of “absorbedUnit” into this Unit.

absorbAndDeleteUnit

public void absorbAndDeleteUnit(Unit absorbedUnit)

Try to absorb “absorbedUnit” into this Unit, then delete “absorbedUnit”.

addBlock

public void addBlock(Block block)

Add a block to allBlock. This will break Flow Graph numbering, therefore it will have to be re-made later.

addChildrenClass

public void addChildrenClass(Unit unit)

addDeadTree

public void addDeadTree(Tree tree)

Adds “tree” to the list of all Tree’s proved dead because unreachable.

addDerivedSymbolTable

public void addDerivedSymbolTable(SymbolTable symbolTable)

Adds a SymbolTable into the list of all SymbolTables belonging to this Unit. This routine must be called for the upmost SymbolTable’s first, so that these SymbolTables are ordered bottom-up.

addFormatTree

public void addFormatTree(Tree formatTree)

Adds formatTree to the list of format Trees of this Unit.

addInterfaceDecl

protected TapList<Unit> addInterfaceDecl(TreeProtocol inputStream, CallGraph callGraph, SymbolTable symbolTable)

addLostComment

public void addLostComment(Tree tree)

Adds “tree” to the list of all comments lost while building this Unit.

addLowerLevelUnit

public void addLowerLevelUnit(Unit unit)

Declares “unit” as defined locally, inside this Unit.

addNonFlowInstruction

public void addNonFlowInstruction(Instruction instr)

addParentClass

public void addParentClass(Unit unit, boolean isVirtualInheritance, boolean isPublicInheritance)

allBlocks

public TapList<Block> allBlocks()
Returns

the DFST-ordered list of all Blocks. This list does not contain the EntryBlock nor the ExitBlock.

allCallees

public TapList<Unit> allCallees()
Returns

the TapList of all computation Unit’s recursively called by “this” Unit. The returned list is ordered, so that each caller appears before its callees. In case of recursivity loops, no Unit appears twice. The first Unit in the list is “this” unit. The result doesn’t contain non-computation Units such as modules, varFunctions, interfaces…

allCalleesMulti

public static TapList<Unit> allCalleesMulti(TapList<Unit> initialUnits)

Similar to allCallees(), but starts from several initialUnits.

allCalleesMultiAvoiding

public static TapList<Unit> allCalleesMultiAvoiding(TapList<Unit> initialUnits, TapList<Unit> avoidedUnits)

Similar to allCalleesMulti, but avoids going through “avoidedUnits”.

allCallers

public TapList<Unit> allCallers()
Returns

the list of Units for which there exists a path in the CallGraph from that Unit to ‘this’ Unit. @return an ordered TapList of Unit’s, so that each caller appears after all its callees. The given Unit is put in first position in the result.

allCallersMulti

public static TapList<Unit> allCallersMulti(TapList<Unit> initialUnits)

Similar to allCallers(), but starts from several initialUnits.

allocateDeclaredZones

protected void allocateDeclaredZones(int[] firstZones, boolean staticMemory, TapList<ZoneInfo> toAllocatedZones)

Allocates the Zone numbers for the declared variables in this Unit, then (except if on a package) recursively for the sub-units declared locally.

Parameters
  • firstZones – the next available zone numbers, for (anyType, int, real, ptr)

  • staticMemory – when true, allocate only the “static” zones of this Unit, i.e. those of the MODULE variables, the CLASS static variables, the various sort of remanent variables…

  • toAllocatedZones – collects the ordered list of ZoneInfo created (in decreasing rank order). This argument is used only when staticMemory==true. Otherwise pass null.

appendPostComments

public void appendPostComments(TapList<Tree> newComments)

blocksFromBitVector

public TapList<Block> blocksFromBitVector(BoolVector bv)
Returns

the ordered list of the Blocks that are designated by the given BoolVector “bv”. There is no verification that bv corresponds to a bitvector for blocks in this Unit.

bodySymbolTable

public SymbolTable bodySymbolTable()

buildControlDepsOf

public BoolVector buildControlDepsOf(Instruction instr, Block block)

Builds a new BoolVector containing true for all control zones that control the given Instruction (which is in the given Block), or null if empty

buildReturnTypeTree

public Tree buildReturnTypeTree(Block privateDeclBlock, TapList<SymbolDecl> externalTypes, ToObject<Tree> toNewDeclTree, TapList<Instruction> publicDeclarationsInstructions)

Builds the tree of the return type of this Unit.

callGraph

public CallGraph callGraph()
Returns

the CallGraph to which this Unit belongs.

callees

public TapList<CallArrow> callees()
Returns

the list of all CallArrow’s leaving from this Unit.

callerUnitNamesThatCall

public TapList<String> callerUnitNamesThatCall()

Same as callersThatCall.

Returns

the list of name Strings of the callers.

callers

public TapList<CallArrow> callers()
Returns

the list of all CallArrow’s arriving on this Unit.

callersThatCall

public TapList<CallArrow> callersThatCall()
Returns

the list of all CallArrow’s corresponding to a op_call of this Unit.

checkMessagePassingCalls

protected void checkMessagePassingCalls(CallGraph callGraph)

cite

public void cite()

Prints a short reference to this Unit onto TapEnv.curOutputStream().

classTypeSpec

public ClassTypeSpec classTypeSpec()

coherence

protected void coherence()

Computes and sets a number of utility information, most of them derived from the choice about loops done during the “findOptimalLoops” step.

Precisely, sets the following: - for the FlowGraph: allBlocks, nbBlocks - for each Block: rank, enclosingLoop, flowGraph, (TODO: successors, predecessors) boolean fields “isFGCycleHead” and “isFGCycleTail”. - for each LoopBlock: enclosingLoops, depth, entryBlocks, exitBlocks, entryArrows, exitArrows, and cycleArrows - for each Instruction: block - for each FGArrow: rank, iter, originInLevel, destinationInLevel This function requires that the following info is available: – topBlocks, list of top-level blocks – entryBlock and exitBlock – for each LoopBlock, the list of its immediately enclosed Blocks (field “inside”).

collectContainedUnits

public TapList<Unit> collectContainedUnits(TapList<Unit> collector)
Returns

an unordered list of all Units recursively contained in this Unit.

collectImportForLater

protected void collectImportForLater(Instruction useInstr, SymbolTable symbolTable)

computeAllDominatorlikeInfo

protected void computeAllDominatorlikeInfo()

Compute usual informations on flowgraphs. Called in CallGraph.terminateTypesAndZones().

computeArrowZoneInterfaces

protected void computeArrowZoneInterfaces()

computeDominatorArrows

public void computeDominatorArrows()

computeTestZones

public void computeTestZones()

Fill this.testZonesNb, Block.testZone

computeZoneInterfaces

protected void computeZoneInterfaces()

computeZonesUsedInDeclarations

protected void computeZonesUsedInDeclarations()

Initializes “zonesUsedInDeclarations”, the vector of all the zones of all the variables that are used in the declarations part, e.g. as dimension declarator.

copyUnitBody

protected static TapList<FGArrow> copyUnitBody(Unit origUnit, Unit copyUnit, Instruction context)

Copies the contents of origUnit into copyUnit.

Parameters
  • context – the context in which the copyUnit will appear. E.g. when copyUnit is used to inline a call.

copyUnitExceptSymbolTables

public Unit copyUnitExceptSymbolTables(CallGraph callGraph, Unit upperLevelUnit, Unit otherEnclosingUnitOfInterface)

Creates a PARTIAL copy of “this” Unit. Used by differentiation to create copied, non-differentiated Units. Copies the Flow Graph and Flow-Graph-related info.. For every allocation of an active variable, insert allocation of the differentiated variable. Does NOT create the copied SymbolTable’s.

deadTrees

public TapList<Tree> deadTrees()
Returns

the list of all Tree’s proved dead because unreachable.

declareAllSymbolDecls

protected void declareAllSymbolDecls()

dump

public void dump(int indent)

Prints in detail the contents of this Unit, onto TapEnv.curOutputStream().

Parameters
  • indent – the amount of indentation to be used for this printing.

dumpDataFlow

public void dumpDataFlow(boolean dumpPointers, boolean dumpInOut, boolean dumpDeps, boolean dumpInside)

Prints a human-readable description of all the data-flow info found on this Unit.

dumpExternalZones

public void dumpExternalZones()

encloses

public boolean encloses(Unit enclosed)
Returns

true if this Unit contains the “enclosed” Unit. A Unit does not enclose itself.

enclosingUnits

public TapList<Unit> enclosingUnits()
Returns

the list of all Units enclosing this one, from the inside out.

entryBlock

public EntryBlock entryBlock()
Returns

the entry block.

exitBlock

public ExitBlock exitBlock()
Returns

the exit Block.

exportFunctionTypeSpec

public void exportFunctionTypeSpec()

Refine the FunctionTypeSpec of this Unit, using the types found in the function’s definition, but removing from these types the “Hint” information, and any other bit of info that refers to the inside of this Unit and should not be used outside.

exportOneArgumentType

protected void exportOneArgumentType(String argName, WrapperTypeSpec typeSpec)

Same as exportFunctionTypeSpec(), but only for the argument named “argName”, with the given “typeSpec”.

externalSymbolTable

public SymbolTable externalSymbolTable()
Returns

the enclosing SymbolTable of this Unit.

fixImplicits

public void fixImplicits()

For each variable declared, but incompletely (e.g. there was a dimension T(100), but nothing else on T), uses the implicit type mechanism to terminate the typing of the variable in the SymbolTable.

focusToKind

public BoolVector focusToKind(BoolVector vectorAllKind, int kind)

Returns a translation of the given “vectorAllKind”, which is based on the ALLKIND zones numbering, into its subset dealing only with “kind” zones, and using the “kind” zones numbering.

focusToKind

public BoolMatrix focusToKind(BoolMatrix matrixAllKind, int kind)

Same as focusToKind(BoolVector), but on a BoolMatrix

focusToKind

public TapIntList focusToKind(TapIntList allKindZones, int kind)

Same as focusToKind(BoolVector), but on a TapIntList of allKind zones.

Returns

those in the given ALLKIND zones that are actually of the required “kind”, as a new list of “kind” zones.

formalArgumentsNb

public int formalArgumentsNb()
Returns

the number of formal arguments of the function associated to this Unit, as declared in the SymbolTable.

formats

public TapList<Tree> formats()
Returns

the list of format Trees of this Unit.

fortranStuff

public FortranStuff fortranStuff()

Special for treatment of Fortran specific info.

fragmentInOutCkp

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

Returns the “possibly read” and “possibly written” info about one given checkpointed code fragment, here represented by its “main” Block “ckpBlock”

fromInclude

public Instruction fromInclude()

functionDeclHostSymbolTable

public SymbolTable functionDeclHostSymbolTable()

Returns the SymbolTable that contains the main FunctionDecl for this (function) Unit.

functionTypeSpec

public FunctionTypeSpec functionTypeSpec()
Returns

the function type of this Unit.

generateHeaderParamsList

public TapList<Tree> generateHeaderParamsList(SymbolTable locationSymbolTable)

Generates the ordered list of Tree’s for the parameters of this Unit.

Parameters
  • locationSymbolTable – the SymbolTable of the future location of the generated parameter list.

getArrow

public FGArrow getArrow(int rank)
Returns

the Flow-Graph’s arrow of given “rank”.

getElementalIntrinsicTypeConverter

protected Tree getElementalIntrinsicTypeConverter(Tree[] args)
Returns

the argument that deals with type size in the given array of arguments of a called intrinsic.

getForwardDeclaration

public Instruction getForwardDeclaration()
Returns

For C, for an EXTERNAL Unit, the C-style forward declaration instruction.

getFrontierOfParallelRegion

public TapTriplet<TapList<FGArrow>, TapList<Block>, TapList<FGArrow>> getFrontierOfParallelRegion(Block regionBlock)
Parameters
  • regionBlock – Block that ends with the parallel region pragma

getImportedDecl

public SymbolDecl getImportedDecl(String name, int kind)
Returns

null if no declaration is found.

getNameFromBindC

public String getNameFromBindC()

getOptionalParameterDeclsNumber

protected int getOptionalParameterDeclsNumber()

getOrigUnitOfInterface

public Unit getOrigUnitOfInterface(CallGraph callGraph)
Returns

the original standard Unit of which this Unit is an interface.

getPosition

public int getPosition()
Returns

the position of this Unit in its textual file.

getSetNewParallelControls

public static TapList<Instruction> getSetNewParallelControls(TapList<Instruction> oldParallelControls, BlockStorage<Block> blockCorrespondence, BlockStorage<TapList<Instruction>> parallelControlsCorrepondence)

Transposes a given list of parallel controls which applies to an existing Unit into a new “mirror” list of parallel controls that applies to a new unit deduced from the existing one, following the correspondence “blockCorrespondence” from existing Unit’s Blocks to new Unit’s Blocks, and the already built new lists of parallel controls “parallelControlsCorrepondence”.

getUnitOfInterface

public Unit getUnitOfInterface()
Returns

the STANDARD Unit (when it exists) corresponding to this INTERFACE Unit. This code is not very satisfying, because the getFunctionDecl should be made more specific by using the INTERFACE’s functionTypeSpec().

getUpperLevelClassUnit

public Unit getUpperLevelClassUnit()
Returns

the closest upper level class unit of this unit.

globalZonesNumber

public int globalZonesNumber(int whichKind)

hasArrayNotation

public boolean hasArrayNotation()
Returns

true if we allow for array notation (“vector” notation) in this Unit.

hasDirective

public Directive hasDirective(int kind)
Returns

one Directive of kind “kind” in the list of AD directives attached to this Unit.

hasGlobalArgs

protected boolean hasGlobalArgs()
Returns

true when this Unit has global arguments that are neither the returned value nor in the list of formal arguments, and that may be used (R or W) by this Unit.

hasParamElemsInfo

public boolean hasParamElemsInfo()
Returns

true when this Unit contains info on its elementary parameters.

hasPredefinedDerivatives

public boolean hasPredefinedDerivatives()
Returns

true if this unit has predefined derivatives, e.g. from an external specification library.

hasSource

public boolean hasSource()
Returns

true if this Unit knows its source code, i.e. Flow Graph, etc…

hasTooManyZones

public final boolean hasTooManyZones()

headTree

public Tree headTree()
Returns

the header of the current procedure Unit, in the form of a tree with top operator “call”.

importAllSymbolTables

protected void importAllSymbolTables()

importInheritedClassesSymbolTables

protected void importInheritedClassesSymbolTables()

importedModules

public TapList<Unit> importedModules()
Returns

the list of all directly imported modules.

importsSymbolTable

public SymbolTable importsSymbolTable()
Returns

the imported context SymbolTable of this Unit.

inStdCIncludeFile

public boolean inStdCIncludeFile()
Returns

true if this Unit comes from a C include file.

isAContext

public boolean isAContext()
Returns

true when this Unit is (in particular) differentiated as a context to call diff code.

isAFunction

public boolean isAFunction()
Returns

true if this Unit is a function, i.e. return type is not ‘void’.

isC

public boolean isC()

isCPlusPlus

public boolean isCPlusPlus()

isCalledFromOtherLanguage

public boolean isCalledFromOtherLanguage()

isCexactly

public boolean isCexactly()
Returns

True if the programming language is C.

isClass

public boolean isClass()
Returns

True if this is a class.

isConstructor

public boolean isConstructor()
Returns

True if this is an constructor Unit.

isDiffPackage

public Boolean isDiffPackage()
Returns

Boolean(true) if this Unit is a package (of the source CallGraph) for which there will be a differentiated package Unit. Also returns true if this Unit is this corresponding differentiated package Unit (of the differentiated Call Graph). This is set to true when the new module contains something new in addition to the contents of the primal, such as the declaration of some differentiated objects. Otherwise, this is also set to true when TapEnv.get().stripPrimalModules is false.

isElemental

public boolean isElemental()
Returns

true for procedures that F90 can use as elemental, i.e. on an array of arguments of the expected type.

isExternal

public boolean isExternal()
Returns

True if this is an external Unit.

isFortran

public boolean isFortran()
Returns

True if the programming language is any FORTRAN.

isFortran2003

public boolean isFortran2003()
Returns

True if the programming language is FORTRAN2003 or upper.

isFortran9x

public boolean isFortran9x()
Returns

True if the programming language is FORTRAN90 or upper.

isInterface

public boolean isInterface()
Returns

True if this is an (unsolved) interface Unit.

isIntrinsic

public boolean isIntrinsic()
Returns

True if this is an intrinsic Unit.

isIntrinsicNotElemental

public boolean isIntrinsicNotElemental()

isModule

public boolean isModule()
Returns

True if this is a module.

isOutside

public boolean isOutside()
Returns

True if this is an external, or an intrinsic, or an outside to be determined.

isOutsideTBD

public boolean isOutsideTBD()
Returns

True if this is an outside Unit, maybe external, maybe intrinsic.

isPackage

public boolean isPackage()
Returns

True if this is a package of sub-Units.

isPredefinedModuleOrTranslationUnit

public boolean isPredefinedModuleOrTranslationUnit()
Returns

true if this is the MPI module.

isPrivate

protected boolean isPrivate()

isProcedure

public boolean isProcedure()
Returns

True if this is a procedure Unit.

isProcedureWithCode

public boolean isProcedureWithCode()
Returns

True if this is a procedure Unit with its code exposed.

isRenamed

public boolean isRenamed()
Returns

True if this is a renamed Unit.

isStandard

public boolean isStandard()
Returns

True if this is a standard Unit.

isTopInFile

public boolean isTopInFile()
Returns

True if this is a top-level unit, i.e. immediately inside a file (aka Translation Unit).

isTranslationUnit

public boolean isTranslationUnit()
Returns

True if this is a “Translation Unit” (i.e. the Unit for a file).

isUndefined

public boolean isUndefined()
Returns

True if this is an undefined module.

isUseAssociatedIntrinsic

public boolean isUseAssociatedIntrinsic(FunctionDecl intrinsicDecl)
Returns

true si intrinsicDecl est declare’e dans un des modules importe’ pb: on ne peut pas passer par les importedSymbolTable car les intrinsic n’y sont pas: elles sont rajoutees au typeCheck des declarations du module qui est fait apres la copie des symbolTable importees TODO dans ce qui suit on ne tient pas compte des restrictions faites par les only ou renamed il faudrait affiner …

isVarFunction

public boolean isVarFunction()
Returns

True if this is a Unit for a variable that holds a function.

language

public int language()
Returns

the programming language.

language

public static int language(Unit unit)

lostComments

public TapList<Tree> lostComments()
Returns

the list of all comments lost while building this Unit.

makeExternal

public static Unit makeExternal(String funcName, CallGraph callGraph, int language, boolean isPrivate)

Constructor for external Units.

makeExternalOrIntrinsic

public static Unit makeExternalOrIntrinsic(String funcName, CallGraph callGraph, int language)

Constructor for Units that are still dubious between External and Intrinsic.

makeFlowGraph

public void makeFlowGraph(EntryBlock entryBlock, TapList<Block> givenAllBlocks, ExitBlock exitBlock, boolean finalGraph)

Sets the Flow Graph contents of this Unit. Takes a raw description of a Flow Graph, i.e. entryBlock, allBlocks, and exitBlock, condenses, simplifies, and normalizes it, and then puts the result as the new Flow Graph contents of this Unit. Assumes that all given Blocks are linked by the correct FGArrow’s. Normalization includes Block fusion when possible, loop nesting choice, detection of unreachable Blocks, and coherence enforcement. When this function completes, the Unit has its “allBlocks” and “topBlocks” computed, plus all the various fields related to the loop nesting in contained BasicBlock’s, LoopBlock’s, HeaderBlock’s, FGArrow’s, etc.

Parameters
  • entryBlock – The EntryBlock of the given raw Flow Graph

  • givenAllBlocks – All the inside blocks of the given raw Flow Graph, unordered, EntryBlock and ExitBlock excluded

  • exitBlock – The ExitBlock of the given raw Flow Graph

  • finalGraph – true when this graph is not going to be analyzed any more, and is rather the final result of AD. In this case condensation will be a little more aggressive.

makeTransferMatrix

public BoolMatrix makeTransferMatrix(int whichKind)
Returns

and builds BoolMatrix “transferMatrix”, which is used to translate public BoolMatrix’es to and from private ZoneMatrix’es, for infos that are travelling to and from the head of this unit.

makeVarFunction

public static Unit makeVarFunction(String funcName, Unit callingUnit)
Returns

an empty unit designed to represent a function which is only a variable of type “function” inside another unit.

middleNormalBlock

public Block middleNormalBlock()
Returns

null if no suitable middle block found.

mustDifferentiateJoint

public boolean mustDifferentiateJoint()

mustDifferentiateSplit

public boolean mustDifferentiateSplit()

name

public String name()
Returns

name of this Unit. For a translation Unit, it is the full path name of the corresponding file.

nestingDepth

public int nestingDepth()
Returns

0 for the topmost Unit’s

otherName

public Unit otherName()

(Hack) Name of another unit (if any) that “corresponds” to this Unit. Used for two-way source-code correspondence e.g. for HTML display.

otherReturnVar

public VariableDecl otherReturnVar()

The alternate return variable name, if different from the function’s name.

paramElemPublicInfo

public PublicInfo paramElemPublicInfo(int i)
Returns

the ZoneInfo of the i-th elementary parameter of this Unit.

paramElemZoneInfo

public ZoneInfo paramElemZoneInfo(int i)
Returns

the ZoneInfo of the i-th elementary parameter of this Unit.

paramElemsNb

public int paramElemsNb()
Returns

the number of elementary parameters of this Unit.

preprocess

protected void preprocess()

privateSymbolTable

public SymbolTable privateSymbolTable()
Returns

the SymbolTable of this Unit’s top private symbols.

protectedSymbolTable

public SymbolTable protectedSymbolTable()
Returns

the SymbolTable of this Unit’s top protected symbols.

publicSymbolTable

public SymbolTable publicSymbolTable()
Returns

the SymbolTable of this Unit’s formal parameters or public symbolDecls.

publicZonesNumber

public int publicZonesNumber(int whichKind)

rank

public int rank()
Returns

The rank of this Unit, for access in UnitStorage’s, Positive number.

removePhantomPackages

public static TapList<Unit> removePhantomPackages(TapList<Unit> diffUnits)

returnIndices

public TapIntList returnIndices(int kind)
Returns

the list of the “kind” zones of the result of this Unit

sameLanguage

public boolean sameLanguage(int lang)

setAllocDealloc

public void setAllocDealloc()

setCalledFromOtherLanguage

public void setCalledFromOtherLanguage()

setClass

public void setClass()

Declare this is a class.

setClassTypeSpec

public void setClassTypeSpec(ClassTypeSpec type)

setConstructor

public void setConstructor()

Declare this is an constructor Unit.

setDeleted

public void setDeleted()

setDestructor

public void setDestructor()

Declare this is an destructor Unit.

setEntryBlock

public void setEntryBlock(EntryBlock eb)

Sets the entry block.

setExitBlock

public void setExitBlock(ExitBlock eb)

Sets the exit Block.

setExternal

public void setExternal()

Declare this is an external Unit.

setExternalSymbolTable

public void setExternalSymbolTable(SymbolTable symbolTable)

Sets the enclosing SymbolTable of this Unit.

setForwardDeclaration

public void setForwardDeclaration(Instruction instr)

For C, for an EXTERNAL Unit, set the C-style forward declaration instruction.

setFragmentInOutCkp

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

setFromInclude

public void setFromInclude(Instruction fromInc)

setFunctionTypeSpec

public void setFunctionTypeSpec(FunctionTypeSpec functionTypeSpec)

Sets the function type of this Unit.

setHasArrayNotation

public void setHasArrayNotation()

Allow for array notation (“vector” notation) in this Unit.

setImportsSymbolTable

public void setImportsSymbolTable(SymbolTable symbolTable)

Sets the imported context SymbolTable of this Unit.

setInStdCIncludeFile

public void setInStdCIncludeFile()

Declares that this Unit comes from a C include file.

setInitConstructorBlock

public void setInitConstructorBlock(InitConstructorBlock ib)

Sets the entry block.

setInterface

public void setInterface()

Declare this is an interface Unit.

setInterfaceDeclaration

public void setInterfaceDeclaration(Instruction instr)

setIntrinsic

public void setIntrinsic()

Declare this is an intrinsic Unit.

setIsDiffPackage

public void setIsDiffPackage(boolean isDiff)

setKind

public void setKind(Unit otherUnit)

Sets the kind of this Unit.

setKind

public void setKind(int kind)

setLanguage

public void setLanguage(int lang)

Sets the programming language.

setLanguageAndUp

public void setLanguageAndUp(int lang)

Sets the programming language, and recursively up on each enclosing Unit.

setLostComments

public void setLostComments(TapList<Tree> lostComments)

Sets the list of all comments lost while building this Unit.

setModule

public void setModule()

Declare this is a module.

setName

public void setName(String name)

Set unit’s name.

Parameters
  • name – unit name.

setOtherName

public void setOtherName(Unit otherUnit)

setOtherReturnVar

public void setOtherReturnVar(VariableDecl otherReturnVar)

setPredefinedModuleOrTranslationUnit

public void setPredefinedModuleOrTranslationUnit()

Declares that this is the MPI module.

setPrivateSymbolTable

public void setPrivateSymbolTable(SymbolTable symbolTable)

Sets the SymbolTable of this Unit’s top private symbols.

setProtectedSymbolTable

public void setProtectedSymbolTable(SymbolTable symbolTable)

Sets the SymbolTable of this Unit’s top protected symbols.

setPublicSymbolTable

public void setPublicSymbolTable(SymbolTable symbolTable)

Sets the SymbolTable of this Unit’s formal parameters or public symbolDecls.

setRank

public void setRank(int rank)

setTranslationUnit

public void setTranslationUnit(String fileName)

Declare this is a “Translation Unit” (i.e. the Unit for a file).

setTranslationUnitSymbolTable

public void setTranslationUnitSymbolTable(SymbolTable symbolTable)

setUndefined

public void setUndefined()

setUpperLevelUnit

public void setUpperLevelUnit(Unit upUnit)

setVarFunction

public void setVarFunction()

Declare this is a Unit for a variable that holds a function.

shortName

protected String shortName()

tapenade web server does not show full path name.

Returns

name of this Unit without directory.

subClassOf

protected boolean subClassOf(Unit parentUnit)

symbolTablesBottomUp

public TapList<SymbolTable> symbolTablesBottomUp()
Returns

the list of all the SymbolTable’s belonging to this Unit. The list contains all SymbolTable’s created for this Unit or for one of its Blocks, ordered with the deepest SymbolTable’s first.

takesArgumentByValue

public boolean takesArgumentByValue(int parameterRank, int callerLanguage)
Parameters
  • parameterRank – rank of this parameter, from 1 to nbArgs

Returns

True if this unit, when called by another unit of language “callerLanguage”, gets the parameter of rank parameterRank by value.

testZoneOfControllerBlock

public int testZoneOfControllerBlock(Block block)

When this block is a controller (e.g. ends with a control statement), returns the zone attached to this control, otherwise returns -1

testZoneOfControllerWhere

public int testZoneOfControllerWhere(Instruction instr)

This instr is assumed to be a where, and therefore is a control. Returns the zone attached to this control

toString

public String toString()

topBlocks

public TapList<Block> topBlocks()
Returns

the DFST-ordered list of all top-level Blocks. i.e. the Blocks that are not enclosed in any loop. This list does not contain the EntryBlock nor the ExitBlock.

transferMatrix

public BoolMatrix transferMatrix(int whichKind)
Returns

the transfer matrix between the public, external numbering of zones and the private, internal numbering specialized for type “whichKind”.

transferTransposed

public BoolMatrix transferTransposed(BoolMatrix matrix, int whichKind)

Computes the same as the product of this Unit’s transferMatrix of kind “whichKind” times the transpose of the given “matrix”, but without ever using the Unit’s transferMatrix because it is so large that we don’t want to build it. If the transferMatrix was computed, this should be equivalent to transferMatrix(whichKind).timesTransposed(matrix)

translateDeclaredToPublicZones

public TapIntList translateDeclaredToPublicZones(TapIntList declaredZones)

Translate a TapIntList of declared zones indices for “this” Unit into the TapIntList of corresponding published zone numbers for this Unit. zones which are local to this Unit are not published, and are therefore discarded.

translateToCallerZones

public TapIntList translateToCallerZones(TapIntList publicZones, Unit origUnit)

Translate the published zones from the given TapIntList “publicZones”, which are expressed with respect to “this” Unit, into the corresponding published zones expressed with respect to Unit “origUnit”. If one such zone is simply unknown in origUnit, then discard it.

translationUnit

public Unit translationUnit()

Returns the enclosing file Unit (aka Translation Unit).

translationUnitSymbolTable

public SymbolTable translationUnitSymbolTable()

turnExternal

public void turnExternal()

Turns a Unit which was created as a OUTSIDE_TBD, into an EXTERNAL.

turnIntrinsic

public void turnIntrinsic()

Turns a Unit which was created as a OUTSIDE_TBD or STANDARD, into an INTRINSIC.

typeCheck

public void typeCheck()

TypeChecks this Unit. TypeChecks each Instruction of this Unit with respect to its enclosing Block’s SymbolTable. Supposes all declarations are already in the SymbolTable, even when they were found later in the code, because all the declarations are inserted into the SymbolTable during a previous phase (cf FlowGraphBuilder). Adds implicit or error recovery declarations for undeclared variables, and creates Unit’s for undeclared routines called.

typeCheckInterface

protected void typeCheckInterface()

TypeChecks this interface. Checks coherence between interface and complete declaration if found.

typeCheckNameEqOptionalArguments

protected WrapperTypeSpec[] typeCheckNameEqOptionalArguments(SymbolTable symbolTable, Tree[] actualArgs, WrapperTypeSpec[] actualTypes, WrapperTypeSpec[] nameEqTypes, int rankOfFirstNameEq, Tree newCallTree, Tree optionalTree, ToBool callUsesNameEq)

typeCheckOptionalArguments

protected void typeCheckOptionalArguments(WrapperTypeSpec[] actualTypes, Tree newCallTree, Tree optionalTree, ToBool callUsesNameEq)

unfocusFromKind

public BoolVector unfocusFromKind(BoolVector vectorKind, int kind)

Reciprocal of focusToKind(). Fills the other zones with false

unitInOutCertainlyR

public BoolVector unitInOutCertainlyR()
Returns

the vector of zones that are certainly completely read by this Unit.

unitInOutCertainlyW

public BoolVector unitInOutCertainlyW()
Returns

the vector of zones that are certainly completely written by this Unit.

unitInOutN

public BoolVector unitInOutN()

In-Out data-flow info: vector of zones possibly/partly not accessed.

unitInOutPossiblyNotW

public BoolVector unitInOutPossiblyNotW()
Returns

the vector of zones that are possibly not written by this Unit.

unitInOutPossiblyR

public BoolVector unitInOutPossiblyR()
Returns

the vector of zones that are possibly read by this Unit.

unitInOutPossiblyRorW

public BoolVector unitInOutPossiblyRorW()
Returns

the vector of zones that are possibly read or written by this Unit.

unitInOutPossiblyW

public BoolVector unitInOutPossiblyW()
Returns

the vector of zones that are possibly written by this Unit.

unitInOutR

public BoolVector unitInOutR()

In-Out data-flow info: vector of zones possibly/partly read and not written.

unitInOutRW

public BoolVector unitInOutRW()

In-Out data-flow info: vector of zones possibly/partly read then written.

unitInOutW

public BoolVector unitInOutW()

In-Out data-flow info: vector of zones possibly/partly not read only written.

unitTBR

public BoolVector unitTBR()

TBR info: vector of zones possibly becoming TBR when going through this Unit, in other words zones used non-linearly and therefore needed in derivatives.

updateNestsOfBlocks

protected void updateNestsOfBlocks(Block block, TapList<Block> blocks)

Inside the list of Blocks that holds this level of the nest of loops, i.e. the nested level that contains “block”, replaces “block” by “blocks”.

upperLevelUnit

public Unit upperLevelUnit()
Returns

the Unit enclosing this one, if exists. null otherwise.

wasDeleted

public boolean wasDeleted()

zonesOfResult

public TapIntList zonesOfResult()

Computes the list of zones of the result of this (function) Unit.

Returns

the zones of the result of this (function) Unit, null if no result.