memtest.py (10720:67b3e74de9ae) | memtest.py (10750:30efc3828bb4) |
---|---|
1# Copyright (c) 2015 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 26 unchanged lines hidden (view full) --- 35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39# Authors: Ron Dreslinski 40# Andreas Hansson 41 42import optparse | 1# Copyright (c) 2015 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 26 unchanged lines hidden (view full) --- 35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39# Authors: Ron Dreslinski 40# Andreas Hansson 41 42import optparse |
43import random |
|
43import sys 44 45import m5 46from m5.objects import * 47 | 44import sys 45 46import m5 47from m5.objects import * 48 |
49# This example script stress tests the memory system by creating false 50# sharing in a tree topology. At the bottom of the tree is a shared 51# memory, and then at each level a number of testers are attached, 52# along with a number of caches that them selves fan out to subtrees 53# of testers and caches. Thus, it is possible to create a system with 54# arbitrarily deep cache hierarchies, sharing or no sharing of caches, 55# and testers not only at the L1s, but also at the L2s, L3s etc. 56 |
|
48parser = optparse.OptionParser() 49 50parser.add_option("-a", "--atomic", action="store_true", 51 help="Use atomic (non-timing) mode") 52parser.add_option("-b", "--blocking", action="store_true", 53 help="Use blocking caches") 54parser.add_option("-l", "--maxloads", metavar="N", default=0, 55 help="Stop after N loads") 56parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick, 57 metavar="T", 58 help="Stop after T ticks") 59 | 57parser = optparse.OptionParser() 58 59parser.add_option("-a", "--atomic", action="store_true", 60 help="Use atomic (non-timing) mode") 61parser.add_option("-b", "--blocking", action="store_true", 62 help="Use blocking caches") 63parser.add_option("-l", "--maxloads", metavar="N", default=0, 64 help="Stop after N loads") 65parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick, 66 metavar="T", 67 help="Stop after T ticks") 68 |
60# This example script stress tests the memory system by creating false 61# sharing in a tree topology. At the bottom of the tree is a shared 62# memory, and then at each level a number of testers are attached, 63# along with a number of caches that them selves fan out to subtrees 64# of testers and caches. Thus, it is possible to create a system with 65# arbitrarily deep cache hierarchies, sharing or no sharing of caches, 66# and testers not only at the L1s, but also at the L2s, L3s etc. 67# | |
68# The tree specification consists of two colon-separated lists of one 69# or more integers, one for the caches, and one for the testers. The 70# first integer is the number of caches/testers closest to main 71# memory. Each cache then fans out to a subtree. The last integer in 72# the list is the number of caches/testers associated with the 73# uppermost level of memory. The other integers (if any) specify the 74# number of caches/testers connected at each level of the crossbar 75# hierarchy. The tester string should have one element more than the --- 11 unchanged lines hidden (view full) --- 87parser.add_option("-f", "--functional", type="int", default=0, 88 metavar="PCT", 89 help="Target percentage of functional accesses " 90 "[default: %default]") 91parser.add_option("-u", "--uncacheable", type="int", default=0, 92 metavar="PCT", 93 help="Target percentage of uncacheable accesses " 94 "[default: %default]") | 69# The tree specification consists of two colon-separated lists of one 70# or more integers, one for the caches, and one for the testers. The 71# first integer is the number of caches/testers closest to main 72# memory. Each cache then fans out to a subtree. The last integer in 73# the list is the number of caches/testers associated with the 74# uppermost level of memory. The other integers (if any) specify the 75# number of caches/testers connected at each level of the crossbar 76# hierarchy. The tester string should have one element more than the --- 11 unchanged lines hidden (view full) --- 88parser.add_option("-f", "--functional", type="int", default=0, 89 metavar="PCT", 90 help="Target percentage of functional accesses " 91 "[default: %default]") 92parser.add_option("-u", "--uncacheable", type="int", default=0, 93 metavar="PCT", 94 help="Target percentage of uncacheable accesses " 95 "[default: %default]") |
95 96parser.add_option("--progress", type="int", default=10000, | 96parser.add_option("-r", "--random", action="store_true", 97 help="Generate a random tree topology") 98parser.add_option("--progress", type="int", default=100000, |
97 metavar="NLOADS", 98 help="Progress message interval " 99 "[default: %default]") 100parser.add_option("--sys-clock", action="store", type="string", 101 default='1GHz', 102 help = """Top-level clock for blocks running at system 103 speed""") 104 105(options, args) = parser.parse_args() 106 107if args: 108 print "Error: script doesn't take any positional arguments" 109 sys.exit(1) 110 | 99 metavar="NLOADS", 100 help="Progress message interval " 101 "[default: %default]") 102parser.add_option("--sys-clock", action="store", type="string", 103 default='1GHz', 104 help = """Top-level clock for blocks running at system 105 speed""") 106 107(options, args) = parser.parse_args() 108 109if args: 110 print "Error: script doesn't take any positional arguments" 111 sys.exit(1) 112 |
113# Get the total number of testers 114def numtesters(cachespec, testerspec): 115 # Determine the tester multiplier for each level as the 116 # elements are per subsystem and it fans out 117 multiplier = [1] 118 for c in cachespec: 119 multiplier.append(multiplier[-1] * c) 120 121 total = 0 122 for t, m in zip(testerspec, multiplier): 123 total += t * m 124 125 return total 126 |
|
111block_size = 64 112 113# Start by parsing the command line options and do some basic sanity 114# checking | 127block_size = 64 128 129# Start by parsing the command line options and do some basic sanity 130# checking |
115try: 116 cachespec = [int(x) for x in options.caches.split(':')] 117 testerspec = [int(x) for x in options.testers.split(':')] 118except: 119 print "Error: Unable to parse caches or testers option" 120 sys.exit(1) | 131if options.random: 132 # Generate a tree with a valid number of testers 133 while True: 134 tree_depth = random.randint(1, 4) 135 cachespec = [random.randint(1, 3) for i in range(tree_depth)] 136 testerspec = [random.randint(1, 3) for i in range(tree_depth + 1)] 137 if numtesters(cachespec, testerspec) < block_size: 138 break |
121 | 139 |
122if len(cachespec) < 1: 123 print "Error: Must have at least one level of caches" 124 sys.exit(1) | 140 print "Generated random tree -c", ':'.join(map(str, cachespec)), \ 141 "-t", ':'.join(map(str, testerspec)) 142else: 143 try: 144 cachespec = [int(x) for x in options.caches.split(':')] 145 testerspec = [int(x) for x in options.testers.split(':')] 146 except: 147 print "Error: Unable to parse caches or testers option" 148 sys.exit(1) |
125 | 149 |
126if len(cachespec) != len(testerspec) - 1: 127 print "Error: Testers must have one element more than caches" 128 sys.exit(1) | 150 if len(cachespec) < 1: 151 print "Error: Must have at least one level of caches" 152 sys.exit(1) |
129 | 153 |
130if testerspec[-1] == 0: 131 print "Error: Must have testers at the uppermost level" 132 sys.exit(1) 133 134for t in testerspec: 135 if t < 0: 136 print "Error: Cannot have a negative number of testers" | 154 if len(cachespec) != len(testerspec) - 1: 155 print "Error: Testers must have one element more than caches" |
137 sys.exit(1) 138 | 156 sys.exit(1) 157 |
139for c in cachespec: 140 if c < 1: 141 print "Error: Must have 1 or more caches at each level" | 158 if testerspec[-1] == 0: 159 print "Error: Must have testers at the uppermost level" |
142 sys.exit(1) 143 | 160 sys.exit(1) 161 |
144# Determine the tester multiplier for each level as the string 145# elements are per subsystem and it fans out 146multiplier = [1] 147for c in cachespec: 148 if c < 1: 149 print "Error: Must have at least one cache per level" 150 multiplier.append(multiplier[-1] * c) | 162 for t in testerspec: 163 if t < 0: 164 print "Error: Cannot have a negative number of testers" 165 sys.exit(1) |
151 | 166 |
152numtesters = 0 153for t, m in zip(testerspec, multiplier): 154 numtesters += t * m | 167 for c in cachespec: 168 if c < 1: 169 print "Error: Must have 1 or more caches at each level" 170 sys.exit(1) |
155 | 171 |
156if numtesters > block_size: 157 print "Error: Number of testers limited to %s because of false sharing" \ 158 % (block_size) 159 sys.exit(1) | 172 if numtesters(cachespec, testerspec) > block_size: 173 print "Error: Limited to %s testers because of false sharing" \ 174 % (block_size) 175 sys.exit(1) |
160 161# Define a prototype L1 cache that we scale for all successive levels 162proto_l1 = BaseCache(size = '32kB', assoc = 4, 163 hit_latency = 1, response_latency = 1, 164 tgts_per_mshr = 8, is_top_level = True) 165 166if options.blocking: 167 proto_l1.mshrs = 1 --- 50 unchanged lines hidden (view full) --- 218 # The levels are indexing backwards through the list 219 ntesters = testerspec[len(cachespec) - level] 220 221 # Scale the progress threshold as testers higher up in the tree 222 # (smaller level) get a smaller portion of the overall bandwidth, 223 # and also make the interval of packet injection longer for the 224 # testers closer to the memory (larger level) to prevent them 225 # hogging all the bandwidth | 176 177# Define a prototype L1 cache that we scale for all successive levels 178proto_l1 = BaseCache(size = '32kB', assoc = 4, 179 hit_latency = 1, response_latency = 1, 180 tgts_per_mshr = 8, is_top_level = True) 181 182if options.blocking: 183 proto_l1.mshrs = 1 --- 50 unchanged lines hidden (view full) --- 234 # The levels are indexing backwards through the list 235 ntesters = testerspec[len(cachespec) - level] 236 237 # Scale the progress threshold as testers higher up in the tree 238 # (smaller level) get a smaller portion of the overall bandwidth, 239 # and also make the interval of packet injection longer for the 240 # testers closer to the memory (larger level) to prevent them 241 # hogging all the bandwidth |
226 limit = (len(cachespec) - level + 1) * 10000000 | 242 limit = (len(cachespec) - level + 1) * 100000000 |
227 testers = [proto_tester(interval = 10 * (level * level + 1), 228 progress_check = limit) \ 229 for i in xrange(ntesters)] 230 if ntesters: 231 subsys.tester = testers 232 233 if level != 0: 234 # Create a crossbar and add it to the subsystem, note that --- 59 unchanged lines hidden --- | 243 testers = [proto_tester(interval = 10 * (level * level + 1), 244 progress_check = limit) \ 245 for i in xrange(ntesters)] 246 if ntesters: 247 subsys.tester = testers 248 249 if level != 0: 250 # Create a crossbar and add it to the subsystem, note that --- 59 unchanged lines hidden --- |