Changes in benchmark/rmit.py [83b22b53:6f27b67]
- File:
-
- 1 edited
-
benchmark/rmit.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/rmit.py
r83b22b53 r6f27b67 16 16 import random 17 17 import re 18 import socket19 18 import subprocess 20 19 import sys … … 96 95 return nopts 97 96 98 # returns the first option with key 'opt'99 def search_option(action, opt):100 i = 0101 while i < len(action):102 if action[i] == opt:103 i += 1104 if i != len(action):105 return action[i]106 i += 1107 108 return None109 110 97 def actions_eta(actions): 111 98 time = 0 112 99 for a in actions: 113 o = search_option(a, '-d') 114 if o : 115 time += int(o) 100 i = 0 101 while i < len(a): 102 if a[i] == '-d': 103 i += 1 104 if i != len(a): 105 time += int(a[i]) 106 i += 1 116 107 return time 117 118 taskset_maps = None119 120 def init_taskset_maps():121 global taskset_maps122 known_hosts = {123 "jax": {124 range( 1, 24) : "48-71",125 range( 25, 48) : "48-71,144-167",126 range( 49, 96) : "48-95,144-191",127 range( 97, 144) : "24-95,120-191",128 range(145, 192) : "0-95,96-191",129 },130 }131 132 if (host := socket.gethostname()) in known_hosts:133 taskset_maps = known_hosts[host]134 return True135 136 print("Warning unknown host '{}', disable taskset usage".format(host), file=sys.stderr)137 return False138 139 140 def settaskset_one(action):141 o = search_option(action, '-p')142 if not o:143 return action144 try:145 oi = int(o)146 except ValueError:147 return action148 149 m = "Not found"150 for key in taskset_maps:151 if oi in key:152 return ['taskset', '-c', taskset_maps[key], *action]153 154 print("Warning no mapping for {} cores".format(oi), file=sys.stderr)155 return action156 157 def settaskset(actions):158 return [settaskset_one(a) for a in actions]159 108 160 109 if __name__ == "__main__": … … 166 115 parser.add_argument('--file', nargs='?', type=argparse.FileType('w'), default=sys.stdout) 167 116 parser.add_argument('--trials', help='Number of trials to run per combinaison', type=int, default=3) 168 parser.add_argument('--notaskset', help='If specified, the trial will not use taskset to match the -p option', action='store_true')169 117 parser.add_argument('command', metavar='command', type=str, nargs=1, help='the command prefix to run') 170 118 parser.add_argument('candidates', metavar='candidates', type=str, nargs='*', help='the candidate suffix to run') … … 222 170 223 171 # ================================================================================ 224 # Fixup the different commands 225 226 # Add tasksets 227 withtaskset = False 228 if not options.notaskset and init_taskset_maps(): 229 withtaskset = True 230 actions = settaskset(actions) 231 232 # ================================================================================ 233 # Now that we know what to run, print it. 234 # find expected time 235 time = actions_eta(actions) 236 print("Running {} trials{}".format(len(actions), "" if time == 0 else " (expecting to take {})".format(str(datetime.timedelta(seconds=int(time)))) )) 237 238 # dry run if options ask for it 172 # Figure out all the combinations to run 239 173 if options.list: 240 174 for a in actions: … … 246 180 # Prepare to run 247 181 182 # find expected time 183 time = actions_eta(actions) 184 print("Running {} trials{}".format(len(actions), "" if time == 0 else " (expecting to take {})".format(str(datetime.timedelta(seconds=int(time)))) )) 185 248 186 random.shuffle(actions) 249 187 … … 253 191 first = True 254 192 for i, a in enumerate(actions): 255 sa = " ".join(a [3:] if withtaskset else a)193 sa = " ".join(a) 256 194 if first: 257 195 first = False … … 270 208 match = re.search("^(.*):(.*)$", s) 271 209 if match: 272 try: 273 fields[match.group(1).strip()] = float(match.group(2).strip().replace(',','')) 274 except: 275 pass 276 277 options.file.write(json.dumps([a[3 if withtaskset else 0][2:], sa, fields])) 210 fields[match.group(1).strip()] = float(match.group(2).strip().replace(',','')) 211 212 options.file.write(json.dumps([a[0][2:], sa, fields])) 278 213 options.file.flush() 279 214
Note:
See TracChangeset
for help on using the changeset viewer.