Changeset 2612 for proto/Compiler


Ignore:
Timestamp:
Nov 5, 2012, 5:25:27 PM (7 years ago)
Author:
cameron
Message:

Experimental mode for CCGO

Location:
proto/Compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/config.py

    r2393 r2612  
    3535                          default=False,
    3636                          help='use C syntax for output',
     37                          )
     38       
     39        parser.add_option('-X', '--experimental',
     40                          dest='experimental',
     41                          action='store_true',
     42                          default=False,
     43                          help='Experimental version with CCGO support',
    3744                          )
    3845       
  • proto/Compiler/pablo.py

    r2606 r2612  
    1313do_final_block_inline_decorator = ''
    1414error_routine = 'raise_assert'
    15 
     15experimentalMode=False
    1616
    1717def isCarryGenerating(builtin_fn):
     
    2121def usesCarryCountArgument(builtin_fn):
    2222   return builtin_fn in ['Advance']
     23
     24def GetBuiltinFn(fncall, builtin_fnmod_noprefix='pablo'):
     25  if not isinstance(fncall, ast.Call): return None
     26  if isinstance(fncall.func, ast.Name): fn_name = fncall.func.id
     27  elif isinstance(fncall.func, ast.Attribute) and isinstance(fncall.func.value, ast.Name):
     28    if fncall.func.value.id == builtin_fnmod_noprefix: fn_name = fncall.func.attr
     29    else: return None
     30  else: return None
     31  if isCarryGenerating(fn_name): return fn_name
     32  else: return None
     33
    2334
    2435def CarryCountOfFn(fncall, builtin_fnmod_noprefix='pablo'):
     
    394405    return self.adv_n_count
    395406
     407
     408
     409
     410class testCCGO():
     411    def GenerateCarryInAccess(self, carry_group_var, carry_index):
     412        return mkCall(carry_group_var + "." + 'get_carry_in', [ast.Num(carry_index)])
     413    def GenerateCarryOutStore(self, carry_group_var, carry_index, carry_out_expr):
     414        return ast.Assign([ast.Subscript(ast.Attribute(ast.Name(carry_group_var, ast.Load()), 'cq', ast.Load()), ast.Index(ast.Num(carry_index)), ast.Store())],
     415                          mkCall("bitblock::srli<127>", [carry_out_expr]))
     416
     417
    396418class CarryIntro(ast.NodeTransformer):
    397419  def __init__(self, carryvar="carryQ", carryin = "_ci", carryout = "_co"):
     
    399421    self.carryin = carryin
    400422    self.carryout = carryout
     423    self.ccgo = testCCGO()
    401424  def xfrm_fndef(self, fndef):
    402425    self.current_carry = 0
     
    547570      return c
    548571    else: return exprnode
    549   def visit_Assign(self, assignode):
    550       self.last_stmt_carries = CarryCounter().count(assignode)
    551       self.generic_visit(assignode)
    552       self.last_stmt = assignode
    553       return assignode
     572  def visit_Assign(self, assigNode):
     573    self.last_stmt_carries = CarryCounter().count(assigNode)
     574    f = GetBuiltinFn(assigNode.value)
     575    if f == None:
     576            self.generic_visit(assigNode)
     577            self.last_stmt = assigNode
     578            return assigNode
     579    elif isCarryGenerating(f) and CarryCountOfFn(assigNode.value) == 1 and experimentalMode:
     580    # We have an assignment v = pablo.SomeCarryGeneratingFunction()
     581    #elif f == 'ScanThru':
     582            if self.carryin == "_ci":
     583                carry_in_expr = self.ccgo.GenerateCarryInAccess(self.carryvar.id, self.current_carry)
     584            else:
     585                carry_in_expr = mkCall('simd<1>::constant<0>', [])
     586            callnode = assigNode.value
     587            if f in ['ScanTo', 'AdvanceThenScanTo']:
     588               if self.carryout == "":  scanclass = mkCall('simd_andc', [ast.Name('EOF_mask', ast.Load()), callnode.args[1]])
     589               else: scanclass = mkCall('simd_not', [callnode.args[1]])
     590               pablo_routine_call = mkCall('pablo_blk_' +f[:-2] + 'Thru', [callnode.args[0], scanclass, carry_in_expr, assigNode.targets[0]])
     591            else:
     592               pablo_routine_call = mkCall('pablo_blk_' + f, assigNode.value.args + [carry_in_expr, assigNode.targets[0]])
     593            self.last_stmt = pablo_routine_call
     594            compiled = self.ccgo.GenerateCarryOutStore(self.carryvar.id,  self.current_carry, pablo_routine_call)
     595            self.current_carry += 1
     596            return compiled
     597    else:
     598            self.generic_visit(assigNode)
     599            self.last_stmt = assigNode
     600            return assigNode
    554601
    555602  def visit_If(self, ifNode):
     
    9821029
    9831030class MainLoopTransformer:
    984   def __init__(self, main_module, C_syntax=False, add_dump_stmts=False, add_assert_bitblock_align=False, dump_func_data=False, main_node_id='Main'):
     1031  def __init__(self, main_module, C_syntax=False, experimental=False, add_dump_stmts=False, add_assert_bitblock_align=False, dump_func_data=False, main_node_id='Main'):
    9851032       
    9861033    self.main_module = main_module
     
    9901037    self.add_assert_bitblock_align = add_assert_bitblock_align
    9911038    self.dump_func_data = dump_func_data
     1039    self.experimental = experimental
    9921040   
    9931041        # Gather and partition function definition nodes.
  • proto/Compiler/pablomain.py

    r2393 r2612  
    8484
    8585        pablo.error_routine = options.error_routine
    86                
     86
     87        pablo.experimentalMode = options.experimental
     88       
    8789        if options.use_IDISA:
    8890                pablo.name_substitution_map = {'bitblock_has_bit' : 'bitblock::any',
Note: See TracChangeset for help on using the changeset viewer.