Changeset f56101f
- Timestamp:
- May 3, 2022, 12:51:52 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 160ee4c
- Parents:
- ffc1689
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/rmit.py
rffc1689 rf56101f 63 63 return eval(fmt) 64 64 65 # Evaluate all the options 66 # options can be of the for key = val or key = some_math(other_key) 67 # produce a list of all the options to replace some_math(other_key) with actual value 65 68 def eval_options(opts): 69 # Find all the options with dependencies 66 70 dependents = [d for d in opts.values() if type(d) is DependentOpt] 71 72 # we need to find all the straglers 67 73 processed = [] 68 nopts = [] 74 75 # extract all the necessary inputs 76 input_keys = {} 69 77 for d in dependents: 78 # Mark the dependent as seen 70 79 processed.append(d.key) 71 lists = [] 80 81 # process each of the dependencies 72 82 for dvar in d.vars: 83 # Check that it depends on something that exists 73 84 if not dvar in opts.keys(): 74 85 print('ERROR: extra pattern option {}:{} uses unknown key {}'.format(d.key,d.value,dvar), file=sys.stderr) 75 86 sys.exit(1) 76 87 77 lists.append([(dvar, o) for o in opts[dvar]]) 88 # Check that it's not nested 89 if type(dvar) is DependentOpt: 90 print('ERROR: dependent options cannot be nested {}:{} uses key {}'.format(d.key,d.value,dvar), file=sys.stderr) 91 sys.exit(1) 92 93 # Add the values to the input keys 94 if dvar not in input_keys: 95 input_keys[dvar] = opts[dvar] 96 else : 97 if input_keys[dvar] != opts[dvar]: 98 print('INTERNAL ERROR: repeat input do not match {}:{} vs {}'.format(dvar,opts[dvar],input_keys[dvar]), file=sys.stderr) 99 sys.exit(1) 100 101 # Mark the input as seen 78 102 processed.append(dvar) 79 103 80 kopt = [] 81 for vals in list(itertools.product(*lists)): 82 res = ['-{}'.format(d.key), "{}".format(eval_one(d.value, vals))] 83 for k, v in vals: 84 res.extend(['-{}'.format(k), "{}".format(v)]) 85 kopt.append(res) 86 nopts.append(kopt) 87 88 89 for k, vals in opts.items(): 90 if k not in processed: 91 kopt = [] 92 for v in vals: 93 kopt.append(['-{}'.format(k), "{}".format(v)]) 94 nopts.append(kopt) 95 96 return nopts 104 # add in all the straglers they should cause too many problems 105 for k, v in opts.items(): 106 if type(v) is DependentOpt: 107 continue 108 109 if k in processed: 110 # consistency check 111 if k not in input_keys: 112 print('INTERNAL ERROR: key \'{}\' marked as processed but not in input_keys'.format(k), file=sys.stderr) 113 sys.exit(1) 114 continue 115 116 # consistency check 117 if k in input_keys: 118 print('INTERNAL ERROR: key \'{}\' in input_keys but not marked as processed'.format(k), file=sys.stderr) 119 sys.exit(1) 120 121 # add the straggler 122 input_keys[k] = v 123 124 # flatten the dict into a list of pairs so it's easier to work with 125 input_list = [] 126 for k, v in input_keys.items(): 127 input_list.append([(k, o) for o in v]) 128 129 # evaluate all the dependents 130 # they are not allowed to produce new values so it's a one-to-one mapping from here 131 evaluated = [] 132 for inputs in list(itertools.product(*input_list)): 133 this_eval = list(inputs) 134 for d in dependents: 135 this_eval.append((d.key, eval_one(d.value, inputs))) 136 137 evaluated.append(this_eval) 138 139 # reformat everything to a list of arguments 140 formated = [] 141 for o in evaluated: 142 inner = [] 143 for k,v in o: 144 inner.append("-{}".format(k)) 145 inner.append("{}".format(v)) 146 147 # print(inner) 148 formated.append(inner) 149 150 return formated 97 151 98 152 # returns the first option with key 'opt' … … 122 176 known_hosts = { 123 177 "jax": { 124 range( 1, 2 4) : "48-71",125 range( 25, 4 8) : "48-71,144-167",126 range( 49, 9 6) : "48-95,144-191",127 range( 97, 14 4) : "24-95,120-191",128 range(145, 19 2) : "0-95,96-191",178 range( 1, 25) : "48-71", 179 range( 25, 49) : "48-71,144-167", 180 range( 49, 97) : "48-95,144-191", 181 range( 97, 145) : "24-95,120-191", 182 range(145, 193) : "0-95,96-191", 129 183 }, 130 184 } … … 184 238 185 239 except: 186 print('ERROR: invalid arguments', file=sys.stderr)187 parser.print_help(sys.stderr)188 240 sys.exit(1) 189 241 … … 215 267 # Figure out all the combinations to run 216 268 actions = [] 217 for p in itertools.product(range(options.trials), commands, *opts):269 for p in itertools.product(range(options.trials), commands, opts): 218 270 act = [p[1]] 219 271 for o in p[2:]: … … 281 333 282 334 if options.file != sys.stdout: 283 print("Done ");")335 print("Done ")
Note: See TracChangeset
for help on using the changeset viewer.