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

[API][Refactor] Rewrite basic scheduling functions -- fuse/reorder/split #80

Closed seanlatias closed 5 years ago

seanlatias commented 5 years ago

In this PR, we rewrite some of the basic scheduling functions. The idea is that now the IR changes everytime a scheduling function is applied. Specifically, we have added a new feature for loop splitting. Namely, now the if/else condition for non-trivial loop splitting will be inserted in a smart way. Following we show some examples.

  1. No conditional statement is inserted if the factor is a divisor.
    
    A = hcl.compute((10, 10), lambda x, y: ...)
    xo, xi = s[A].split(A.axis[0],  factor=2)

IR

for (xo, 0, 5) for (xi, 0, 2) for (y, 0, 10)

compute


2. A conditional statement is inserted otherwise. In addition, it will be inserted in the innermost loop if possible (a check is made to ensure that).
```python
xo, xi = s[A].split(A.axis[0], factor=3)

# IR
for (xo, 0, 4)
  for (xi, 0, 3)
    for (y, 0, 10)
      if (xo*3 + xi < 10)  # under innermost loop    
        # compute