cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
322 stars 92 forks source link

multi-stage kernel cannot be unrolled #84

Closed Blaok closed 5 years ago

Blaok commented 5 years ago

The samples/seidel/seidel.py sample isn't working as expected. To properly generate SODA code, all stencil loops must be unrolled with the same factor; however, only the second stage (output) of seidel can be unrolled; it will crash if one tries to unroll the first stage (tmp). This can be reproduced by uncommenting this line.

seanlatias commented 5 years ago

Please check #85.

Blaok commented 5 years ago

Thanks. With #85 it no longer crashes, but the unroll factors are missing from both loops (tmp and output).

seanlatias commented 5 years ago

Really? Can you show me the IR? I tested here but I don't see any problem. Thanks.

Blaok commented 5 years ago

If you change the target to soda instead of soda_xhls, you'll see the unroll factor is 1, not 8.

seanlatias commented 5 years ago

No, that's because you unroll the innermost loop, which is the reduce axis. However, when you traverse the loop in "stencil.cc", you stop at the "y" loop. I'm not sure which loop you intend to unroll.

Blaok commented 5 years ago

Oh the reduction loops are also included in the axes. How to distinguish reduction loops from normal loops? I need to unroll the innermost loop of the tensor dimensions. Hard coding [1] works but will break for 3-dimensional applications.

seanlatias commented 5 years ago

If you know there is only one reduction axis, just use the second-to-the-last axis?