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 for hls::stream in VHLS backend #286

Closed hecmay closed 3 years ago

hecmay commented 4 years ago

The FIFO is implemented as an annotated multi-dim array in VHLS backend:

int fifo[100];
#pragma HLS STREAM variable=fifo depth=100

However, this makes it hard to declare multiple FIFO channels (which is needed when combining tiling and streaming).

hls::stream FIFO_arr[O];
for (outer, O)
    for (inner, I)
        FIFO_arr[outer].write(data);
zhangzhiru commented 4 years ago

Why is it difficult to declare multiple FIFO channels using the array-based coding style?

hecmay commented 4 years ago

@zhangzhiru I meant currently in heterocl we are not able to do so. It is not a problem in HLS.

zhangzhiru commented 4 years ago

I see. Can you provide a high-level reason why this is hard in HeteroCL?

hecmay commented 4 years ago

@zhangzhiru This is not hard to implement in HeteroCL. This issue is opened just for bookkeeping, and it will be supported in the next release.

zhangzhiru commented 4 years ago

@chhzh123 you're saying you've already modified the codegen logic to generate hls::stream?

chhzh123 commented 4 years ago

@chhzh123 you're saying you've already modified the codegen logic to generate hls::stream?

Yes, I use a simple but tricky way to generate the stream reads and writes -- If _pipe or _channel is in variable names, then the varible is supposed to be a stream buffer. This method is used by Shaojie at the very beginning, where only the VHLS codegen needs to be changed. However, to distinguish a normal buffer and a stream buffer, it would be better to register a new IR node, like StreamAllocate. I think @Hecmay has done this and make the stream buffers generation robust in his PR?

hecmay commented 3 years ago

Yes. This has been done in #265. The load and store operations on FIFOs are replaced into StreamStmt and StreamExpr1 IRs, and will be printed as hls:stream.write() and hls::stream.read().

hecmay commented 3 years ago

This has already been fixed. Test cases: https://github.com/cornell-zhang/heterocl/blob/heteroflow/tests/test_schedule_stream.py#L340