Getting "HAL Kern Error: Read/Write failed from addr x, read y expected z" when running multithread OpenCL application on CycloneV SoC
To ensure, that I didn't just write an incorrect program, I used the standard multithread example: https://www.intel.com/content/www/us/en/programmable/support/support-resources/design-examples/design-software/opencl/multithreaded-vector-operation.html
As there is no arm32 version of that example, I checked the difference between exm_opencl_hello_world_arm32_linux and exm_opencl_hello_world_x64_linux from https://www.intel.com/content/www/us/en/programmable/support/support-resources/design-examples/design-software/opencl/hello-world.html.
As the only difference was the Makefile, I applied the same changes to the Makefile of exm_opencl_multithread_vector_operation_x64_linux.
diff exm_opencl_hello_world_x64_linux/hello_world/Makefile exm_opencl_hello_world_arm32_linux/hello_world/Makefile
43,44c43,44
< AOCL_COMPILE_CONFIG := $(shell aocl compile-config )
< AOCL_LINK_CONFIG := $(shell aocl link-config )
---
> AOCL_COMPILE_CONFIG := $(shell aocl compile-config --arm)
> AOCL_LINK_CONFIG := $(shell aocl link-config --arm)
53,54c53,54
< # Compiler
< CXX := g++
---
> # Compiler. ARM cross-compiler.
> CXX := arm-linux-gnueabihf-g++Using the changed Makefile, I compiled the multithread example:
cd exm_opencl_multithread_vector_operation_x64_linux/multithread_vector_operation/
PATH="/opt/intelFPGA/19.1/embedded/ds-5/sw/gcc/bin/:$INTELFPGAOCLSDKROOT/bin:$PATH" \
AOCL_BOARD_PACKAGE_ROOT="$INTELFPGAOCLSDKROOT/board/de10_standard" \
VERBOSE=1 make
PATH="/opt/intelFPGA/19.1/embedded/ds-5/sw/gcc/bin/:$INTELFPGAOCLSDKROOT/bin:$PATH" \
AOCL_BOARD_PACKAGE_ROOT="$INTELFPGAOCLSDKROOT/board/de10_standard" \
aoc -board=de10_standard_sharedonly -v device/vector_op.cl -o bin/vector_op.aocxRunning the program sometimes succeeds, but often results in a crash:
root@socfpga:~# ./host
Initializing OpenCL
Platform: Intel(R) FPGA SDK for OpenCL(TM)
Using 1 device(s)
de10_standard_sharedonly : Cyclone V SoC Development Kit
Using AOCX: vector_op.aocx
Reprogramming device [0] with handle 1
Thread1 created successfully
Thread2 created successfully
Instantiating a new problem with args: N=100000 kernel_name=vector_mult
Instantiating a new problem with args: N=100000 kernel_name=vector_add
Launching for device 0 (100000 elements)
Launching for device 0 (100000 elements)
HAL Kern Error: Read failed from addr 1080, read -1234493200 expected 4
HAL Kern Error: Read failed from addr 20, read -1234493200 expected 4
Time: 20.714 ms
Kernel time (device 0): 1.098 ms
HAL Kern Error: Write failed to addr 1080 with value 0, wrote -1234493200 expected 4
HAL Kern Error: Read failed from addr 20, read -1234493200 expected 4
Segmentation faultIs multithreadding not supported on arm32?