UCLA-VAST / tapa

TAPA is a dataflow HLS framework that features fast compilation, expressive programming model and generates high-frequency FPGA accelerators.
https://tapa.rtfd.io
MIT License
144 stars 27 forks source link

TAPA ping-pong buffer #129

Open mvanbeirendonck opened 1 year ago

mvanbeirendonck commented 1 year ago

Hi, I am trying to map an application from Vitis HLS to TAPA. The design almost fully streaming, but there are some parts where I need ping-pong buffer behavior. Is this currently supported by TAPA?

In particular, this is the function:

void permute(tapa::ostream<u64> &sout, tapa::istream<u64> &sin, ap_uint<LOG2SIZE> offset)
{
#pragma HLS function_instantiate variable = offset
#pragma HLS dataflow

    u64 pipo[SIZE];

    // ping-pong buffer write
    for (int i = 0; i < SIZE; i++)
    {
#pragma HLS pipeline rewind
        sin >> pipo[i];
    }

    // ping-pong buffer read
    for (int i = 0; i < SIZE; i++)
    {
#pragma HLS pipeline rewind
        sout << pipo[i ^ offset];
    }
}

The behavior that I am currently seeing is that this compiles fine with TAPA without the #pragma HLS dataflow (i.e. without ping-pong buffer behavior), but with the pragma included compilation gets stuck. I have tried to push the loops into sub-functions with the same result.

I have attached some sources for you to reproduce. They show the same example compiles fine in Vitis HLS.

Thanks for any help!

Blaok commented 1 year ago

Looks like with the pragma, Vitis HLS will crash. I don't have a good explanation for this; it should at least compile fine.