Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/test_writeDiderot.py
ViewVC logotype

Diff of /branches/ein16/synth/d2/test_writeDiderot.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3945, Thu Jun 9 20:00:15 2016 UTC revision 3946, Sat Jun 11 00:39:19 2016 UTC
# Line 40  Line 40 
40  #itypes: types for input field  #itypes: types for input field
41  #inputlist: name for input data  #inputlist: name for input data
42  def inShape(f,appC):  def inShape(f,appC):
43      app = apply.get_root_app(appC)      #app = apply.get_root_app(appC)
44      i=0      i=0
45      exps =  apply.get_exps(app)      #exps =  apply.get_exps(app)
46        exps = apply.get_all_Fields(appC)
47      for exp in exps:      for exp in exps:
48            #print "current fld",field.toStr(exp)
49          dim = field.get_dim(exp)          dim = field.get_dim(exp)
50          #print ("exp:", field.toStr(exp))          #print ("exp:", field.toStr(exp))
51          fieldShape(f, exp.fldty)          fieldShape(f, exp.fldty)
# Line 108  Line 110 
110      opr_outer=app_outer.opr      opr_outer=app_outer.opr
111      app_inner=apply.get_unary(app_outer)      app_inner=apply.get_unary(app_outer)
112      opr_inner=app_inner.opr      opr_inner=app_inner.opr
113      arity= opr_inner.arity      arity_inner= opr_inner.arity
114      itypes=apply.get_types(app_inner)      arity_outer= opr_outer.arity
115        s_inner=apply.toStr(app_inner,0)
116        s_outer= apply.toStr(app_outer,0)
117        #print s_outer
118    
119        itypes_inner = apply.get_types(app_inner)
120      foo = opfieldname1+" = "      foo = opfieldname1+" = "
121      #checks inside arity      #checks inside arity
122      #assumes outside arity is one      #assumes outside arity is one
123      if (arity==1):      if (arity_inner==1):
124          (_, typ_inner) = applyUnaryOp(opr_inner,itypes)          (_, typ_inner) = applyUnaryOp(opr_inner,itypes_inner)
125            if(arity_outer==1):
126          (_, typ_outer) = applyUnaryOp(opr_outer,[typ_inner])          (_, typ_outer) = applyUnaryOp(opr_outer,[typ_inner])
127          fieldShape(f, typ_outer)          fieldShape(f, typ_outer)
128          foo += (opr_outer.symb)+"("+(opr_inner.symb)+fieldName(0)+")"          foo += (opr_outer.symb)+"("+(opr_inner.symb)+fieldName(0)+")"
129      elif(arity==2):          elif(arity_outer==2):
130          (_, typ_inner)= applyBinaryOp(opr_inner,itypes)              #assumes second arg is a field
131                (f_outer,g_outer) = apply.get_binary(app_outer)
132                #print "f-outer", f_outer
133                #print "g-outer", g_outer
134                g_ty = g_outer.fldty
135                (_, typ_outer) = applyBinaryOp(opr_outer,[typ_inner,  g_ty])
136                fieldShape(f, typ_outer)
137                foo += fieldName(0)+(opr_outer.symb)+"("+(opr_inner.symb)+fieldName(1)+")"
138            else:
139                raise Exception("unsupported arity")
140        elif(arity_inner==2):
141            (_, typ_inner)= applyBinaryOp(opr_inner,itypes_inner)
142            if(arity_outer==1):
143          (_, typ_outer) = applyUnaryOp(opr_outer,[typ_inner])          (_, typ_outer) = applyUnaryOp(opr_outer,[typ_inner])
144          fieldShape(f, typ_outer)          fieldShape(f, typ_outer)
145          foo += (opr_outer.symb)+"("+fieldName(0)+(opr_inner.symb)+fieldName(1)+")"          foo += (opr_outer.symb)+"("+fieldName(0)+(opr_inner.symb)+fieldName(1)+")"
146            elif(arity_outer==2):
147                (f_outer,g_outer) = apply.get_binary(app_outer)
148                #print "f-outer", f_outer
149                #print "g-outer", g_outer
150                g_ty = g_outer.fldty
151                (_, typ_outer) = applyBinaryOp(opr_outer,[typ_inner,  g_ty])
152                fieldShape(f, typ_outer)
153                foo += "("+fieldName(0)+(opr_inner.symb)+fieldName(1)+")"+(opr_outer.symb)+fieldName(2)
154            else:
155                raise Exception("unsupported arity")
156      else:      else:
157          raise Exception("unsupported arity")          raise Exception("unsupported arity")
158      foo += ";\n"      foo += ";\n"
159      f.write(foo.encode('utf8'))      f.write(foo.encode('utf8'))
160    
161  def replaceOp(f,app):  def replaceOp(f,app):
162      if(app.isroot):      # one or two?
163        if(app.isrootlhs):
164          return gotop1(f,app)          return gotop1(f,app)
165      else: #twice embedded      else: #twice embedded
166          return gotop2(f,app)          return gotop2(f,app)
# Line 212  Line 242 
242  def writeDiderot(p_out, app, pos, output, runtimepath, isVis):  def writeDiderot(p_out, app, pos, output, runtimepath, isVis):
243      readDiderot(p_out,app,pos)      readDiderot(p_out,app,pos)
244      # compile and run diderot program      # compile and run diderot program
245      print runtimepath      # print runtimepath
246      os.system(" echo \"pout "+p_out+"\"")      os.system(" echo \"pout "+p_out+"\"")
247      os.system(" echo \"create diderot program "+p_out+".diderot \"")      os.system(" echo \"create diderot program "+p_out+".diderot \"")
248      os.system(runtimepath+" "+p_out+".diderot")      os.system(runtimepath+" "+p_out+".diderot")

Legend:
Removed from v.3945  
changed lines
  Added in v.3946

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0