def opTable(stage, lut): reportdir = os.path.join(config.outputDirectory, 'stats', stage) ensureDirectoryExists(reportdir) total = collections.defaultdict(lambda: 0) for shader, opLUT in lut.iteritems(): for op, count in opLUT.opCount.iteritems(): total[op] += count if False: opNames = [] for op in asts: if total[op] > 0: opNames.append(op) else: opNames = ['DirectCall', 'Load', 'ILoad', 'Store', 'IStore', 'Allocate'] builder = TableBuilder(*opNames) builder.setFormats(*(['%d']*len(opNames))) for shader in shaderNames: opLUT = lut[shader] builder.row(shader, *[opLUT.opCount[name] for name in opNames]) builder.row('total', *[total[name] for name in opNames]) f = open(os.path.join(reportdir, 'shader-ops.tex'), 'w') builder.dumpLatex(f, "%s-shader-ops" % stage) f.close()
def makeReportDirectory(moduleName): reportdir = os.path.join(config.outputDirectory, moduleName) ensureDirectoryExists(reportdir) return reportdir
def contextStats(compiler, prgm, name, classOK=False): if not config.dumpStats: return optimization.cullprogram.evaluate(compiler, prgm) reportdir = os.path.join(config.outputDirectory, 'stats', name) ensureDirectoryExists(reportdir) liveCode = prgm.liveCode collect = StatCollector() collect.name = name collect.reportdir = reportdir for code in liveCode: if not code.isStandardCode(): continue cls = classifyCode(code) collect.code(cls, code) if False: print code print cls, len(code.annotation.contexts) print code.annotation.origin print ops, lcls, copies = astcollector.getAll(code) for op in ops: collect.op(cls, code, op) collect.copies(cls, code, len(copies)) # Histogram if False: for count in sorted(collect.counts.iterkeys()): print count for cls, num in collect.counts[count].iteritems(): print '\t', cls, num print tw = collections.defaultdict(lambda: 0) tc = collections.defaultdict(lambda: 0) for xtype, count in collect.access.iteritems(): tw[xtype.obj.pythonType()] += count tc[xtype.obj.pythonType()] += 1 paw = 0 tow = 0 otc = 0 for t, count in collect.taccess.iteritems(): rel = tw[t]/float(tc[t]) print t, count, rel paw += rel tow += count otc += 1 tapo = float(tow)/otc papo = paw/otc print print tapo, papo, papo/tapo print functionRatios(collect, classOK) opRatios(collect, classOK) if prgm.stats: opsRemoved(collect, prgm.stats) if False: for cls, lut in collect.opCount.iteritems(): print cls for opT, num in lut.iteritems(): print '\t', opT, num print print opPieChart(collect) print "vparams" print collect.vparamCount, collect.contextVparamCount print print "vargs" print collect.vargCount, collect.contextVargCount print generateIndex(collect) prgm.stats = collect return collect
def contextStats(compiler, prgm, name, classOK=False): if not config.dumpStats: return optimization.cullprogram.evaluate(compiler, prgm) reportdir = os.path.join(config.outputDirectory, 'stats', name) ensureDirectoryExists(reportdir) liveCode = prgm.liveCode collect = StatCollector() collect.name = name collect.reportdir = reportdir for code in liveCode: if not code.isStandardCode(): continue cls = classifyCode(code) collect.code(cls, code) if False: print code print cls, len(code.annotation.contexts) print code.annotation.origin print ops, lcls, copies = astcollector.getAll(code) for op in ops: collect.op(cls, code, op) collect.copies(cls, code, len(copies)) # Histogram if False: for count in sorted(collect.counts.iterkeys()): print count for cls, num in collect.counts[count].iteritems(): print '\t', cls, num print tw = collections.defaultdict(lambda: 0) tc = collections.defaultdict(lambda: 0) for xtype, count in collect.access.iteritems(): tw[xtype.obj.pythonType()] += count tc[xtype.obj.pythonType()] += 1 paw = 0 tow = 0 otc = 0 for t, count in collect.taccess.iteritems(): rel = tw[t] / float(tc[t]) print t, count, rel paw += rel tow += count otc += 1 tapo = float(tow) / otc papo = paw / otc print print tapo, papo, papo / tapo print functionRatios(collect, classOK) opRatios(collect, classOK) if prgm.stats: opsRemoved(collect, prgm.stats) if False: for cls, lut in collect.opCount.iteritems(): print cls for opT, num in lut.iteritems(): print '\t', opT, num print print opPieChart(collect) print "vparams" print collect.vparamCount, collect.contextVparamCount print print "vargs" print collect.vargCount, collect.contextVargCount print generateIndex(collect) prgm.stats = collect return collect
def __init__(self, directory): self.directory = directory self.urls = {} self.uid = 0 ensureDirectoryExists(directory)