Ignore:
Timestamp:
Dec 1, 2012, 7:37:30 AM (7 years ago)
Author:
cameron
Message:

New experimental version eliminating ubitblock and convert; much faster

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/CCGO_HMCPS.py

    r2707 r2708  
    369369        count = self.aligned_size[block_no]
    370370        width = count * self.fw
    371         if width <= 64:
     371        if count < self.field_count:
    372372            t = self.carry_pack_index(width, ub, rp/count)
    373373            return TestHelper_Integer_Or(testExpr, t)
     
    452452        return []
    453453
     454#
     455#  A version of HMCPS_CCGO eliminating ubitblocks
     456#
     457class HMCPS_CCGO2(HMCPS_CCGO):
     458
     459    def carry_pack_full(self, ub, mode = ast.Load()):
     460       return make_index(self.carryGroupVar, ub, mode)
     461
     462    def carry_pack_index(self, fw, ub, rp, mode = ast.Load()):
     463       return make_call("mvmd<%i>::extract<%i>" % (fw, rp), [self.carry_pack_full(ub)])
     464
     465    def local_pack_full(self, ub, mode = ast.Load()):
     466       return make_index("sub" + self.carryGroupVar, ub, mode)
     467
     468    def GenerateCarryDecls(self):
     469        return "  BitBlock simd_const_1\n;    BitBlock %s [%i];\n" % (self.carryGroupVar, self.ubitblock_count)
     470
     471    def GenerateInitializations(self):
     472        v = self.carryGroupVar       
     473        inits = "simd_const_1 = mvmd<16>::srli<7>(simd<16>::constant<1>());\n"
     474        for i in range(0, self.ubitblock_count):
     475          inits += "%s[%i] = simd<%i>::constant<0>();\n" % (v, i, self.fw)
     476        for op_no in range(self.carryInfoSet.block_op_count[0]):
     477          if op_no in self.carryInfoSet.init_one_list:
     478            posn = self.alloc_map[op_no]
     479            ub = posn/self.field_count
     480            rp = posn%self.field_count
     481            v = "%s[%i]" % (self.carryGroupVar, ub)
     482            inits += "%s = simd_or(%s, mvmd<%i>::slli<%i>(simd_const_1)) ;\n" % (v, v, self.fw, rp)
     483        return inits
     484
     485    def GenerateCarryInAccess(self, operation_no):
     486        block_no = self.carryInfoSet.containing_block[operation_no]
     487        posn = self.alloc_map[operation_no] - self.carry_offset
     488        ub = posn/self.field_count
     489        rp = posn%self.field_count
     490        #return make_call("convert", [self.carry_pack_index(self.fw, ub, rp)])
     491        return make_call('simd_and', [make_call("mvmd<%i>::srli<%i>" %(self.fw, rp), [self.carry_pack_full(ub)]), mk_var("simd_const_1")])
     492
     493    def GenerateLocalDeclare(self, block_no):
     494        if self.carryInfoSet.block_op_count[block_no] == 0: return []
     495        count = self.aligned_size[block_no]
     496        if count >= self.field_count:
     497          ub_count = count / self.field_count
     498          decls = [make_callStmt('BitBlock_declare', [self.local_pack_full(ub_count)])]
     499          decls += [make_assign(self.local_pack_full(i, ast.Store()), make_zero(self.fw)) for i in range(ub_count)]
     500          count = self.field_count
     501        else: decls = []
     502        # Generate carry pack temps.
     503        f = count
     504        s = 1
     505        temps = []
     506        while f > 0:
     507          temps += [self.local_temp(s*(i+1)-1, s*i) for i in range(f)]
     508          f = f/2
     509          s = s * 2
     510        #return BitBlock_decls_from_vars(decls)
     511        return decls + [make_callStmt('BitBlock_declare', [mk_var(t)]) for t in temps]
     512   
     513
Note: See TracChangeset for help on using the changeset viewer.