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

async_mmap get some warning: channel 'read_data' destructed with leftovers #157

Closed lifeformg closed 3 months ago

lifeformg commented 3 months ago

I wrote a function to read data from async_mmap into a stream, the program seems to run fine, but gives the following warning message at the end:

WARNING: Logging before InitGoogleLogging() is written to STDERR
I0418 16:31:28.685515 2119402 task.h:54] running software simulation with TAPA library
65536:65536
read_mask finished
65536:65536
read_mask finished
65536:65536
read_mask finished
65536:65536
read_mask finished
W0418 16:31:32.159674 2119402 stream.h:56] channel 'read_data' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.159710 2119402 stream.h:56] channel 'read_addr' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.160077 2119402 stream.h:56] channel 'read_data' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.160087 2119402 stream.h:56] channel 'read_addr' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.160427 2119402 stream.h:56] channel 'read_data' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.160437 2119402 stream.h:56] channel 'read_addr' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.160758 2119402 stream.h:56] channel 'read_data' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
W0418 16:31:32.160768 2119402 stream.h:56] channel 'read_addr' destructed with leftovers; hardware behavior may be unexpected in consecutive invocations
Kernel execution time: 3.47789 s
PASS!

The code is as follows:

void read_mask(tapa::async_mmap<int> & mat_mask,
               tapa::ostream<int> & fifo_mask) {
    int read_times = (NUM_S * NUM_S / COL_SIZE / NUM_PE_V);
    rd_A:
    int count_req = 0, count_res = 0;
    for(int i_req = 0, i_resp = 0; i_resp < read_times;) {
#pragma HLS pipeline II=1
        if ((i_req < read_times) &
            !mat_mask.read_addr.full()) {
            mat_mask.read_addr.try_write(i_req);
            count_req++;
            ++i_req;
        }
        if (!fifo_mask.full() & !mat_mask.read_data.empty()) {
            int tmp;
            mat_mask.read_data.try_read(tmp);
            count_res++;
            fifo_mask.try_write(tmp);
            ++i_resp;
        }
    }
    cout << count_req << ":" << count_res << endl;
    cout << "read_mask finished" << endl;
}

The output indicates that count_req is equal to count_req.

tapa::task()
        .invoke<tapa::join, NUM_PE_V>
            (read_mask, mat_mask_ch, fifo_mask)
lifeformg commented 3 months ago

I did some more tests, replacing async_mmap with mmap also generates the same warning. What's even stranger is that when I reduce the number of elements read from mmap (reducing to 10), the warning message disappears, and when reading more elements, the number of warnings also increases. (In the example above, I read 65536 elements)