Skip to content

Commit f82c28c

Browse files
authored
Set nonzero exit status when gemmbench compilation/execution fails (#71)
See also 384cae4, which did the same for convbench.
1 parent c478b34 commit f82c28c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

iree_kernel_benchmark/gemmbench/__main__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ def compile_gemm(
166166
with Pool(num_cpus) as pool:
167167
compilation_results = list(tqdm(pool.starmap(compile_gemm, list(compile_args))))
168168

169-
error_count = 0
169+
compile_error_count = 0
170170
for tag, config, mlir_file, vmfb_file in compilation_results:
171171
if vmfb_file:
172172
vmfb_dict[vmfb_file] = (tag, config)
173173
else:
174-
error_count += 1
174+
compile_error_count += 1
175175
print(
176-
f"{len(configs) - error_count} Success, {error_count} Failed out of {len(configs)} configs"
176+
f"{len(configs) - compile_error_count} Success, {compile_error_count} Failed out of {len(configs)} configs"
177177
)
178178

179179
print("Compilation process completed.")
@@ -190,6 +190,7 @@ def compile_gemm(
190190
if not os.path.exists(csv_dir):
191191
os.makedirs(csv_dir)
192192

193+
run_error_count = 0
193194
for vmfb_filename, value in vmfb_dict.items():
194195
tag, config = value
195196
vmfb_hash = generate_md5_hex(vmfb_filename)
@@ -218,6 +219,8 @@ def compile_gemm(
218219
# iree benchmark kernels
219220
ret_value, cmd_out, cmd_err = run_iree_command(exec_args)
220221
ok = ret_value == 0
222+
if not ok:
223+
run_error_count += 1
221224
benchmark_gemm_mean_time_ms = bench_summary_process(ret_value, cmd_out)
222225
benchmark_gemm_mean_time_us = benchmark_gemm_mean_time_ms * 1000
223226

@@ -266,3 +269,8 @@ def compile_gemm(
266269

267270
write_results_to_csv(results, output_csv, fieldnames)
268271
print(f"Results written to {output_csv}")
272+
273+
if compile_error_count != 0 or run_error_count != 0:
274+
exit(1)
275+
else:
276+
exit(0)

0 commit comments

Comments
 (0)