XRT
XRT copied to clipboard
pyxrt not compatible with numpy v2.0.0
Using pyxrt with numpy v2.0.0 results in all bytes being read as 1.
Minimal reproduction script below. Uses xclbin file available here: https://gitlab.com/ska-telescope/low-cbf/ska-low-cbf-fw-cnic/-/packages/26156556 but I think any xclbin file or different Alveo card is likely to produce the same result.
import pyxrt
device = pyxrt.device("0000:d2:00.1")
xclbin = pyxrt.xclbin("./cnic.xclbin")
uuid = device.load_xclbin(xclbin)
kernel_names = [kernel.get_name() for kernel in xclbin.get_kernels()]
cu_name = kernel_names[0]
kernel = pyxrt.kernel(device, uuid, cu_name, pyxrt.kernel.cu_access_mode(0))
mem_group_ids = []
num_args = 0
for n in range(100):
try:
gid = kernel.group_id(n)
num_args += 1
if gid not in (-1, 0xFFFF):
mem_group_ids.append(gid)
print(f"Kernel group: {n}, memory bank {gid}")
except IndexError as e:
print(f"_load_firmware; n:{n}, {e}")
break
buf = pyxrt.bo(device, 128<<10, pyxrt.bo.flags.normal, mem_group_ids.pop(0))
task = kernel(0, 0x8000*4, buf, 64)
task.wait()
buf.sync(pyxrt.xclBOSyncDirection.XCL_BO_SYNC_BO_FROM_DEVICE, 64, 0)
result = buf.read(64, 0)
print(result)
# Wrong result w/ numpy v2.0.0
# array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
# 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
# 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
# dtype=int8)
# Correct result w/ numpy v1.23.0
# array([ 1, 112, 106, -7, 18, 25, 9, 35, 1, 0, 0, 0, 0,
# 0, 0, 0, 102, 102, 102, 102, 0, 0, 0, 0, 1, 0,
# 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 67, 73, 78,
# 67, 18, 39, -49, 99, 78, 73, 65, 77, 64, 2, 0, 0,
# 1, 117, -57, 57, 62, 2, 0, 0, 0, 0, 0, 0],
# dtype=int8)