heterocl icon indicating copy to clipboard operation
heterocl copied to clipboard

Weird segfault when adding two bit slice objects

Open seanlatias opened this issue 5 years ago • 5 comments

The following code leads to a segfault

def kernel(A):
  return hcl.compute(A.shape, lambda x: A[x][0:7] + A[x][8:15])

The segfault only happens when the bit slices are the exact numbers as shown in the above code. Other numbers don't seem to create a segfault.

seanlatias avatar Sep 27 '20 14:09 seanlatias

We already know that the segfault happens in the Simplify pass, but the cause is still unknown.

seanlatias avatar Sep 27 '20 14:09 seanlatias

The data type of A also doesn't seem to matter.

seanlatias avatar Sep 27 '20 14:09 seanlatias

Just to confirm -- [0:7] means we are extracting the first 8 bits, right? Last Wed, I saw Xiangyi/Alga use [0:8] and [8:16]

zhangzhiru avatar Sep 27 '20 14:09 zhangzhiru

No, we will be extracting the first 7 bits, which is the same as Python's convention. For Python, the range is upper-bound exclusive.

seanlatias avatar Sep 27 '20 14:09 seanlatias

Can you take a look at the bit slicing support in other HW-oriented Python DSLs, like PyMTL and PyRTL? See if they are following this convention.

zhangzhiru avatar Sep 27 '20 15:09 zhangzhiru