diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-21 18:32:24 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-21 18:32:24 -0500 |
| commit | 6e2b99a0870e467e35c8b4b95aeb1e665dded413 (patch) | |
| tree | 1e4b4d000c6b53b93a35b5446dc774d4799c987c /parse/ft.py | |
| parent | 9bcbb4048cd82ea11ed469731eae95d808b99449 (diff) | |
Many bugfixes motivated by some end-to-end testing.
Diffstat (limited to 'parse/ft.py')
| -rw-r--r-- | parse/ft.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/parse/ft.py b/parse/ft.py index 5293b00..19453d1 100644 --- a/parse/ft.py +++ b/parse/ft.py | |||
| @@ -3,6 +3,7 @@ import numpy as np | |||
| 3 | import os | 3 | import os |
| 4 | import re | 4 | import re |
| 5 | import shutil as sh | 5 | import shutil as sh |
| 6 | import sys | ||
| 6 | import subprocess | 7 | import subprocess |
| 7 | 8 | ||
| 8 | from point import Measurement,Type | 9 | from point import Measurement,Type |
| @@ -28,7 +29,6 @@ def parse_overhead(result, overhead_bin, overhead, cycles, out_dir, err_file): | |||
| 28 | raise Exception("Failed (%d) with command: %s" % (ret, " ".join(cmd))) | 29 | raise Exception("Failed (%d) with command: %s" % (ret, " ".join(cmd))) |
| 29 | if not size: | 30 | if not size: |
| 30 | os.remove(ovh_fname) | 31 | os.remove(ovh_fname) |
| 31 | |||
| 32 | if size and not ret: | 32 | if size and not ret: |
| 33 | # Map and sort file for stats | 33 | # Map and sort file for stats |
| 34 | data = np.memmap(ovh_fname, dtype="float32", mode='c') | 34 | data = np.memmap(ovh_fname, dtype="float32", mode='c') |
| @@ -47,19 +47,22 @@ def parse_overhead(result, overhead_bin, overhead, cycles, out_dir, err_file): | |||
| 47 | 47 | ||
| 48 | def sort_ft(ft_file, err_file, out_dir): | 48 | def sort_ft(ft_file, err_file, out_dir): |
| 49 | '''Create and return file with sorted overheads from @ft_file.''' | 49 | '''Create and return file with sorted overheads from @ft_file.''' |
| 50 | out_fname = "{}/{}".format("%s/%s" % (os.getcwd(), out_dir), FT_SORTED_NAME) | 50 | out_fname = "{}/{}".format(out_dir, FT_SORTED_NAME) |
| 51 | 51 | ||
| 52 | # Sort happens in-place | 52 | # Sort happens in-place |
| 53 | sh.copyfile(ft_file, out_fname) | 53 | sh.copyfile(ft_file, out_fname) |
| 54 | cmd = [conf.BINS['ftsort'], out_fname] | 54 | cmd = [conf.BINS['ftsort'], out_fname] |
| 55 | ret = subprocess.call(cmd, cwd="%s/%s" % (os.getcwd(), out_dir), stderr=err_file, stdout=err_file) | ||
| 56 | 55 | ||
| 56 | ret = subprocess.call(cmd, cwd=out_dir, stderr=err_file, stdout=err_file) | ||
| 57 | if ret: | 57 | if ret: |
| 58 | raise Exception("Sort failed with command: %s" % " ".join(cmd)) | 58 | raise Exception("Sort failed (%d) with command: %s" % (ret, " ".join(cmd))) |
| 59 | 59 | ||
| 60 | return out_fname | 60 | return out_fname |
| 61 | 61 | ||
| 62 | def extract_ft_data(result, data_dir, work_dir, cycles): | 62 | def extract_ft_data(result, data_dir, work_dir, cycles): |
| 63 | data_dir = os.path.abspath(data_dir) | ||
| 64 | work_dir = os.path.abspath(work_dir) | ||
| 65 | |||
| 63 | freg = conf.FILES['ft_data'] + "$" | 66 | freg = conf.FILES['ft_data'] + "$" |
| 64 | bins = [f for f in os.listdir(data_dir) if re.match(freg, f)] | 67 | bins = [f for f in os.listdir(data_dir) if re.match(freg, f)] |
| 65 | 68 | ||
| @@ -67,6 +70,9 @@ def extract_ft_data(result, data_dir, work_dir, cycles): | |||
| 67 | return False | 70 | return False |
| 68 | 71 | ||
| 69 | bin_file = "{}/{}".format(data_dir, bins[0]) | 72 | bin_file = "{}/{}".format(data_dir, bins[0]) |
| 73 | if not os.path.getsize(bin_file): | ||
| 74 | sys.stderr.write("Empty feather trace file %s!" % bin_file) | ||
| 75 | return False | ||
| 70 | 76 | ||
| 71 | with open("%s/%s" % (work_dir, FT_ERR_NAME), 'w') as err_file: | 77 | with open("%s/%s" % (work_dir, FT_ERR_NAME), 'w') as err_file: |
| 72 | sorted_bin = sort_ft(bin_file, err_file, work_dir) | 78 | sorted_bin = sort_ft(bin_file, err_file, work_dir) |
