-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_config.py
More file actions
executable file
·32 lines (24 loc) · 912 Bytes
/
fix_config.py
File metadata and controls
executable file
·32 lines (24 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3.11
import math
import json
import argparse
import pathlib
def amdahl_law(exec_time, nproc, amdahl_p):
h = round(exec_time * ((1-amdahl_p) + amdahl_p / nproc), 2)
h_ceil = math.ceil(h)
return h_ceil
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('input_dir', type=pathlib.Path, help='instances directory')
args = parser.parse_args();
for input in args.input_dir.glob('**/*.json'):
with open(input, 'r') as f:
j = json.load(f)
alpha = j['instance']['alpha'] / 100
for task in j['instance']['tasks']:
effort = task['effort']
for config in task['configs']:
width = config['width']
config['height'] = amdahl_law(effort, width, alpha)
with open(input, 'w') as f:
json.dump(j, f, indent=4)