Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions xls/data_structures/binary_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ absl::StatusOr<int64_t> BinarySearchMaxTrueWithStatus(
absl::FunctionRef<absl::StatusOr<bool>(int64_t i)> f,
BinarySearchAssumptions assumptions) {
XLS_RET_CHECK_LE(start, end);
if (assumptions == BinarySearchAssumptions::kEndKnownTrue ||
(start == end &&
assumptions == BinarySearchAssumptions::kStartKnownTrue)) {
// We're already done.
return end;
}
if (assumptions != BinarySearchAssumptions::kStartKnownTrue) {
XLS_ASSIGN_OR_RETURN(bool f_start, f(start));
if (!f_start) {
Expand Down Expand Up @@ -79,6 +85,11 @@ absl::StatusOr<int64_t> BinarySearchMinTrueWithStatus(
absl::FunctionRef<absl::StatusOr<bool>(int64_t i)> f,
BinarySearchAssumptions assumptions) {
XLS_RET_CHECK_LE(start, end);
if (assumptions == BinarySearchAssumptions::kStartKnownTrue ||
(start == end && assumptions == BinarySearchAssumptions::kEndKnownTrue)) {
// We're already done.
return start;
}
if (assumptions != BinarySearchAssumptions::kEndKnownTrue) {
XLS_ASSIGN_OR_RETURN(bool f_end, f(end));
if (!f_end) {
Expand Down
3 changes: 2 additions & 1 deletion xls/scheduling/pipeline_schedule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ absl::StatusOr<PipelineScheduleProto> PipelineSchedule::ToProto(
std::max(delay_to_node_start, node_path_delays.at(operand));
}
}
int64_t node_delay = delay_estimator.GetOperationDelayInPs(node).value();
XLS_ASSIGN_OR_RETURN(int64_t node_delay,
delay_estimator.GetOperationDelayInPs(node));
int64_t path_delay = delay_to_node_start + node_delay;
node_delays[node] = node_delay;
node_path_delays[node] = path_delay;
Expand Down
23 changes: 15 additions & 8 deletions xls/scheduling/run_pipeline_schedule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,9 @@ absl::StatusOr<PipelineSchedule> RunPipelineScheduleInternal(
}

if (options.pipeline_stages() == 1 &&
!options.clock_period_ps().has_value() &&
!options.failure_behavior().explain_infeasibility) {
!options.clock_period_ps().has_value()) {
// No scheduling to be done, and there's no way to violate timing; just
// schedule everything (other than literals) in the first cycle.
// schedule everything timed into the first cycle.
ScheduleCycleMap cycle_map;
XLS_ASSIGN_OR_RETURN(std::vector<Node*> topo_sort_nodes, TopoSort(f));
for (Node* node : topo_sort_nodes) {
Expand All @@ -650,12 +649,20 @@ absl::StatusOr<PipelineSchedule> RunPipelineScheduleInternal(
PipelineSchedule schedule,
PipelineSchedule::Create(f, std::move(cycle_map),
{.length = options.pipeline_stages()}));
XLS_RETURN_IF_ERROR(schedule.Verify());
XLS_RETURN_IF_ERROR(
schedule.VerifyConstraints(options.constraints(), options));
absl::Status status = schedule.Verify();
status.Update(schedule.VerifyConstraints(options.constraints(), options));
if (status.ok()) {
XLS_VLOG_LINES(3, "Schedule\n" + schedule.ToString());
return schedule;
}

// If we don't need to explain the infeasibility, return the error.
if (!options.failure_behavior().explain_infeasibility) {
return std::move(status);
}

XLS_VLOG_LINES(3, "Schedule\n" + schedule.ToString());
return schedule;
// If we do need to explain the infeasibility, fall through to the normal
// scheduling code to let it attempt to explain.
}

XLS_ASSIGN_OR_RETURN(absl::flat_hash_set<Node*> dead_after_synthesis,
Expand Down
Loading