cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
326 stars 92 forks source link

Add burst mode for host-to-device data copy #277

Closed hecmay closed 3 years ago

hecmay commented 4 years ago

Burst read and write enables multiple items to be read from global memory to the kernel’s local memory. This is done to achieve low memory access latency and also for efficient use of bandwidth provided by the m_axi interface. Similarly, computation results are stored in a buffer and are written to global memory in a burst.

When moving data from the host to the device or the opposite, we should allow users to create a burst buffer inside the kernel, and copy the data from global memory to the kernel's local memory in bursts.

s.to(A, target.xcel, burst=True, max_burst_len=256)

The expected code generated should have the following interface:

extern "C" {
void vadd(int *A, int size, int inc_value) {
#pragma HLS INTERFACE m_axi port = A offset = slave bundle = gmem max_read_burst_length = 256 max_write_burst_length = 256

#pragma HLS INTERFACE s_axilite port = a
#pragma HLS INTERFACE s_axilite port = size
#pragma HLS INTERFACE s_axilite port = inc_value
#pragma HLS INTERFACE s_axilite port = return

  int A.burstbuffer[SIZE];
    // Auto-pipeline is going to apply pipeline to these loops
    for (int j = 0; j < chunk_size; j++) {
      A.burstbuffer[j] = A[j];
    }