def run(self, cmp_func, out_file=None): log = Logger(out_file) self.file = sys.stdout if not out_file else open(out_file, "w") blocks1 = cdump.load_blocks(self.dump1_fname) blocks2 = cdump.load_blocks(self.dump2_fname) found_opers = [] log.info(self.dump1_fname) log.info(self.dump2_fname) for b in blocks1: if b.type == cdump.Block.TYPE_TC: continue for oper in b.opers: if cmp_func(oper): found_opers.append(oper) miss_opers = OrderedDict() for p in found_opers: found = False for b in blocks2: if b.type == cdump.Block.TYPE_TC: continue for oper in b.opers: if oper.gva == p.gva: if not cmp_func(oper): # check we have oper with same gva already if any(pp.gva == p.gva for pp in miss_opers): continue if p not in miss_opers: miss_opers[p] = [] miss_opers[p].append(oper) else: miss_opers.pop(p, None) found = True break if found: break for k, v in miss_opers.items(): if not any(op.block.type != cdump.Block.TYPE_TC for op in v): continue log.info('-'*64) log.info(k) log.info(' in ', k.block) o2_match = [] for b in blocks1: if b.type != cdump.Block.TYPE_TC: continue for oper in b.opers: if oper.gva == k.gva: o2_match.append(oper) if len(o2_match) > 2: break if len(o2_match) > 2: break log.info(' First dump:') log.dump_opers(o2_match) log.info(' Second dump:') log.dump_opers(v) log.info('') print 'Miss opers count: ', len(miss_opers) del blocks1 del blocks2
def search(dump_file, func, block_type=cdump.Block.TYPE_ALL): bs = cdump.load_blocks(dump_file, block_type) res = [] for b in bs: for oper in b: if func(oper): res.append(oper) return res
def search_cross(dump_file, tc_func, jit_func): bs = cdump.load_blocks(dump_file) for b1 in bs: #if b1.type != cdump.Block.TYPE_TC: continue for oper1 in b1.opers: if tc_func(oper1): for b2 in bs: if b2.type == cdump.Block.TYPE_TC: continue for oper2 in b2: if oper1.gva == oper2.gva and jit_func(oper2): log.info('-'*32) log.dump_oper(oper1) log.dump_oper(oper2)
def analyze_big_blocks(): bl_cnt_total = 0 bbl_cnt_total = 0 bigs = [] for f in cdump.xsim_nightly_code_warmups(gear='O1', arch='aarch64'): print f blocks = cdump.load_blocks(f, cdump.Block.TYPE_O1) # gva = [b.gva for b in blocks if b.type == cdump.Block.TYPE_O1] # blocks = [b for b in blocks if b.gva in gva] bl_cnt = 0 bbl_cnt = 0 for b in blocks: if b.size() < 32: if b.size() > 1: bl_cnt += 1 continue bbs = [] cnt = 0 for oper in b: if not oper.inst.attr('A_BRANCH'): cnt += 1 continue bbs.append(cnt) cnt = 0 if any(b > 32 for b in bbs): print b, ' BB sizes:', ', '.join([str(b) for b in bbs]) bbl_cnt += 1 bigs.extend([b for b in bbs if b > 32]) bl_cnt += 1 print "Big/Total: %d/%d(%05.2f%%)"%(bbl_cnt, bl_cnt, 100 * float(bbl_cnt)/float(bl_cnt)) bl_cnt_total += bl_cnt bbl_cnt_total += bbl_cnt #break print '\n', "BIG/TOTAL: %d/%d(%05.2f%%)"%(bbl_cnt_total, bl_cnt_total, 100 * float(bbl_cnt_total)/float(bl_cnt_total)) print 'Mean big size value: %.2f'%(float(sum(bigs))/float(len(bigs)))