Changeset 2206


Ignore:
Timestamp:
Jun 4, 2012, 7:03:52 PM (7 years ago)
Author:
cameron
Message:

Added pablo.advance(strm, n) support (non-nested).

Location:
proto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2100 r2206  
    255255    return self.carry_count
    256256
    257 class Adv32Counter(ast.NodeVisitor):
     257class adv_nCounter(ast.NodeVisitor):
    258258  def visit_Call(self, callnode):
    259259    self.generic_visit(callnode)
    260260    if is_BuiltIn_Call(callnode,'Advance32', 1):       
    261       self.adv32_count += 1
     261      self.adv_n_count += 1
     262    if is_BuiltIn_Call(callnode,'Advance', 2):         
     263      self.adv_n_count += 1
    262264  def count(self, nodeToVisit):
    263     self.adv32_count = 0
     265    self.adv_n_count = 0
    264266    self.generic_visit(nodeToVisit)
    265     return self.adv32_count
     267    return self.adv_n_count
    266268
    267269class CarryIntro(ast.NodeTransformer):
     
    272274  def xfrm_fndef(self, fndef):
    273275    self.current_carry = 0
    274     self.current_adv32 = 0
     276    self.current_adv_n = 0
    275277    carry_count = CarryCounter().count(fndef)
    276278    if carry_count == 0: return fndef
     
    281283  def generic_xfrm(self, node):
    282284    self.current_carry = 0
    283     self.current_adv32 = 0
     285    self.current_adv_n = 0
    284286    carry_count = CarryCounter().count(node)
    285     adv32_count = Adv32Counter().count(node)
    286     if carry_count == 0 and adv32_count == 0: return node
     287    adv_n_count = adv_nCounter().count(node)
     288    if carry_count == 0 and adv_n_count == 0: return node
    287289    self.generic_visit(node)
    288290    return node
     
    291293    #CARRYSET
    292294    #carry_args = [ast.Num(self.current_carry)]
    293     #adv32_args = [ast.Subscript(ast.Name('pending32', ast.Load()), ast.Num(self.current_adv32), ast.Load())]
    294     adv32_pending = ast.Subscript(ast.Name('pending32', ast.Load()), ast.Num(self.current_adv32), ast.Load())
     295    #adv_n_args = [ast.Subscript(ast.Name(self.carryvar.id + '.pending64', ast.Load()), ast.Num(self.current_adv_n), ast.Load())]
     296    adv_n_pending = ast.Subscript(ast.Name(self.carryvar.id + '.pending64', ast.Load()), ast.Num(self.current_adv_n), ast.Load())
    295297    if self.carryin == "_ci":
    296298        carry_args = [mkCall(self.carryvar.id + "." + 'get_carry_in', [ast.Num(self.current_carry)]), ast.Num(self.current_carry)]
    297         adv32_args = [adv32_pending, adv32_pending]
     299        adv_n_args = [adv_n_pending, ast.Num(self.current_adv_n)]
    298300    else:
    299301        carry_args = [mkCall('simd<1>::constant<0>', []), ast.Num(self.current_carry)]
    300         adv32_args = [ast.Num(0), adv32_pending]
    301 
     302        adv_n_args = [mkCall('simd<1>::constant<0>', []), ast.Num(self.current_adv_n)]
     303
     304    if is_BuiltIn_Call(callnode, 'Advance', 2):         
     305      #CARRYSET
     306      rtn = self.carryvar.id + "." + "BitBlock_advance_n_<%i>" % callnode.args[1].n
     307      c = mkCall(rtn, [callnode.args[0]] + adv_n_args)
     308      self.current_adv_n += 1
     309      return c
    302310    if is_BuiltIn_Call(callnode, 'Advance', 1):         
    303311      #CARRYSET
     
    308316    elif is_BuiltIn_Call(callnode, 'Advance32', 1):     
    309317      #CARRYSET
    310       rtn = self.carryvar.id + "." + "BitBlock_advance32_ci_co"
    311       c = mkCall(rtn, callnode.args + adv32_args)
    312       self.current_adv32 += 1
     318      rtn = self.carryvar.id + "." + "BitBlock_advance_n_<32>"
     319      c = mkCall(rtn, callnode.args + adv_n_args)
     320      self.current_adv_n += 1
    313321      return c
    314322    elif is_BuiltIn_Call(callnode, 'ScanThru', 2):
     
    413421    carry_base = self.current_carry
    414422    carries = CarryCounter().count(ifNode)
    415     assert Adv32Counter().count(ifNode) == 0, "Advance32() within if: illegal\n"
     423    assert adv_nCounter().count(ifNode) == 0, "Advance(x,n) within if: illegal\n"
    416424    self.generic_visit(ifNode)
    417425    if carries == 0 or self.carryin == "": return ifNode
     
    425433      whileNode.test.args[0] = mkCall("simd_and", [whileNode.test.args[0], ast.Name('EOF_mask', ast.Load())])
    426434    carry_base = self.current_carry
    427     assert Adv32Counter().count(whileNode) == 0, "Advance32() within while: illegal\n"
     435    assert adv_nCounter().count(whileNode) == 0, "Advance(x,n) within while: illegal\n"
    428436    carries = CarryCounter().count(whileNode)
    429437    #CARRYSET
     
    461469    BitBlock a2;
    462470    BitBlock a3;
    463   }    self.current_adv32 = 0
     471  }    self.current_adv_n = 0
    464472
    465473 
     
    603611        def __init__(self):
    604612                self.carry_count = 0
    605                 self.adv32_count = 0
     613                self.adv_n_count = 0
    606614                self.type_name = ""
    607615                self.instance_name = ""
     
    632640                self.type_name = stream_function.type_name
    633641               
    634                 if stream_function.carry_count > 0 or stream_function.adv32_count > 0:
    635                         constructor = self.constructor(stream_function.type_name, stream_function.carry_count, stream_function.adv32_count)
    636                         carry_declaration = self.carry_declare('carryQ', stream_function.carry_count, stream_function.adv32_count)
     642                if stream_function.carry_count > 0 or stream_function.adv_n_count > 0:
     643                        constructor = self.constructor(stream_function.type_name, stream_function.carry_count, stream_function.adv_n_count)
     644                        carry_declaration = self.carry_declare('carryQ', stream_function.carry_count, stream_function.adv_n_count)
    637645
    638646                do_block_function = self.do_block(self.do_block_parameters(stream_function.parameters),
     
    665673                + "\n" + self.indent(icount) + "};\n\n"
    666674
    667         def constructor(self, type_name, carry_count, adv32_count, icount=0):
    668                 adv32_decl = ""
    669                 for i in range(adv32_count): adv32_decl += self.indent(icount+2) + "pending32[%s] = 0;\n" % i   
    670                 return self.indent(icount) + "%s() { ""\n" % (type_name) + adv32_decl + self.carry_init(carry_count) + " }"
     675        def constructor(self, type_name, carry_count, adv_n_count, icount=0):
     676                adv_n_decl = ""
     677                #for i in range(adv_n_count): adv_n_decl += self.indent(icount+2) + "pending64[%s] = simd<1>::constant<0>();\n" % i     
     678                return self.indent(icount) + "%s() { ""\n" % (type_name) + adv_n_decl + self.carry_init(carry_count) + " }"
    671679                       
    672680        def do_block(self, parameters, declarations, initializations, statements, icount=0):
     
    723731                return ""
    724732               
    725         def carry_declare(self, carry_variable, carry_count, adv32_count=0, icount=0):
    726                 adv32_decl = ""
    727                 if adv32_count > 0:
    728                         adv32_decl = "\n" + self.indent(icount) + "uint32_t pending32[%s];" % adv32_count
     733        def carry_declare(self, carry_variable, carry_count, adv_n_count=0, icount=0):
     734                adv_n_decl = ""
     735                #if adv_n_count > 0:
     736                #       adv_n_decl = "\n" + self.indent(icount) + "BitBlock pending64[%s];" % adv_n_count
    729737                #CARRY SET
    730                 return self.indent(icount) + "CarryArray<%i> %s;" % (carry_count, carry_variable) + adv32_decl
     738                return self.indent(icount) + "CarryArray<%i, %i> %s;" % (carry_count, adv_n_count, carry_variable)
    731739
    732740        def carry_test(self, carry_variable, carry_count, icount=0):
     
    786794    self.main_node = self.stream_function_node[main_node_id]
    787795    self.main_carry_count = CarryCounter().count(self.main_node)
    788     self.main_adv32_count = Adv32Counter().count(self.main_node)
    789     assert self.main_adv32_count == 0, "Advance32() in main not supported.\n"
     796    self.main_adv_n_count = adv_nCounter().count(self.main_node)
     797    assert self.main_adv_n_count == 0, "Advance32() in main not supported.\n"
    790798    del self.stream_function_node[self.main_node_id]
    791799   
     
    794802                stream_function = StreamFunction()
    795803                stream_function.carry_count = CarryCounter().count(node)
    796                 stream_function.adv32_count = Adv32Counter().count(node)
     804                stream_function.adv_n_count = adv_nCounter().count(node)
    797805                stream_function.type_name = node.name[0].upper() + node.name[1:]
    798806                stream_function.instance_name = node.name[0].lower() + node.name[1:]
  • proto/parabix2/pablo_template.cpp

    r2204 r2206  
    66
    77#define LocalCarryDeclare(name, count)\
    8 CarryArray<count> name;\
     8CarryArray<count, 0> name;\
    99
    1010#include "../lib/bitblock.hpp"
  • proto/parabix2/parabix2_pablo.py

    r2204 r2206  
    321321        v = lex.LAngle | lex.Hyphen
    322322        w = lex.Hyphen | lex.QMark
    323         v1 = pablo.Advance(v)
    324         w1 = pablo.Advance(w)
     323        v1 = pablo.Advance(v,1)
     324        w1 = pablo.Advance(w,1)
    325325       
    326326        LAngle_scope = v1 &~ w1  #pablo.Advance(lex.LAngle)
Note: See TracChangeset for help on using the changeset viewer.