I am including tech-talk in my reply, because I am hoping someone else may have an idea what is wrong. I don't have any experience cross-compiling for ARM.
I understand that you can build a standalone OpenCL program that runs on the ARM, but when you try to run it from within an areaDetector driver it crashes.
If your program is linking and starting up with no errors then I think your Makefile and included libraries are probably OK.
The first thing to check is the compiler and linker flags being used in both cases. Can you send the complete output of the following:
- Building the standalone OpenCL application
- Building the EPICS application
- Running the IOC, including the crash.
From: Ricardo Herrero [mailto:firstname.lastname@example.org]
Sent: Wednesday, August 16, 2017 6:19 AM
To: Mark Rivers
Subject: Help with issue compiling areaDetector Driver
I wonder if you can help with a problem I have with areaDetector driver.
I need to ask you a question about the areaDetector driver I´m developing. After what we talked last time, I have renamed driver and included the proper paths for it to work. But
I continue to receive a difficult error. I wonder if you could help me to debug it. I´m trying to use openCL inside areaDetector and I have an openCL program that alone works in my ARM device after cross compiling it in an x86_64 host. I can also execute cross-compiled
areaDetector and EPICS in this ARM device. But when I insert my openCL code (it is written in C) inside areaDetector driver, after a few functions there is one which returns a munmap_chunk() error and the driver crashes. I can´t see why it is not working. I
thought it would be because Makefile is not including all the proper libraries. I have been testing different options, but I always receive the same error. I have also debugged the code, but when it jumps to the function clCreateProgramWithBinary it crashes
and I can´t get any information. This seems to work properly without areaDetector, but I can´t see the differences.
I don´t know if it is caused by openCL being executed in EPICS environment. What I do is runnning my executable, called hpsfpga1dtest with my st.cmd file and I received the following result:
*** Error in `../../bin/linux-arm/hpsfpga1dtest': munmap_chunk(): invalid pointer: 0x00294a98 ***
The function where the problem appears is (it is an openCL function):
program = clCreateProgramWithBinary(context, 1, &device, (const size_t *)&binary_size, (const unsigned char **)&binary_buf, &binary_status, &status_ocl);
I send you the makefile log of the areaDetector driver, the compile sentence for my openCL program and the code for openCL. openCL program is called main.cpp and its code has been
included in the creation method of the areaDetector driver. I also send you my Makefiles for the library and the IOC. When I compile the library, HPS_FPGA_1D.cpp should be compiled with AOCL_Utils.cpp, I think it is done properly, because some functions are
properly executed, but this particular method, clCreateProgramWithBinary returns SIGABRT and munmap_chunk() error.
Finally I want to send you the code which I´m working on, if it can help, it includes my driver, with openCL utils, 4 files are in the same folder HPS_FPGA_1DApp, and the ioc code.
There is something more I have seen, but I don´t know if it is important. In the makefile log I have seen that some pragmas are ignored when compiled in EPICS. However when I compile
openCL alone I don´t receive any warning. I think I´m using the same cross-compiler, so I can´t see why this difference.
Thanks a lot for the help and your time, any advice to make new tests are welcomed!
Jefe de Área de Ingeniería de Sistemas - CEH- CEDEX