fluctuation analysis and pass seperation
This commit is contained in:
parent
b644eb51c3
commit
fd40814b36
2 changed files with 44 additions and 9 deletions
|
|
@ -379,15 +379,19 @@ class FortranProgram:
|
|||
|
||||
print "< IR 1 >"
|
||||
ir1 = Stage1(tree)
|
||||
print ir1
|
||||
|
||||
print "< IR 2 >"
|
||||
ir2 = Stage2(ir1)
|
||||
print ir2
|
||||
|
||||
print "dependency graph"
|
||||
pp.pprint (ir2.dependency())
|
||||
|
||||
|
||||
print "< IR 3 >"
|
||||
ir3 = Stage3(ir2)
|
||||
|
||||
|
||||
|
||||
|
||||
self.parser.transform(tree)
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,21 @@ class FieldBase (object):
|
|||
def __repr__ (self):
|
||||
return self.name
|
||||
|
||||
def checkFluctuation (self):
|
||||
|
||||
fset = set([])
|
||||
|
||||
if self.is_fluctuation():
|
||||
fset.add(self.name)
|
||||
|
||||
for d in map(self.fdict.get, self.dep):
|
||||
fset.update(d.checkFluctuation())
|
||||
|
||||
if len(fset) > 0:
|
||||
fset.add(self.name)
|
||||
|
||||
return fset
|
||||
|
||||
|
||||
class Field (FieldBase):
|
||||
|
||||
|
|
@ -95,22 +110,34 @@ class DerivedField (FieldBase):
|
|||
class AveragedField (FieldBase):
|
||||
|
||||
def __init__ (self, w, tgt, fdict):
|
||||
|
||||
if w:
|
||||
name = "{}_avg_{}".format(w, tgt)
|
||||
else:
|
||||
name = "avg_{}".format(tgt)
|
||||
|
||||
super(AveragedField,self).__init__(name, fdict)
|
||||
|
||||
self.tgt = fdict[tgt]
|
||||
self.dep.add(tgt)
|
||||
self.weighted = False
|
||||
|
||||
if w:
|
||||
self.weighted = True
|
||||
self.w = fdict[w]
|
||||
self.dep.add(w)
|
||||
|
||||
self.fset = self.checkFluctuation() - set([self.name])
|
||||
|
||||
def isWeighted (self):
|
||||
return self.weighted
|
||||
|
||||
def pass1 (self):
|
||||
return not self.pass2()
|
||||
|
||||
def pass2 (self):
|
||||
return len(self.fset) > 0
|
||||
|
||||
class CollectDefinitions(Visitor):
|
||||
|
||||
def __init__ (self, primary, derived, averaged):
|
||||
|
|
@ -179,9 +206,6 @@ class Stage2():
|
|||
a = AveragedField(w, t, self.derived)
|
||||
self.averaged[a.name] = a
|
||||
|
||||
print "debug averaged"
|
||||
print self.averaged
|
||||
|
||||
def __repr__ (self):
|
||||
return "\n".join(map(str, [self.derived, self.derivative, self.averaged]))
|
||||
|
||||
|
|
@ -198,12 +222,19 @@ class Stage2():
|
|||
|
||||
|
||||
class Stage3():
|
||||
''' analyze fluctuation '''
|
||||
''' calculate execution order '''
|
||||
|
||||
def __init__ (self, src):
|
||||
self.src = src
|
||||
self.derived = src.derived
|
||||
self.derivative = src.derivative
|
||||
self.averaged = src.averaged
|
||||
self.dependency = src.dependency()
|
||||
|
||||
pass1set = filter(AveragedField.pass1, self.averaged.values())
|
||||
pass2set = filter(AveragedField.pass2, self.averaged.values())
|
||||
|
||||
print pass1set
|
||||
print pass2set
|
||||
|
||||
def __repr__ (self):
|
||||
return "\n".join(map(str, [self.derived, self.derivative]))
|
||||
|
|
@ -212,10 +243,10 @@ class Stage3():
|
|||
|
||||
|
||||
class Stage4():
|
||||
''' pass1 and pass2 seperation and calculation ordering '''
|
||||
''' analyze liveness and allocate array '''
|
||||
|
||||
class Stage5():
|
||||
''' analyze liveness and allocate array '''
|
||||
''' pass1 and pass2 seperation and calculation ordering '''
|
||||
|
||||
class Stage6():
|
||||
''' generate fortran code '''
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue