42a43
> import random
47a49,56
> # This example script stress tests the memory system by creating false
> # sharing in a tree topology. At the bottom of the tree is a shared
> # memory, and then at each level a number of testers are attached,
> # along with a number of caches that them selves fan out to subtrees
> # of testers and caches. Thus, it is possible to create a system with
> # arbitrarily deep cache hierarchies, sharing or no sharing of caches,
> # and testers not only at the L1s, but also at the L2s, L3s etc.
>
60,67d68
< # This example script stress tests the memory system by creating false
< # sharing in a tree topology. At the bottom of the tree is a shared
< # memory, and then at each level a number of testers are attached,
< # along with a number of caches that them selves fan out to subtrees
< # of testers and caches. Thus, it is possible to create a system with
< # arbitrarily deep cache hierarchies, sharing or no sharing of caches,
< # and testers not only at the L1s, but also at the L2s, L3s etc.
< #
95,96c96,98
<
< parser.add_option("--progress", type="int", default=10000,
---
> parser.add_option("-r", "--random", action="store_true",
> help="Generate a random tree topology")
> parser.add_option("--progress", type="int", default=100000,
110a113,126
> # Get the total number of testers
> def numtesters(cachespec, testerspec):
> # Determine the tester multiplier for each level as the
> # elements are per subsystem and it fans out
> multiplier = [1]
> for c in cachespec:
> multiplier.append(multiplier[-1] * c)
>
> total = 0
> for t, m in zip(testerspec, multiplier):
> total += t * m
>
> return total
>
115,120c131,138
< try:
< cachespec = [int(x) for x in options.caches.split(':')]
< testerspec = [int(x) for x in options.testers.split(':')]
< except:
< print "Error: Unable to parse caches or testers option"
< sys.exit(1)
---
> if options.random:
> # Generate a tree with a valid number of testers
> while True:
> tree_depth = random.randint(1, 4)
> cachespec = [random.randint(1, 3) for i in range(tree_depth)]
> testerspec = [random.randint(1, 3) for i in range(tree_depth + 1)]
> if numtesters(cachespec, testerspec) < block_size:
> break
122,124c140,148
< if len(cachespec) < 1:
< print "Error: Must have at least one level of caches"
< sys.exit(1)
---
> print "Generated random tree -c", ':'.join(map(str, cachespec)), \
> "-t", ':'.join(map(str, testerspec))
> else:
> try:
> cachespec = [int(x) for x in options.caches.split(':')]
> testerspec = [int(x) for x in options.testers.split(':')]
> except:
> print "Error: Unable to parse caches or testers option"
> sys.exit(1)
126,128c150,152
< if len(cachespec) != len(testerspec) - 1:
< print "Error: Testers must have one element more than caches"
< sys.exit(1)
---
> if len(cachespec) < 1:
> print "Error: Must have at least one level of caches"
> sys.exit(1)
130,136c154,155
< if testerspec[-1] == 0:
< print "Error: Must have testers at the uppermost level"
< sys.exit(1)
<
< for t in testerspec:
< if t < 0:
< print "Error: Cannot have a negative number of testers"
---
> if len(cachespec) != len(testerspec) - 1:
> print "Error: Testers must have one element more than caches"
139,141c158,159
< for c in cachespec:
< if c < 1:
< print "Error: Must have 1 or more caches at each level"
---
> if testerspec[-1] == 0:
> print "Error: Must have testers at the uppermost level"
144,150c162,165
< # Determine the tester multiplier for each level as the string
< # elements are per subsystem and it fans out
< multiplier = [1]
< for c in cachespec:
< if c < 1:
< print "Error: Must have at least one cache per level"
< multiplier.append(multiplier[-1] * c)
---
> for t in testerspec:
> if t < 0:
> print "Error: Cannot have a negative number of testers"
> sys.exit(1)
152,154c167,170
< numtesters = 0
< for t, m in zip(testerspec, multiplier):
< numtesters += t * m
---
> for c in cachespec:
> if c < 1:
> print "Error: Must have 1 or more caches at each level"
> sys.exit(1)
156,159c172,175
< if numtesters > block_size:
< print "Error: Number of testers limited to %s because of false sharing" \
< % (block_size)
< sys.exit(1)
---
> if numtesters(cachespec, testerspec) > block_size:
> print "Error: Limited to %s testers because of false sharing" \
> % (block_size)
> sys.exit(1)
226c242
< limit = (len(cachespec) - level + 1) * 10000000
---
> limit = (len(cachespec) - level + 1) * 100000000