diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-11-26 16:02:48 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-11-26 16:02:48 -0500 |
commit | cb8db5d30ee769304c2c2b00f2a7d9bcb3c4098f (patch) | |
tree | c5352d84285af565d5246c3eb861ffba709761f1 /parse/ft.py | |
parent | 41c867480f1e20bd3b168258ed71450499ea6ccf (diff) |
Removed 2-step parse for scheduling statistics.
Diffstat (limited to 'parse/ft.py')
-rw-r--r-- | parse/ft.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/parse/ft.py b/parse/ft.py index c5f1522..fea246a 100644 --- a/parse/ft.py +++ b/parse/ft.py | |||
@@ -11,27 +11,8 @@ FT_SPLIT_NAME = "overhead={}.bin" | |||
11 | FT_SORTED_NAME = "sorted-ft.bin" | 11 | FT_SORTED_NAME = "sorted-ft.bin" |
12 | FT_ERR_NAME = "err-ft" | 12 | FT_ERR_NAME = "err-ft" |
13 | 13 | ||
14 | def extract_ft_data(result, data_dir, cycles, tmp_dir): | ||
15 | freg = conf.FILES['ft_data'] + "$" | ||
16 | bins = [f for f in os.listdir(data_dir) if re.match(freg, f)] | ||
17 | |||
18 | if not len(bins): | ||
19 | return False | ||
20 | |||
21 | bin_file = "{}/{}".format(data_dir, bins[0]) | ||
22 | |||
23 | with open("%s/%s" % (tmp_dir, FT_ERR_NAME), 'w') as err_file: | ||
24 | sorted_bin = sort_ft(bin_file, err_file, tmp_dir) | ||
25 | |||
26 | for event in conf.BASE_EVENTS: | ||
27 | parse_overhead(result, sorted_bin, event, cycles, | ||
28 | tmp_dir, err_file) | ||
29 | |||
30 | os.remove(sorted_bin) | ||
31 | |||
32 | return True | ||
33 | |||
34 | def parse_overhead(result, overhead_bin, overhead, cycles, out_dir, err_file): | 14 | def parse_overhead(result, overhead_bin, overhead, cycles, out_dir, err_file): |
15 | '''Store statistics for @overhead in @overhead_bin into @result.''' | ||
35 | ovh_fname = "{}/{}".format(out_dir, FT_SPLIT_NAME).format(overhead) | 16 | ovh_fname = "{}/{}".format(out_dir, FT_SPLIT_NAME).format(overhead) |
36 | 17 | ||
37 | if os.path.exists(ovh_fname): | 18 | if os.path.exists(ovh_fname): |
@@ -39,7 +20,7 @@ def parse_overhead(result, overhead_bin, overhead, cycles, out_dir, err_file): | |||
39 | ovh_file = open(ovh_fname, 'w') | 20 | ovh_file = open(ovh_fname, 'w') |
40 | 21 | ||
41 | # Extract matching overhead events into a seperate file | 22 | # Extract matching overhead events into a seperate file |
42 | cmd = [conf.BINS["split"], "-r", "-b", overhead, overhead_bin] | 23 | cmd = [conf.BINS["ftsplit"], "-r", "-b", overhead, overhead_bin] |
43 | ret = subprocess.call(cmd, cwd=out_dir, stderr=err_file, stdout=ovh_file) | 24 | ret = subprocess.call(cmd, cwd=out_dir, stderr=err_file, stdout=ovh_file) |
44 | size = os.stat(ovh_fname).st_size | 25 | size = os.stat(ovh_fname).st_size |
45 | 26 | ||
@@ -65,9 +46,7 @@ def parse_overhead(result, overhead_bin, overhead, cycles, out_dir, err_file): | |||
65 | os.remove(ovh_fname) | 46 | os.remove(ovh_fname) |
66 | 47 | ||
67 | def sort_ft(ft_file, err_file, out_dir): | 48 | def sort_ft(ft_file, err_file, out_dir): |
68 | """ | 49 | '''Create and return file with sorted overheads from @ft_file.''' |
69 | Create and return file with sorted overheads from @ft_file. | ||
70 | """ | ||
71 | out_fname = "{}/{}".format(out_dir, FT_SORTED_NAME) | 50 | out_fname = "{}/{}".format(out_dir, FT_SORTED_NAME) |
72 | 51 | ||
73 | # Sort happens in-place | 52 | # Sort happens in-place |
@@ -79,3 +58,23 @@ def sort_ft(ft_file, err_file, out_dir): | |||
79 | raise Exception("Sort failed with command: %s" % " ".join(cmd)) | 58 | raise Exception("Sort failed with command: %s" % " ".join(cmd)) |
80 | 59 | ||
81 | return out_fname | 60 | return out_fname |
61 | |||
62 | def extract_ft_data(result, data_dir, work_dir, cycles): | ||
63 | freg = conf.FILES['ft_data'] + "$" | ||
64 | bins = [f for f in os.listdir(data_dir) if re.match(freg, f)] | ||
65 | |||
66 | if not len(bins): | ||
67 | return False | ||
68 | |||
69 | bin_file = "{}/{}".format(data_dir, bins[0]) | ||
70 | |||
71 | with open("%s/%s" % (work_dir, FT_ERR_NAME), 'w') as err_file: | ||
72 | sorted_bin = sort_ft(bin_file, err_file, work_dir) | ||
73 | |||
74 | for event in conf.BASE_EVENTS: | ||
75 | parse_overhead(result, sorted_bin, event, cycles, | ||
76 | work_dir, err_file) | ||
77 | |||
78 | os.remove(sorted_bin) | ||
79 | |||
80 | return True | ||