Skip to content

Instantly share code, notes, and snippets.

@pranavb-ca
Last active April 24, 2018 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pranavb-ca/ba7e4ccb2961ac860fba5c50d85174af to your computer and use it in GitHub Desktop.
Save pranavb-ca/ba7e4ccb2961ac860fba5c50d85174af to your computer and use it in GitHub Desktop.
Trying to compute a Func with an update definition so that they share their y loop
avg_box = sum(x, y)/25; //sum(x, y) is the sum of the pixels in a 5x5 neighborhood of (x, y).
calc(x, y) = (0);
calc(x, y) << 1) + (src_data(x+r.x, y+r.y) > avg_box(x, y));
output(x, y) = calc(x, y);
//schedule
Func(output)
.hexagon()
.split(y, yo, y, ht/2)
.prefetch(in, y, 2)
.tile(x, y, xi, yi, vector_size, 4)
.vectorize(xi)
.unroll(yi)
.parallel(yo);
avg_box
.compute_at(output, y)
.tile(x, y, xi, yi, vector_size, 2)
.vectorize(xi)
.unroll(yi);
calc
.compute_at(output, y)
.vectorize(x, vector_size);
calc
.update(0)
.vectorize(x, vector_size);
Func(output).print_loop_nest();
// produce output:
// for __outermost in [0, 0]<Hexagon>:
// parallel y.yo:
// for y.y.y:
// produce bounded_input:
// for y:
// for x.x:
// vectorized x.v24 in [0, 127]:
// bounded_input(...) = ...
// consume bounded_input:
// produce avg_box:
// for y.y:
// for x.x:
// unrolled y.yi in [0, 1]:
// vectorized x.xi in [0, 127]:
// avg_box(...) = ...
// consume avg_box:
// produce calc:
// for y: // Loop Nest A
// for x.x:
// vectorized x.v47 in [0, 127]:
// calc(...) = ...
// for y: // Loop Nest B: Not sharing the y loop with the previous loop nest A
// for x.x:
// vectorized x.v50 in [0, 127]:
// for r:
// for r:
// calc(...) = ...
// consume calc:
// for x.x:
// unrolled y.y.yi in [0, 3]:
// vectorized x.xi in [0, 127]:
// output(...) = ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment