Skip to content

Commit

Permalink
Improve error reporting from codegen scheduling failures
Browse files Browse the repository at this point in the history
Replaces a QFATAL log line, instead constructing a Status containing more error details to be passed up to final error handling.

Also fixes a case (at least one of `pipeline_stages` and `clock_period_ps` unspecified) where we accidentally discarded the error and crashed with an XLS_RET_CHECK.

PiperOrigin-RevId: 555559547
  • Loading branch information
ericastor authored and copybara-github committed Aug 10, 2023
1 parent eeb9b3e commit c55c3e8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions xls/tools/codegen_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,19 @@ absl::StatusOr<PipelineSchedule> RunSchedulingPipeline(
if (absl::IsResourceExhausted(scheduling_status)) {
// Resource exhausted error indicates that the schedule was
// infeasible. Emit a meaningful error in this case.
if (scheduling_options.pipeline_stages().has_value() &&
scheduling_options.clock_period_ps().has_value()) {
// TODO(meheff): Add link to documentation with more information and
// guidance.
XLS_LOG(QFATAL) << absl::StreamFormat(
"Design cannot be scheduled in %d stages with a %dps clock.",
scheduling_options.pipeline_stages().value(),
scheduling_options.clock_period_ps().value());
std::string error_message = "Design cannot be scheduled";
if (scheduling_options.pipeline_stages().has_value()) {
absl::StrAppendFormat(&error_message, " in %d stages",
scheduling_options.pipeline_stages().value());
}
} else {
return scheduling_status;
if (scheduling_options.clock_period_ps().has_value()) {
absl::StrAppendFormat(&error_message, " with a %dps clock",
scheduling_options.clock_period_ps().value());
}
return xabsl::StatusBuilder(scheduling_status).SetPrepend()
<< error_message << ": ";
}
return scheduling_status;
}
XLS_RET_CHECK(scheduling_unit.schedule.has_value());

Expand Down

0 comments on commit c55c3e8

Please sign in to comment.