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

Enhance .to() to generate VivadoHLS-preferred dataflow pattern #315

Open hecmay opened 3 years ago

hecmay commented 3 years ago

Here is a simplified example of HLS code generated from our 1d CONV test case ( after using .to() to customize the dataflow architecture):

void main(int*A, int*B) {
  for (int a=0; a < 100; a++) {
  #pragma HLS dataflow
    PE1(A, out1)
    PE2(out1, out2)
    PE3(out2, B)
  }
}

It seems that Vivado cannot synthesize the dataflow pattern above. HLS tool complains that A and B cannot be accessed by multiple processes... Even marking memory A and B as stable still does not help.

To make the HLS happy, we need to move the for loop inside each PE.

void main(int*A, int*B) {
  #pragma HLS dataflow
    // Each PE has the temporal loop inside their bodies
    PE1_(A, out1)
    PE2_(out1, out2)
    PE3_(out2, B)
}