Changeset 2697


Ignore:
Timestamp:
Nov 27, 2012, 6:45:43 AM (7 years ago)
Author:
cameron
Message:

Support Advance(x,n) in experimental mode

Location:
proto/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/CCGO.py

    r2693 r2697  
    2828    def GenerateCarryInAccess(self, operation_no): return None
    2929    def GenerateCarryOutStore(self, operation_no, carry_out_expr): return []
     30    def GenerateAdvanceInAccess(self, operation_no): return None
     31    def GenerateAdvanceOutStore(self, operation_no, carry_out_expr): return []
    3032    def GenerateCarryIfTest(self, block_no, ifTest): return ifTest
    3133    def GenerateCarryElseFinalization(self, block_no): return []
     
    5961        self.carryGroupVar = carryGroupVarName
    6062        self.carryIndex = {}
     63        self.advIndex = {}
    6164        self.operation_offset = 0
    6265        carry_counter = 0
     66        adv_counter = 0
    6367        for op_no in range(carryInfoSet.operation_count):
    6468          self.carryIndex[op_no] = carry_counter
    6569          if not op_no in carryInfoSet.advance_amount.keys(): carry_counter += 1
    6670          elif carryInfoSet.advance_amount[op_no] == 1: carry_counter += 1
     71          else: 
     72            self.advIndex[op_no] = adv_counter
     73            adv_counter += 1
    6774        # Add a dummy entry for any possible final block that is empty.
    6875        self.carryIndex[carryInfoSet.operation_count] = carry_counter
     76        self.advIndex[carryInfoSet.operation_count] = adv_counter
     77        self.carry_count = carry_counter
    6978    # Helper
    7079    def CarryGroupAtt(self, attname, CarryGroupVarName=""):
     
    97106        return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(carry_index)), ast.Store())],
    98107                          mkCall("bitblock::srli<127>", [carry_out_expr]))]
     108    def GenerateAdvanceInAccess(self, operation_no):
     109        adv_index = self.advIndex[operation_no - self.operation_offset]
     110        return mkCall(self.carryGroupVar + "." + 'get_pending64', [ast.Num(adv_index)])
     111    def GenerateAdvanceOutStore(self, operation_no, adv_out_expr):
     112        adv_index = self.advIndex[operation_no - self.operation_offset]
     113        cq_index = adv_index + self.carry_count
     114        return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(cq_index)), ast.Store())], adv_out_expr)]
     115#                          mkCall("bitblock::srli<127>", [carry_out_expr]))]
    99116    def GenerateCarryIfTest(self, block_no, ifTest):
    100117        carry_count = self.carryInfoSet.block_op_count[block_no]
  • proto/Compiler/pablo.py

    r2693 r2697  
    3030  return ast.Attribute(ast.Name(obj, ast.Load()), field, ast.Load())
    3131
    32 #
    33 # Helpers
    3432def mkCall(fn_name, args):
    3533  if isinstance(fn_name, str):
     34        if name_substitution_map.has_key(fn_name): fn_name = name_substitution_map[fn_name]
    3635        fn_name = ast.Name(fn_name, ast.Load())
    3736  return ast.Call(fn_name, args, [], None, None)
     
    4140  return ast.Expr(ast.Call(fn_name, args, [], None, None))
    4241 
    43 
     42 
    4443
    4544#
     
    531530            self.current_carry += 1
    532531            return compiled
     532    elif isAdvance(f):
     533            if self.carryin == "_ci":
     534                carry_in_expr = self.ccgo.GenerateAdvanceInAccess(self.operation_count)
     535            else:
     536                carry_in_expr = mkCall('simd<1>::constant<0>', [])
     537            callnode = assigNode.value
     538            pablo_routine_call = mkCall('pablo_blk_Advance<%i>' %  assigNode.value.args[1].n, [assigNode.value.args[0], carry_in_expr, assigNode.targets[0]])
     539            self.last_stmt = pablo_routine_call
     540            compiled = self.ccgo.GenerateAdvanceOutStore(self.operation_count, pablo_routine_call)
     541            self.operation_count += 1
     542            self.current_adv_n += 1
     543            return compiled
     544
    533545    else:
    534546            self.generic_visit(assigNode)
Note: See TracChangeset for help on using the changeset viewer.