def getChoiceSites(tx): getSiteRe = re.compile( re.escape(nameof(tx)) + "_([0-9]*)_lvl[0-9]*_.*" ) getSite=lambda t: int(getSiteRe.match(nameof(t)).group(1)) #it would be nice to export this data, for now parse it from tunable names sites=[] sites.extend(map(getSite, getTunables(tx,"algchoice.cutoff"))) sites.extend(map(getSite, getTunables(tx,"algchoice.alg"))) return list(set(sites))
def printTx(tx, depth, loops): t = len(getTunables(tx, "system.cutoff.splitsize")) cs = len(getChoiceSites(tx)) if loops == 0: t += len(getTunables(tx, "system.cutoff.sequential")) print ''.ljust( 2 * depth) + ' - ' + nameof(tx) + " (%d choice site, %d cutoffs)" % (cs, t)
def getChoiceSites(tx): getSiteRe = re.compile(re.escape(nameof(tx)) + "_([0-9]*)_lvl[0-9]*_.*") getSite = lambda t: int(getSiteRe.match(nameof(t)).group(1)) #it would be nice to export this data, for now parse it from tunable names sites = [] sites.extend(map(getSite, getTunables(tx, "algchoice.cutoff"))) sites.extend(map(getSite, getTunables(tx, "algchoice.alg"))) return list(set(sites))
def getChoiceSiteWeight(tx, site, cutoffs): getSiteRe = re.compile(re.escape(nameof(tx)) + "_([0-9]*)_lvl[0-9]*_.*") getSite = lambda t: int(getSiteRe.match(nameof(t)).group(1)) tunables = filter(lambda x: getSite(x) == site, getTunables(tx, "algchoice.alg")) algcounts = map( lambda x: int(x.getAttribute("max")) - int(x.getAttribute("min")), tunables) return reduce(max, algcounts, 1) + len(cutoffs)
def printTx(tx, depth, loops): t = len(getTunables(tx, "system.cutoff.splitsize")) cs = len(getChoiceSites(tx)) if loops == 0: t+=len(getTunables(tx, "system.cutoff.sequential")) print ''.ljust(2*depth) + ' - ' + nameof(tx) + " (%d choice site, %d cutoffs)"%(cs,t)
def getChoiceSiteWeight(tx, site, cutoffs): getSiteRe = re.compile( re.escape(nameof(tx)) + "_([0-9]*)_lvl[0-9]*_.*" ) getSite=lambda t: int(getSiteRe.match(nameof(t)).group(1)) tunables=filter(lambda x: getSite(x)==site, getTunables(tx,"algchoice.alg")) algcounts=map(lambda x: int(x.getAttribute("max"))-int(x.getAttribute("min")),tunables) return reduce(max, algcounts, 1)+len(cutoffs)