public class ArrayPrivatization extends AnalysisPass
[1:m] (intersect) [1:n]
results in [1:n]
if the expression comparison tool with the value range set can decide
n
is less than or equal to m
.
The algorithm traverses a loop nest from the innermost to the outermost loop.
At each level, it first collects definitions
(write references)
and uses
(read references) in the loop body. Uses that are
covered by prior definitions create privatizable variables (or array
sections) for the current loop. The other uses are
upward exposed
, creating read
references seen in the outer loop. Second, the algorithm aggregates all
these array sections over the loop iteration space, creating the array
sections that are private, written and upward exposed for the entire loop.
The aggregation for the written sections (DEF
) computes the
must-defined regular sections of the arrays over the entire loop iteration
while the aggregation of upward-exposed sections (UEU
) requires
only the conservative value ranges of the sections (may-used sections). This
algorithm is a slightly simpler version of the one used in the Polaris
parallelizing compiler for Fortran77 programs.
procedure Privatization(L) Input : Loop L Output: DEF[L], UEU[L], PRI[L] // DEF: Definded set // USE: Used set // UEU: Upward-exposed set // PRI: Private variables // (^): intersection, (v): union foreach direct inner loop L' in L (DEF[L'],USE[L']) = Privatization(L') G(N,E) = BuildCFG(L) // BuildCFG builds a CFG with the inner loops represented as super nodes Iteratively solve data flow equation DEF for node n in N DEFin[n] = (^) {DEFout[p], p in predecessors of n} DEFout[n] = (DEFin[n]-KILL[n]) (v) DEF[n] DEF[L] = {} UEU[L] = {} PRI[L] = CollectCandidates(L) // CollectCandidates collects variables that satisfies the following: // 1. It has write access in the loop body. // 2. Its subscript do not contain loop-variant variables. foreach loop-exiting node e in N DEF[L] = DEF[L] (^) DEFout[e] foreach node n in N UEU[L] = UEU[L] (v) (USE[n]-DEFin[n]) foreach variable v in UEU[L] PRI[L] = PRI[L]-{v} DEF[L] = AggregateDEF(DEF[L]) UEU[L] = AggregateUSE(UEU[L]) // AggregateDEF aggregates array sections in DEF (MUST set) // AggregateUSE aggregates array sections in USE (MAY set) return (DEF[L], UEU[L]) endArray privatization is invoked by specifying the flag
-privatize
,
and the result is stored as an annotation that contains the set of private
variables. We do not consider a variable with user-defined type as a
candidate private variable, but intend to widen the scope of the analysis
in the future.Constructor and Description |
---|
ArrayPrivatization(Program program)
Constructs an array privatization analyzer for a program.
|
Modifier and Type | Method and Description |
---|---|
void |
analyzeProcedure(Procedure proc)
Starts array privatization for a procedure.
|
java.lang.String |
getPassName()
Returns the pass name.
|
void |
start()
Starts array privatization by calling the procedure-level driver for each
procedure within the program.
|
run
public ArrayPrivatization(Program program)
program
- the input program.public java.lang.String getPassName()
getPassName
in class AnalysisPass
public void start()
start
in class AnalysisPass
public void analyzeProcedure(Procedure proc)
analyzeLoop(Loop)
to analyze the outer-most loops in the
procedure. The final step is to annotate the analysis result for each
loop in the procedure.proc
- the input procedure.