Changeset 2799


Ignore:
Timestamp:
Dec 27, 2012, 7:07:56 AM (6 years ago)
Author:
cameron
Message:

Separate allocation from init, add BLOCK_SIZE parameter, tidy

Location:
proto/Compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/CCGO.py

    r2786 r2799  
    2323class CCGO:
    2424    def __init__(self): pass
     25    def allocate_all(self): pass
    2526    def GenerateCarryDecls(self): return ""
    2627    def GenerateInitializations(self): return ""
     
    5859#
    5960class testCCGO(CCGO):
    60     def __init__(self, carryInfoSet, carryGroupVarName='carryQ'):
     61    def __init__(self, BLOCK_SIZE, carryInfoSet, carryGroupVarName='carryQ'):
     62        self.BLOCK_SIZE = BLOCK_SIZE
    6163        self.carryInfoSet = carryInfoSet
    6264        self.carryGroupVar = carryGroupVarName
     65
     66    def allocate_all(self):
    6367        self.carryIndex = {}
    6468        self.advIndex = {}
     
    6670        carry_counter = 0
    6771        adv_counter = 0
    68         for op_no in range(carryInfoSet.operation_count):
     72        for op_no in range(self.carryInfoSet.operation_count):
    6973          self.carryIndex[op_no] = carry_counter
    70           if not op_no in carryInfoSet.advance_amount.keys(): carry_counter += 1
    71           elif carryInfoSet.advance_amount[op_no] == 1: carry_counter += 1
     74          if not op_no in self.carryInfoSet.advance_amount.keys(): carry_counter += 1
     75          elif self.carryInfoSet.advance_amount[op_no] == 1: carry_counter += 1
    7276          else: 
    7377            self.advIndex[op_no] = adv_counter
    7478            adv_counter += 1
    7579        # Add a dummy entry for any possible final block that is empty.
    76         self.carryIndex[carryInfoSet.operation_count] = carry_counter
    77         self.advIndex[carryInfoSet.operation_count] = adv_counter
     80        self.carryIndex[self.carryInfoSet.operation_count] = carry_counter
     81        self.advIndex[self.carryInfoSet.operation_count] = adv_counter
    7882        self.carry_count = carry_counter
     83
    7984    # Helper
    8085    def CarryGroupAtt(self, attname, CarryGroupVarName=""):
     
    106111        carry_index = self.carryIndex[operation_no - self.operation_offset]
    107112        return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(carry_index)), ast.Store())],
    108                           mkCall("bitblock::srli<127>", [carry_out_expr]))]
     113                          mkCall("bitblock::srli<%i>" % (self.BLOCK_SIZE - 1), [carry_out_expr]))]
    109114    def GenerateAdvanceInAccess(self, operation_no):
    110115        adv_index = self.advIndex[operation_no - self.operation_offset]
  • proto/Compiler/CCGO_HMCPS.py

    r2798 r2799  
    174174 
    175175class HMCPS_CCGO(CCGO.CCGO):
    176     def __init__(self, fw, carryInfoSet, carryPackVarName='carryG', temp_prefix='__c'):
     176    def __init__(self, BLOCK_SIZE, fw, carryInfoSet, carryPackVarName='carryG', temp_prefix='__c'):
     177        self.BLOCK_SIZE = BLOCK_SIZE
    177178        self.fw = fw
    178         self.field_count = 128/fw
     179        self.field_count = self.BLOCK_SIZE/fw
    179180        self.carryInfoSet = carryInfoSet
    180181        self.carryPackVar = carryPackVarName
    181182        self.temp_prefix = temp_prefix
    182         self.aligned_size = determine_aligned_block_sizes(self.field_count, carryInfoSet)
     183
     184    def allocate_all(self):
     185        self.aligned_size = determine_aligned_block_sizes(self.field_count, self.carryInfoSet)
    183186        self.carryPack_count = (self.aligned_size[0] + self.field_count - 1) / self.field_count
    184         self.totalPack_count = self.carryPack_count + carryInfoSet.adv_n_count
     187        self.totalPack_count = self.carryPack_count + self.carryInfoSet.adv_n_count
    185188        self.alloc_map = {}
    186189        self.alloc_map[0] = 0
     
    223226       return self.carry_pack_full(ub, "sub" + self.carryPackVar, mode)
    224227
    225 
     228    def local_pack_index(self, fw, ub, rp, mode = ast.Load()):
     229       v = "sub" + self.carryPackVar
     230       return make_index(make_att(make_index(v, ub), '_%i' % fw), rp, mode)
     231 
    226232
    227233    def cg_temp(self, hi_carry, lo_carry = None):
     
    277283      shift_result = self.cg_temp(carry_num + shift - 1, pending_carry_base)
    278284      pending = self.cg_temp(carry_num - 1, pending_carry_base)
    279       #print shift_result, " by shift ", pending, shift
    280       a1 = make_assign(shift_result, make_call('bitblock::srli<%i>' % (self.fw * shift), [mk_var(pending)]))
     285      #a1 = make_assign(shift_result, make_call('bitblock::srli<%i>' % (self.fw * shift), [mk_var(pending)]))
     286      a1 = make_assign(shift_result, make_call('mvmd<%i>::srli<%i>' % (self.fw, shift), [mk_var(pending)]))
    281287      # Do any necessary merges
    282288      m = self.gen_merges(carry_num + shift - 1,  pending_carry_base)
     
    367373        if skip > 0:
    368374          assigs += self.gen_multiple_carry_zero_then_pack(rp+1, skip)
    369         #print (posn, skip)
    370375        if next_posn % self.field_count == 0:
    371376          shift_op = "simd<%i>::srli<%i>" % (self.fw, self.fw-1)
     
    418423        next_op = self.carryInfoSet.block_first_op[block_no] + self.carryInfoSet.block_op_count[block_no]
    419424        end_pos = (self.alloc_map[next_op]  - self.carry_offset - 1) % self.field_count
    420         #print rp, next_op,self.alloc_map[next_op]
    421         #assigs = [make_assign(self.cg_temp(end_pos, rp), make_zero(self.fw))]
    422425        assigs = self.gen_multiple_carry_zero_then_pack(rp, end_pos - rp + 1)
    423426        if (end_pos + 1) % self.field_count == 0:
     
    453456        self.temp_prefix = "sub" + self.temp_prefix
    454457        self.carry_offset = self.alloc_map[operation_offset]
    455         #print "self.carry_offset = %i" % self.carry_offset
     458
    456459    def ExitLocalWhileBlock(self): 
    457460        self.carryPackVar = self.carryPackVar[3:]
  • proto/Compiler/pablo.py

    r2792 r2799  
    322322
    323323def Strategic_CCGO_Factory(carryInfoSet):
     324  BLOCK_SIZE = 128
    324325  if experimentalMode:
    325326    ops = carryInfoSet.operation_count
    326327    if ops == 0: ccgo = CCGO.CCGO()
    327     elif ops <= 2: ccgo = CCGO_HMCPS.HMCPS_CCGO2(64, carryInfoSet, 'carryG', '__c')
    328     elif ops <= 4: ccgo = CCGO_HMCPS.HMCPS_CCGO2(32, carryInfoSet, 'carryG', '__c')
    329     #elif ops <= 8: ccgo = CCGO_HMCPS.HMCPS_CCGO(16, carryInfoSet, 'carryG', '__c')
    330     #else: ccgo = CCGO_HMCPS.HMCPS_CCGO(8, carryInfoSet, 'carryG', '__c')
    331     else: ccgo = CCGO_HMCPS.HMCPS_CCGO2(16, carryInfoSet, 'carryG', '__c')
     328    elif ops <= 2: ccgo = CCGO_HMCPS.HMCPS_CCGO2(BLOCK_SIZE, 64, carryInfoSet, 'carryG', '__c')
     329    elif ops <= 4: ccgo = CCGO_HMCPS.HMCPS_CCGO2(BLOCK_SIZE, 32, carryInfoSet, 'carryG', '__c')
     330    #elif ops <= 8: ccgo = CCGO_HMCPS.HMCPS_CCGO(BLOCK_SIZE, 16, carryInfoSet, 'carryG', '__c')
     331    #else: ccgo = CCGO_HMCPS.HMCPS_CCGO(BLOCK_SIZE, 8, carryInfoSet, 'carryG', '__c')
     332    else: ccgo = CCGO_HMCPS.HMCPS_CCGO2(BLOCK_SIZE, 16, carryInfoSet, 'carryG', '__c')
    332333  else:
    333     ccgo = CCGO.testCCGO(carryInfoSet, 'carryQ')
     334    ccgo = CCGO.testCCGO(BLOCK_SIZE, carryInfoSet, 'carryQ')
     335  ccgo.allocate_all()
    334336  return ccgo
    335337
Note: See TracChangeset for help on using the changeset viewer.