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

Support data placement with disconnected DFG #274

Closed hecmay closed 3 years ago

hecmay commented 4 years ago

I just checked Alex's code. The root cause is that the graph partitioning algorithm assumes there is a path from input nodes to output nodes in the DFG. But this is not always true.

The minimum test case to produce the error. In this program, the output does not depend on inputs.

def kernel(A, B):
    return hcl.compute((10,32), lambda *args: 1, "O")

# Not using .to() here since we have the auto-placement feature now
s = hcl.create_schedule([A, B], kernel)
f = hcl.build(s, target)
hecmay commented 4 years ago

Added a fix that should eliminate most of the subgraph related bugs -- Whenever the algorithm fails to extract the subgraph, it rolls back and offload the whole function body to the FPGA device.

hecmay commented 3 years ago

This is fixed already. When the output does not depend on the inputs (this kind of behavior does not make much sense, but it is still valid), the algorithm will throw out a critical warning, but keep generating the HLS code.

Test cases: https://github.com/cornell-zhang/heterocl/blob/heteroflow/tests/issues/test_issue_274.py