First issue is with scons. A Previous post was concerned with creating my own source and build subdirectories (MyProgs/ and build/MyProgs) and modification of SConstruct to succesfully compile cl_convolution and neon_convolution as a first step for compiling my own attempts. I can succesfully compile all the example programs and the graph_alexnet example in my MyProgs source folder with the following command line:
scons Werror=1 debug=1 -j6 debug=1 asserts=0 embed_kernels=1 neon=1 opencl=1 os=linux arch=armv7a
However, if I add my own program to the source folder, scons doesn't seem to see it or try to compile it. I copied my program to the examples directory and reverted to the original SConstruct in case the *.cpp file names were being referenced from there by scons! Still not seen by scons. I have searched around and can't seem to find any lists of the examples source files so I assume scons must be creating it's own list! So how do I ensure my file is picked up by scons and not filtered out?
Second issue comes about because I started using the manual build compile incantation due to the scons issue above. I originally had problems with making this work but recently succeeded in compiling neon_convolution.cpp using the following command line, (changing -L. to -L./openclLib to find the missing -larm_compute etc):
arm-linux-gnueabihf-g++ MyProgs/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L./openclLib -larm_compute -larm_compute_core -o build/MyProgs/neon_convolution
However when I try to compile my own Opencl program or the cl_convolution example, after the gcc compile is succesfully finished, I end up with ld (Linker??) issues, similar in both cases which makes me think there is something missing from the command line incantation. Comparing the command line with the scons command line, I think, due to unfamiliarity with command line stuff, I'm probably missing a reference to the gpu or openCL (mfpu=neon is there and can't find any relevant examples in the documentation examples!)? Note that the command lines given in the documentation only differ in that "-DARM_COMPUTE_CL" is added to the opencl command line, compilation bombs without it!!
Command line is:
arm-linux-gnueabihf-g++ MyProgs/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L./openclLib -larm_compute -larm_compute_core -o build/MyProgs/cl_convolution -DARM_COMPUTE_CL
This gives the following output, in the case of cl_convolution compilation: (subsequent scons compile works ok for this file)
/tmp/cc99vqAy.o: In function `cl::Context::Context(unsigned long long, int*, void (*)(char const*, void const*, unsigned int, void*), void*, int*)':cl_convolution.cpp:(.text._ZN2cl7ContextC2EyPiPFvPKcPKvjPvES6_S1_[_ZN2cl7ContextC5EyPiPFvPKcPKvjPvES6_S1_]+0x1b0): undefined reference to `clCreateContextFromType'/tmp/cc99vqAy.o: In function `cl::CommandQueue::CommandQueue(cl::Context const&, cl::Device const&, unsigned long long, int*)':cl_convolution.cpp:(.text._ZN2cl12CommandQueueC2ERKNS_7ContextERKNS_6DeviceEyPi[_ZN2cl12CommandQueueC5ERKNS_7ContextERKNS_6DeviceEyPi]+0x48): undefined reference to `clCreateCommandQueue'/tmp/cc99vqAy.o: In function `int cl::Context::getInfo<std::vector<cl::Device, std::allocator<cl::Device> > >(unsigned int, std::vector<cl::Device, std::allocator<cl::Device> >*) const':cl_convolution.cpp:(.text._ZNK2cl7Context7getInfoISt6vectorINS_6DeviceESaIS3_EEEEijPT_[_ZNK2cl7Context7getInfoISt6vectorINS_6DeviceESaIS3_EEEEijPT_]+0x12): undefined reference to `clGetContextInfo'cl_convolution.cpp:(.text._ZNK2cl7Context7getInfoISt6vectorINS_6DeviceESaIS3_EEEEijPT_[_ZNK2cl7Context7getInfoISt6vectorINS_6DeviceESaIS3_EEEEijPT_]+0x16): undefined reference to `clGetContextInfo'collect2: error: ld returned 1 exit status
I've had a search for similar issues on the community page but no success. Any help will be appreciated
I must be getting better at this!! After I fixed the Scons compile and trying to work out how the single module compile is going wrong, I looked at the scons std:out info to see if I could find the difference between the scons compile and single module compile. Then I found it, the command line is missing -lOpenCL!
So the Compute Library documentation for single module compile (linux, native) in the section "How to manually build the examples" at the following heading, needs updating.
"To compile natively (i.e directly on an ARM device) for OpenCL for Linux 32bit or Linux 64bit:"
gives the example:
g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -larm_compute_core -o cl_convolution -DARM_COMPUTE_CLbut should really give something like:g++ MyProgs/cl_convolution.cpp utils/Utils.cpp -o build/MyProgs/cl_convolution.o -I. -Iinclude -std=c++11 -mfpu=neon -L./openclLib -larm_compute -larm_compute_core -lOpenCL -o build/MyProgs/cl_convolution -DARM_COMPUTE_CLA couple of extra things here for the newbies like me! First I have my own source and build subdirectory MyProgs instead of examples.
-o build/MyProgs/cl_convolution.o puts a copy of the object file into the build folder,just like scons does.
-L./openclLib gives the library that the libarm modules and libOpenCL are located, this fixed an earlier problem where the compiler/linker complained it couldn't find -larm_compute etc.-lOpenCL was the missing library causing my problem.-o build/MyProgs/cl_convolution puts the executable in the build directory instead of the directory you are running the command line from!