Xilinx / QNN-MO-PYNQ

BSD 3-Clause "New" or "Revised" License
236 stars 114 forks source link

Python3 to lib_hw.so connection problem on ZynqMP (aarch64) , "python3: unhandled alignment fault (7)" #18

Closed Pe3ucTop closed 5 years ago

Pe3ucTop commented 5 years ago

I compile this library for ZCU102 board (ZynqMP Ultrascale+) and get working app_hw.elf binary. When trying to use library from Python3.6 getting error (python crash) with: In console, when python crash/get back to shell: "Bus error" In system logs: " python3: unhandled alignment fault (7) at 0x7f78695080, esr 0x92000061, in libc-2.27.so[7f8bed6000+140000] CPU: 0 PID: 5065 Comm: python3 Not tainted 4.14.0-xilinx-v2018.2 #1 Hardware name: ZynqMP ZCU102 Rev1.0 (DT) "

giuliogamba commented 5 years ago

Official support to Ultrascale+ PYNQ boards (Ultra96/ZCU104) will be added soon.

feolcn commented 5 years ago

Official support to Ultrascale+ PYNQ boards (Ultra96/ZCU104) will be added soon.

Good news,and when it release?

Pe3ucTop commented 5 years ago

Is there any news ?

giuliogamba commented 5 years ago

Just pushed the update to PYNQ 2.3 and support to Ultra96 PYNQ board (with Ultrascale+ Zynq)

giuliogamba commented 5 years ago

Please let me know if this works for you

feolcn commented 5 years ago

hi @giuliogamba when will support ZCU104?

Pe3ucTop commented 5 years ago

@giuliogamba Sorry for long reply, was out of the office. Update did not solve problem, still getting "Bus error" with "unhandled alignment fault (7)"

giuliogamba commented 5 years ago

It seems odd, we were able to compile everything on Ultra96 board. Are you sure you pulled the latest version? On which board are you experiencing this?

Pe3ucTop commented 5 years ago

Yes, I tried the latest version too, without success. Yes, It's odd, because app_hw work without problems, but lib_hw fail , both use same functions. But I find problem source, it is "memset" which is for (char )type buffer , in file "qnn/src/library/host/offload-utils.cpp" , it is used in "padTo" function. It failing when zeroing testBuffer provided in singleInference() under lib_hw . If it is executed on additional buffer, it do not fail. But final solution I use is in file "qnn/src/library/host/offload-utils.cpp" line 40 : "OffloadUtils::memset(bufferPadded, 0, outputSize); " need replace with "OffloadUtils::memset((ExtMemWord )bufferPadded, 0, outputSize);"

I testing on 2 different boards: Xilinx ZCU102 and Enclustra Mars XU3 . And using lib_hw from Python3.6 for quicker prototyping.

giuliogamba commented 5 years ago

You are correct, the problem is in the memset when used on non-cacheable memory with -O3 as optimization strategy. That's why we changed the optimization strategy here to -O2 and avoid the problem.

Pe3ucTop commented 5 years ago

Thanks for pointing to exact changes relayed to problem. I will recheck once again if I recompile all correctly and give report.

Pe3ucTop commented 5 years ago

Yes, you are right, optimization strategy changes result working lib_hw. Thanks.