coins.hir2lir
クラス ReformHir

java.lang.Object
  |
  +--coins.hir2lir.ReformHir

public class ReformHir
extends java.lang.Object

ReformHir class Reform HIR for profiling and parallelization without using OpenMP.


フィールドの概要
protected  boolean fChanged
           
protected  CoinsOptions fCoinsOptions
           
protected  int fDbgLevel
           
protected  LoopParallel fLoopParallel
           
protected  java.util.Map fLoopStmtToLoopTable
           
protected  java.util.List fLoopsToBeParallelized
           
 FlowRoot flowRoot
           
protected  int fMaxDegreeOfParallel
           
 int fMaximumNumberOfReductions
           
protected  Var fNumberOfThreads
           
protected  FlowResults fResults
           
protected  boolean fStackInLocalMemory
           
protected  java.util.Map fStatementsToBeAdded
           
protected  java.util.List fStatementsToBeDeleted
           
protected  java.util.Map fStatementsToBeReplaced
           
protected  java.util.List fSubpDefinitionList
           
protected  SubpFlow fSubpFlow
           
protected  SymTable fSymTableCurrent
           
protected  Var fThreadDescriptor
           
protected  Subp fThreadEnd
           
protected  Subp fThreadForkForDoAll
           
protected  Var fThreadIdArray
           
protected  Var fThreadIdOfMaster
           
protected  Subp fThreadInit
           
protected  Subp fThreadJoin
           
protected  Subp fThreadPostprocess
           
protected  Subp fThreadPostprocessForDoAllThread
           
protected  Subp fThreadPreprocessForDoAllLoop
           
protected  Subp fThreadPreprocessForDoAllThread
           
protected  Subp fThreadSelfId
           
protected  Type fThreadType
           
protected  LoopUtil fUtil
           
protected  HIR hir
           
 HirRoot hirRoot
           
 IoRoot ioRoot
           
protected  SubpFlow subpFlow
           
protected  Sym sym
           
 SymRoot symRoot
           
 
コンストラクタの概要
ReformHir(HirRoot pHirRoot)
          ReformHir Process HIR pragmas and change them to ones that may correspond to HIR pragma.
 
メソッドの概要
protected  void callHirBaseToC(HirRoot hirRoot, SymRoot symRoot, IoRoot io, java.io.OutputStream out)
          Translates HIR-Base into a C source program and writes it to an OutputStream.
protected  void changeLoopToSubprogram(LoopTable pTable)
          Change loop indicated by pTable to a subprogram to be executed in parallel.
 Param defineParam(java.lang.String pHeader, Type pType, SymTable pSymTable)
           
 Var defineVar(java.lang.String pHeader, Type pType, SymTable pSymTable, Subp pDefinedIn)
           
protected  Var getPrimaryInductionVar(ForStmt pForStmt)
          Get the primary induction variable of the loop.
protected  Reduction getReductionForVar(Var pVar, java.util.List pReductionList)
           
protected  java.util.List getReductionList(LoopTable pTable)
          Get the list of reductions for the loop represented by pTable.
protected  java.util.Set getReductionVar(java.util.List pReductionList)
          Get all reduction variables each of which corresponds to the reduction table in pReductionList.
protected  Var getVarOfExp(Exp pExp)
          Get the variable represented by pExp or by its child 1 node.
protected  Exp initialValueOfReduction(LoopTable pTable, Var pReductionVar)
           
protected  boolean makeCSourceFromHirBase(java.lang.String timing, HirRoot hirRoot, SymRoot symRoot, IoRoot io)
           
protected  SubpDefinition makeSubpDefinition(LoopTable pTable, java.util.List pInLoopVarList, java.util.List pChangeToLocal, java.util.List pChangeToGlobal, java.util.Set pInductionVars, java.util.Set pReductionVarSet, java.util.Set pReductionsToInitiate, java.util.List pPassPointer, java.util.Set pCopyToChild, java.util.Set pCopyBack)
          Make subprogram definition corresponding to the loop represented by pTable.
protected  boolean parallelize(SubpDefinition pSubpDefinition)
          Parallelize the subprogram pSubpDefinition.
 void printList(java.util.List pList, java.lang.String pHeader)
          Print the list pList with header pHeader.
protected  void printLoopTable(LoopTable pTable)
           
 void printSet(java.util.Set pSet, java.lang.String pHeader)
          Print the set pSet with header indicated by pHeader.
protected  boolean reformForInitiation(SubpDefinition pSubpDefinition)
          Reform for thread initiation without parallelizing.
 void reformForParallel()
           
 void reformForProfiling()
          Change global gragmas (pragmas placed as global declaration) (inf prof (defaultTraceOn)) (inf prof (defaultTraceOff)) (inf prof (subpTraceOn subp1 subp1 ...))
protected  boolean reformHirToParallelize()
          Decide how to transform HIR of SubpDefinition indicated by subpFlow so as it can be executed in parallel.
protected  HIR rewriteVariables(HIR pNewHir, java.util.Map pOldSymToNewVarExp)
          Rewrite variables in pNewHir according to the map pOldSymToNewVarExp.
protected  java.util.Set varNodeToVarSet(java.util.Set pVarNodes)
          Change the set of VarNodes to a set of corresponding Vars.
protected  Stmt writeVector(Var pFromVar, Var pToVar, SymTable pSymTable)
           
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

ioRoot

public final IoRoot ioRoot

symRoot

public final SymRoot symRoot

hirRoot

public final HirRoot hirRoot

hir

protected HIR hir

sym

protected Sym sym

fCoinsOptions

protected CoinsOptions fCoinsOptions

fChanged

protected boolean fChanged

flowRoot

public FlowRoot flowRoot

fLoopParallel

protected LoopParallel fLoopParallel

fUtil

protected LoopUtil fUtil

fSubpFlow

protected SubpFlow fSubpFlow

subpFlow

protected SubpFlow subpFlow

fResults

protected FlowResults fResults

fSymTableCurrent

protected SymTable fSymTableCurrent

fSubpDefinitionList

protected java.util.List fSubpDefinitionList

fStatementsToBeReplaced

protected java.util.Map fStatementsToBeReplaced

fStatementsToBeAdded

protected java.util.Map fStatementsToBeAdded

fStatementsToBeDeleted

protected java.util.List fStatementsToBeDeleted

fLoopStmtToLoopTable

protected java.util.Map fLoopStmtToLoopTable

fLoopsToBeParallelized

protected java.util.List fLoopsToBeParallelized

fMaxDegreeOfParallel

protected int fMaxDegreeOfParallel

fThreadType

protected Type fThreadType

fThreadDescriptor

protected Var fThreadDescriptor

fNumberOfThreads

protected Var fNumberOfThreads

fThreadIdArray

protected Var fThreadIdArray

fThreadIdOfMaster

protected Var fThreadIdOfMaster

fStackInLocalMemory

protected boolean fStackInLocalMemory

fThreadInit

protected Subp fThreadInit

fThreadEnd

protected Subp fThreadEnd

fThreadPreprocessForDoAllLoop

protected Subp fThreadPreprocessForDoAllLoop

fThreadPostprocess

protected Subp fThreadPostprocess

fThreadForkForDoAll

protected Subp fThreadForkForDoAll

fThreadPreprocessForDoAllThread

protected Subp fThreadPreprocessForDoAllThread

fThreadPostprocessForDoAllThread

protected Subp fThreadPostprocessForDoAllThread

fThreadJoin

protected Subp fThreadJoin

fThreadSelfId

protected Subp fThreadSelfId

fDbgLevel

protected int fDbgLevel

fMaximumNumberOfReductions

public final int fMaximumNumberOfReductions
関連項目:
定数フィールド値
コンストラクタの詳細

ReformHir

public ReformHir(HirRoot pHirRoot)
ReformHir Process HIR pragmas and change them to ones that may correspond to HIR pragma. If InfStmts are changed, then renumber the HIR nodes.

メソッドの詳細

reformForProfiling

public void reformForProfiling()
Change global gragmas (pragmas placed as global declaration) (inf prof (defaultTraceOn)) (inf prof (defaultTraceOff)) (inf prof (subpTraceOn subp1 subp1 ...)) (inf prof (subpTraceOff subp1 subp1 ...)) to subprogram-wise pragma.


reformForParallel

public void reformForParallel()

parallelize

protected boolean parallelize(SubpDefinition pSubpDefinition)
Parallelize the subprogram pSubpDefinition.

パラメータ:
pSubpDefinition - Subprogram definition requested to be parallelized.
戻り値:
true if parallelizing transformation is actually done.

reformForInitiation

protected boolean reformForInitiation(SubpDefinition pSubpDefinition)
Reform for thread initiation without parallelizing.

パラメータ:
pSubpDefinition - Subprogram definition that may contain thread initiation pragma.
戻り値:
true if transformation is actually done.

reformHirToParallelize

protected boolean reformHirToParallelize()
Decide how to transform HIR of SubpDefinition indicated by subpFlow so as it can be executed in parallel. The results are recorded in fStatementsToBeAdded fStatementsToBeReplaced, fStatementsToBeDeleted.

戻り値:
true if HIR is to be actually transformed.

changeLoopToSubprogram

protected void changeLoopToSubprogram(LoopTable pTable)
Change loop indicated by pTable to a subprogram to be executed in parallel.

パラメータ:
pTable - Loop table of the loop to be parallelized.

makeSubpDefinition

protected SubpDefinition makeSubpDefinition(LoopTable pTable,
                                            java.util.List pInLoopVarList,
                                            java.util.List pChangeToLocal,
                                            java.util.List pChangeToGlobal,
                                            java.util.Set pInductionVars,
                                            java.util.Set pReductionVarSet,
                                            java.util.Set pReductionsToInitiate,
                                            java.util.List pPassPointer,
                                            java.util.Set pCopyToChild,
                                            java.util.Set pCopyBack)
Make subprogram definition corresponding to the loop represented by pTable.

パラメータ:
pTable - Loop table of the loop.
pInLoopVarList - list of variables appering in the loop.
pChangeToLocal - variables to be changed from global to local.
pChangeToGlobal - variables to be changed from local to global.
pInductionVars - set of induction variables in the loop.
pReductionVarSet - set of reduction variables in the loop.
pReductionsToInitiate - set of reduction variables to be initialized in the generated subprgoram.
pPassPointer - set of variables passing write back receiver including reductions.
pCopyToChild - set of variables to be copied from parent to child (neither last private nore reduction).
pCopyBack - set of variabled to be copied from child to parent (neither last private nore reduction).
戻り値:
SubpDefinition generated.

rewriteVariables

protected HIR rewriteVariables(HIR pNewHir,
                               java.util.Map pOldSymToNewVarExp)
Rewrite variables in pNewHir according to the map pOldSymToNewVarExp.

パラメータ:
pNewHir - Statement or expression to be changed.
pOldSymToNewVarExp - maps old variable to new variable expression.

defineVar

public Var defineVar(java.lang.String pHeader,
                     Type pType,
                     SymTable pSymTable,
                     Subp pDefinedIn)

defineParam

public Param defineParam(java.lang.String pHeader,
                         Type pType,
                         SymTable pSymTable)

getPrimaryInductionVar

protected Var getPrimaryInductionVar(ForStmt pForStmt)
Get the primary induction variable of the loop.

パラメータ:
pForStmt - loop statement.
戻り値:
the primary induction variable

writeVector

protected Stmt writeVector(Var pFromVar,
                           Var pToVar,
                           SymTable pSymTable)

printLoopTable

protected void printLoopTable(LoopTable pTable)

printList

public void printList(java.util.List pList,
                      java.lang.String pHeader)
Print the list pList with header pHeader.

パラメータ:
pList - list of items to be printed.
pHeader - string explaining the set in short.

printSet

public void printSet(java.util.Set pSet,
                     java.lang.String pHeader)
Print the set pSet with header indicated by pHeader.

パラメータ:
pSet - set of items.
pHeader - header string to be printed.

varNodeToVarSet

protected java.util.Set varNodeToVarSet(java.util.Set pVarNodes)
Change the set of VarNodes to a set of corresponding Vars.

パラメータ:
pVarNodes - set of VarNodes.
戻り値:
the set of Var symbols.

getVarOfExp

protected Var getVarOfExp(Exp pExp)
Get the variable represented by pExp or by its child 1 node.

パラメータ:
pExp -
戻り値:
the variable represented by pExp.

getReductionVar

protected java.util.Set getReductionVar(java.util.List pReductionList)
Get all reduction variables each of which corresponds to the reduction table in pReductionList.

パラメータ:
pReductionList - list of reductions.
戻り値:
set of reduction variables.

getReductionList

protected java.util.List getReductionList(LoopTable pTable)
Get the list of reductions for the loop represented by pTable.

パラメータ:
pTable - LoopTable of the loop.
戻り値:
list of reductions.

getReductionForVar

protected Reduction getReductionForVar(Var pVar,
                                       java.util.List pReductionList)

initialValueOfReduction

protected Exp initialValueOfReduction(LoopTable pTable,
                                      Var pReductionVar)

makeCSourceFromHirBase

protected boolean makeCSourceFromHirBase(java.lang.String timing,
                                         HirRoot hirRoot,
                                         SymRoot symRoot,
                                         IoRoot io)
                                  throws java.io.IOException
java.io.IOException

callHirBaseToC

protected void callHirBaseToC(HirRoot hirRoot,
                              SymRoot symRoot,
                              IoRoot io,
                              java.io.OutputStream out)
                       throws java.io.IOException
Translates HIR-Base into a C source program and writes it to an OutputStream.

パラメータ:
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - the IoRoot.
out - an OutputStream to which the C source program is written.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.