Skip to content

Commit

Permalink
Fix all "unscheduled update()" warnings in our code (#7991)
Browse files Browse the repository at this point in the history
* Fix all "unscheduled update()" warnings in our code

And also fix the Mullapudi scheduler to explicitly touch all update stages. This allows us to mark this warning as an error if we so choose.

* fixes

* fixes

* Update recursive_box_filters.cpp
  • Loading branch information
steven-johnson authored Dec 7, 2023
1 parent 83febb0 commit df36139
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apps/hist/hist_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Hist : public Halide::Generator<Hist> {
.compute_at(hist_rows.in(), y)
.vectorize(x, vec);

hist_rows.update(0).unscheduled();
hist_rows.in()
.compute_root()
.vectorize(x, vec)
Expand All @@ -199,7 +200,7 @@ class Hist : public Halide::Generator<Hist> {
.parallel(x)
.reorder(ry, x);

cdf.compute_root();
cdf.compute_root().update().unscheduled();
output.reorder(c, x, y)
.bound(c, 0, 3)
.unroll(c)
Expand Down
2 changes: 2 additions & 0 deletions apps/iir_blur/iir_blur_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Func blur_cols_transpose(Func input, Expr height, Expr alpha, bool skip_schedule
blur.compute_at(transpose, yo);

// Vectorize computations within the strips.
blur.update(0)
.unscheduled();
blur.update(1)
.reorder(x, ry)
.vectorize(x);
Expand Down
2 changes: 1 addition & 1 deletion src/autoschedulers/anderson2021/cost_model_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ class CostModel : public Generator<CostModel<training>> {
};

// Pipeline features processing
conv1_stage1.compute_root().vectorize(c);
conv1_stage1.compute_root().vectorize(c).update().vectorize(c);
squashed_head1_filter.compute_root().vectorize(c);

// Schedule features processing. The number of schedule
Expand Down
33 changes: 25 additions & 8 deletions src/autoschedulers/mullapudi2016/AutoSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,20 +837,27 @@ struct AutoSchedule {
}
}

for (const auto &m : f.second) {
const int stage = m.first;
const vector<string> &schedules = m.second;
internal_assert(!schedules.empty());
const int num_stages = func.updates().size() + 1;
for (int stage = 0; stage < num_stages; stage++) {
schedule_ss << " " << fname;
if (stage > 0) {
schedule_ss << ".update(" << std::to_string(stage - 1) << ")";
schedule_ss << ".update(" << (stage - 1) << ")";
}
for (const std::string &s : schedules) {
schedule_ss << "\n ." << s;
auto it = f.second.find(stage);
if (it != f.second.end()) {
const vector<string> &schedules = it->second;
internal_assert(!schedules.empty());
for (const std::string &s : schedules) {
internal_assert(!s.empty());
schedule_ss << "\n ." << s;
}
} else {
if (stage > 0) {
schedule_ss << ".unscheduled()";
}
}
schedule_ss << ";\n";
}

schedule_ss << "}\n";
}

Expand Down Expand Up @@ -3386,6 +3393,16 @@ string generate_schedules(const vector<Function> &outputs, const Target &target,
debug(2) << "Generating CPU schedule...\n";
part.generate_cpu_schedule(target, sched);

// Ensure that all update stages are "touched" so we get no warnings/errors
for (const auto &f : sched.func_schedules) {
const Function &func = get_element(sched.env, f.first);
const int num_update_stages = func.updates().size();
for (int stage = 0; stage < num_update_stages; stage++) {
Definition def = get_stage_definition(func, stage + 1);
def.schedule().touched() = true;
}
}

std::ostringstream oss;
oss << sched;
string sched_string = oss.str();
Expand Down
4 changes: 4 additions & 0 deletions test/correctness/recursive_box_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ int main(int argc, char **argv) {
// have to pass 'true' to the atomic call to tell it to skip the check.
h.update(2).atomic(true).vectorize(r, 16);

// These stages don't need scheduling
h.update(0).unscheduled();
h.update(1).unscheduled();

Buffer<int> r0(size);
Buffer<int> r1(size);
h.realize({r0, r1});
Expand Down
1 change: 1 addition & 0 deletions test/error/tuple_output_bounds_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ int main(int argc, char **argv) {

Var xo, xi;
h.split(x, xo, xi, 16, TailStrategy::RoundUp);
h.update(0).unscheduled();

Buffer<int> r0(size);
Buffer<int> r1(size);
Expand Down

0 comments on commit df36139

Please sign in to comment.