Skip to content

Commit b2ce853

Browse files
ldionnemahesh-attarde
authored andcommitted
[libc++] Improve handling of runtime errors inside SPEC benchmarks
Previously, we would report a successful run if the benchmark exited with an error, and we would produce a timing for the benchmark. After this patch, we consider an error in the benchmark to be a failed LIT test and we don't produce any benchmark data for it.
1 parent a65017e commit b2ce853

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

libcxx/test/benchmarks/spec.gen.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@
7272
print(f'RUN: %{{spec_dir}}/bin/runcpu --config %T/spec-config.cfg --size train --output-root %T --rebuild {benchmark}')
7373
print(f'RUN: rm -rf %T/benchspec') # remove the temporary directory, which can become quite large
7474

75-
# Parse the results into a LNT-compatible format. This also errors out if there are no CSV files, which
76-
# means that the benchmark didn't run properly (the `runcpu` command above never reports a failure).
77-
print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results %T/result/*.train.csv --output-format=lnt > %T/results.lnt || ! cat %T/result/*.log')
75+
# The `runcpu` command above doesn't fail even if the benchmark fails to run. To determine failure, parse the CSV
76+
# results and ensure there are no compilation errors or runtime errors in the status row. Also print the logs and
77+
# fail if there are no CSV files at all, which implies a SPEC error.
78+
print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results --extract "Base Status" --keep-failed %T/result/*.train.csv > %T/status || ! cat %T/result/*.log')
79+
print(f'RUN: ! grep -E "CE|RE" %T/status || ! cat %T/result/*.log')
80+
81+
# If there were no errors, parse the results into LNT-compatible format and print them.
82+
print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results %T/result/*.train.csv --output-format=lnt > %T/results.lnt')
7883
print(f'RUN: cat %T/results.lnt')

libcxx/utils/parse-spec-results

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def main(argv):
5858
'sure to use appropriate quoting for header names that contain spaces. This option only makes sense '
5959
'when the output format is CSV.')
6060
parser.add_argument('--keep-not-run', action='store_true',
61-
help='Keep entries whose \'Base Status\' is marked as \'NR\', aka \'Not Run\'. By default, such entries are discarded.')
61+
help='Keep entries whose "Base Status" is marked as "NR" (aka "Not Run"). By default, such entries are discarded.')
62+
parser.add_argument('--keep-failed', action='store_true',
63+
help='Keep entries whose "Base Status" is marked as "CE" (aka "Compilation Error") or "RE" (aka "Runtime Error"). '
64+
'By default, such entries are discarded.')
6265
args = parser.parse_args(argv)
6366

6467
if args.table == 'full':
@@ -76,10 +79,12 @@ def main(argv):
7679
headers = parsed_headers
7780
rows.extend(parsed_rows)
7881

79-
# Remove rows that were not run unless we were asked to keep them
82+
# Remove rows that were not run (or failed) unless we were asked to keep them
83+
status = headers.index('Base Status')
8084
if not args.keep_not_run:
81-
not_run = headers.index('Base Status')
82-
rows = [row for row in rows if row[not_run] != 'NR']
85+
rows = [row for row in rows if row[status] != 'NR']
86+
if not args.keep_failed:
87+
rows = [row for row in rows if row[status] not in ('CE', 'RE')]
8388

8489
if args.extract is not None:
8590
if args.output_format != 'csv':

0 commit comments

Comments
 (0)