Duplicated streaming commands cause synthesis error
Closed this issue · 0 comments
chhzh123 commented
Errors may occur when careless programmers type the same streaming command several times, like the following example, where B->C
is done twice. (Actually, this will easily happen when there're lots of stages to be streamed.)
def test_duplicated():
A = hcl.placeholder((10,), "A")
def kernel(A):
B = hcl.compute(A.shape,
lambda i: A[i] + 1, "B")
C = hcl.compute(B.shape,
lambda i: B[i] + 1, "C")
return C
target = hcl.platform.zc706
target.config(compile="vivado_hls", mode="csyn")
s = hcl.create_schedule([A], kernel)
s.to([A], target.xcel)
s.to(kernel.C, target.host)
s.to(kernel.B, s[kernel.C])
s.to(kernel.B, s[kernel.C]) # duplicated streaming
f = hcl.build(s, target)
np_A = np.zeros((10,))
np_C = np.zeros((10,))
hcl_A = hcl.asarray(np_A)
hcl_C = hcl.asarray(np_C)
f(hcl_A, hcl_C)
The compiler should detect this duplication and allocate the streaming buffer only once. However, the generated code redundantly allocates a B_pipe_1
buffer causing synthesis error.
void test(bit32 A[10], bit32 C[10]) {
bit32 B[10];
bit32 B_pipe_1[10];
#pragma HLS stream variable=B_pipe_1 depth=1
#pragma HLS dataflow
bit32 B_pipe_2[10];
#pragma HLS stream variable=B_pipe_2 depth=2
B_i: for (bit32 i = 0; i < 10; ++i) {
bit32 B_temp;
B_temp = (A[i] + 1);
B_pipe_2[i] = B_temp;
B_pipe_1[i] = B_temp;
B[i] = B_temp;
}
C_i1: for (bit32 i1 = 0; i1 < 10; ++i1) {
bit32 B_temp1;
B_temp1 = B_pipe_2[i1];
C[i1] = (B_temp1 + 1);
}
}
INFO: [XFORM 203-712] Applying dataflow to function 'test', detected/extracted 2 process function(s):
'Loop_B_i_proc7'
'Loop_C_i1_proc'.
ERROR: [XFORM 203-123] Cannot stream 'B_pipe_1.V1': a local variable is streamable only if it is in a dataflow region.
ERROR: [HLS 200-70] Pre-synthesis failed.