Skip to content

Commit

Permalink
[XSICPP] assert timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
maltanar committed Jan 10, 2025
1 parent 407e00f commit 5003647
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/finn/core/rtlsim_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,15 @@ def rtlsim_exec_cppxsi(model, execution_context, dummy_data_mode=False, postproc
launch_process_helper(runsim_cmd, proc_env=runsim_env, cwd=sim_base)

# parse results file and return dict
with open(sim_base + "/results.txt", "r") as f:
results_filename = sim_base + "/results.txt"
with open(results_filename, "r") as f:
results = f.read().strip().split("\n")
ret_dict = {}
for result_line in results:
key, val = result_line.split("\t")
ret_dict[key] = int(val)
if "TIMEOUT" in ret_dict.keys():
assert ret_dict["TIMEOUT"] == 0, f"XSI C++ simulation timed out, see {results_filename}"
return ret_dict


Expand Down
8 changes: 7 additions & 1 deletion src/finn/qnn-data/cpp/xsi_simdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ int main(int argc, char *argv[]) {
for(size_t i = 0; i < outstream_names.size(); i++) {
if(n_out_txns[i] == n_iters_per_output[i]) n_outputs_with_one_completion++;
}
if(n_outputs_with_one_completion == outstream_names.size()) latency = iters;
if(n_outputs_with_one_completion == outstream_names.size()) {
cout << "All outputs have now produced a sample, latency = " << iters << " cycles" << endl;
latency = iters;
}
}
}

Expand All @@ -395,6 +398,9 @@ int main(int argc, char *argv[]) {
results_file << "cycles" << "\t" << iters << endl;
results_file << "N" << "\t" << n_inferences << endl;
results_file << "latency_cycles" << "\t" << latency << endl;
results_file << "TIMEOUT" << "\t" << timeout ? 1 : 0<< endl;
results_file << "INPUT_DONE" << "\t" << input_done ? 1 : 0 << endl;
results_file << "OUTPUT_DONE" << "\t" << output_done ? 1 : 0 << endl;
// optionally, extract more data from final status
@POSTPROC_CPP@
results_file.close();
Expand Down

0 comments on commit 5003647

Please sign in to comment.